Discussion:
[SoX-users] Converting a wav file to 20-bit depth
R R
2012-12-02 22:38:12 UTC
Permalink
Hello sox experts,



I have a .wav file with a 32-bit depth which I need to convert to 20-bit.
I tried the following:

sox input.wav -b 20 output.wav

Where input.wav is a 24-bit depth file. But I get the following warning:

"sox WARN formats: wav can't encode to 20-bit"

I thought 20-bit depth format was simply 24-bit data with the LSBs padded to 0. Is this correct?
Or sox doesn't support 20-bit conversion? Or the wav format itself doesn't support 20-bit?

If not, suggestions on any other methods/tools are welcome.

Thanks,
Ulrich Klauer
2012-12-03 03:40:52 UTC
Permalink
Post by R R
I thought 20-bit depth format was simply 24-bit data with the LSBs
padded to 0. Is this correct?
Essentially, yes. There is also a wValidBitsPerSample header entry
that says "20" instead of "24". Unfortunately, the SoX WAVE format
driver is restricted to 8/16/24/32 bit.
Post by R R
Or sox doesn't support 20-bit conversion? Or the wav format itself doesn't support 20-bit?
If not, suggestions on any other methods/tools are welcome.
If it is sufficient for you to have 20-bit values in the file, but
still a header saying "24", then you can use the -p option to dither:
sox input.wav -b 24 output.wav dither -p 20

If you need a correct header, probably the easiest way to achieve this
is changing the generated file afterwards with a hex editor or similar
(change the byte at position 38/0x26 from 24/0x18 into 20/0x14).

Ulrich
Sergei Steshenko
2012-12-03 03:49:24 UTC
Permalink
________________________________
Sent: Monday, December 3, 2012 5:40 AM
Subject: Re: [SoX-users] Converting a wav file to 20-bit depth
I thought 20-bit depth format was simply 24-bit data with the LSBs 
padded to 0. Is this correct?
Essentially, yes. There is also a wValidBitsPerSample header entry 
that says "20" instead of "24". Unfortunately, the SoX WAVE format 
driver is restricted to 8/16/24/32 bit.
Or sox doesn't support 20-bit conversion? Or the wav format itself 
doesn't support 20-bit?
If not, suggestions on any other methods/tools are welcome.
If it is sufficient for you to have 20-bit values in the file, but 
   sox input.wav -b 24 output.wav dither -p 20
If you need a correct header, probably the easiest way to achieve this 
is changing the generated file afterwards with a hex editor or similar 
(change the byte at position 38/0x26 from 24/0x18 into 20/0x14).
Ulrich
Is there at all sense in supporting 20 (rather than 24) bits ?

I mean, say, does USB audio protocol allow 20 bits, thus saving some bandwidth ?

Regards,
  Sergei.

Loading...