Change recording bit rate to 16

Hello,

What is the most minimal way to change the bit rate of SC record output when using basic:

Server.default.record;

It’s by default 32 bits which is a problem when importing the file in some other audio applications.
( CDP for instance)
Thanks

Here you can set it:
https://doc.sccode.org/Classes/Server.html#-recSampleFormat
Possible sampleFormat values are listed in SoundFile: https://doc.sccode.org/Classes/SoundFile.html#-sampleFormat

And by the way, you can set a format too:
https://doc.sccode.org/Classes/Server.html#-recHeaderFormat
Possible values: https://doc.sccode.org/Classes/SoundFile.html#-headerFormat

But beware, not all sampleFormat + headerFormat combinations are valid. There’s a reference table at libsndfile: http://www.mega-nerd.com/libsndfile/

Example:

// let's set 16-bit wav
s.recSampleFormat = "int16"
s.recHeaderFormat = "wav"

// or, both in one line:
s.recSampleFormat_("int16").recHeaderFormat_("wav")

FWIW I would recommend recording to 32 bits, so that you can recover from out-of-range signals.

If you have 32-bit floats, the shape of out-of-range signals is preserved, and the ffmpeg utility can convert them (and you can script this in SC, to do multiple files).

If you have 16-bit integers and some parts of the signal went out of range, the shape is lost forever and you can never get it back. So it’s mild inconvenience on the one hand, vs risk of permanent loss of some of the data on the other.

hjh

OK, thanks both, that’s clear.