I want to convert a 16-bit wav file to 12 bit raw audio samples (to simulate the output of an ADC).
I'm trying to run
$ sox file.wav --bits 12 --encoding signed-integer --endian little 12_bit_signed_le/file.raw
And I get the error
sox WARN formats: raw can't encode Signed Integer PCM to 12-bit Output File : '12_bit_signed_le/file.raw' Channels : 1 Sample Rate : 4410 Precision : 16-bit Duration : 00:59:53.47 = 15847219 samples ~ 269511 CDDA sectors Sample Encoding: 16-bit Signed Integer PCM Endian Type : little Reverse Nibbles: no Reverse Bits : no Comment : 'Processed by SoX' sox INFO sox: effects chain: input 4410Hz 1 channels sox INFO sox: effects chain: output 4410Hz 1 channels
As you can see, the command resulted in 16-bit output. How do I force it to truncate to 12 bits?
Also, do I need to be worried about clipping (as this post suggests?)