Setting the sample rate in a WAV file

[email protected] Thu, 6 May 2021 19:20:34 +0000
Newsgroups gmane.comp.audio.supercollider.user
Message-ID <[email protected]>
Hello list,

I have a process that creates signals at rates other than the server's sample rate, and I want to save these signals using a custom UGen GatedDiskOut that writes a frame only on a trigger (very useful). But then I need to get the effective sample rate into the WAV file header, and I can't figure out how. I have tried buffer.sampleRate, but buffer.write and buffer.close both seem to ignore that, writing the server's samplerate to the WAV header instead.  I also tried sf = Soundfile.new(path) followed by sf.sampleRate and sf.asBuffer to specify  the buffer,  but to no avail. Is there any way of creating and writing to a WAV file with a sample rate set to something different from the server's?

Thanks

sternsc