Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: Increase bit-depth with Sox (Read 9475 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Increase bit-depth with Sox

I have a question about increse bit-depth with Sox.

I have want to lower the volume a wave file (16 bit 44.100 kHz) of, let's say 25% and I want to increase the bit-depth to 24 bit.

The command line I use is this:
sox -V4 bs.wav -b 24 -t wavpcm bs24.wav -D vol 0.75

and here it is the output of sox:


Input File    : 'bs.wav'
Channels      : 2
Sample Rate    : 44100
Precision      : 16-bit
Duration      : 00:03:49.67 = 10128300 samples = 17225 CDDA sectors
File Size      : 40.5M
Bit Rate      : 1.41M
Sample Encoding: 16-bit Signed Integer PCM
Endian Type    : little
Reverse Nibbles: no
Reverse Bits  : no

sox INFO sox: Overwriting `bs24.wav'
sox DBUG wav: Writing Wave file: Microsoft PCM format, 2 channels, 44100 samp/se
c
sox DBUG wav:        264600 byte/sec, 6 block align, 24 bits/samp

Output File    : 'bs24.wav'
Channels      : 2
Sample Rate    : 44100
Precision      : 16-bit
Duration      : 00:03:49.67 = 10128300 samples = 17225 CDDA sectors
Sample Encoding: 24-bit Signed Integer PCM
Endian Type    : little
Reverse Nibbles: no
Reverse Bits  : no
Comment        : 'Processed by SoX'

sox INFO sox: effects chain: input      44100Hz 2 channels 16 bits (multi)
sox INFO sox: effects chain: vol        44100Hz 2 channels 32 bits (multi)
sox INFO sox: effects chain: output    44100Hz 2 channels 16 bits (multi)
sox DBUG wav: Finished writing Wave file, 60769800 data bytes 10128300 samples



Why the last operation has a precision of only 16 bit while the output is 24 bit?

Increase bit-depth with Sox

Reply #1
It seems that the output operation uses the same precision of the input file 
So basically if I have to apply some kind of operation to a 16 bit file, even if all the effects uses a precision of 32 bit and I set the output file to 24 bit , the output will only have 16 precision (and 8 zero padding bit to obtain a 24 bit output).
The only way to obtain a "true 24 bit precision file" is to pre-convert the 16 bit file to a 24 bit file (adding 8 padding bits) and then apply the effects to the 24 bit file.

Is there a way to get a 24 bit precision output file starting from a 16 bit file?

Increase bit-depth with Sox

Reply #2
I tested your command line with SoX 14.3.1.

Adobe audition reports: Actual bit depth = 18 so I think that SoX works correctly.

Increase bit-depth with Sox

Reply #3
It's right there in the documentation. The first input/output option described is for bits/sample.
Quote
Input & Output File Format Options

These options apply to the input or output file whose name they immediately precede on the command line and are used mainly when working with headerless file formats or when specifying a format for the output file that is different to that of the input file.
-b BITS, --bits BITS
The number of bits (a.k.a. bit-depth or sometimes word-length) in each encoded sample. Not applicable to complex encodings such as MP3 or GSM. Not necessary with encodings that have a fixed number of bits, e.g. A/µ-law, ADPCM.
For an input file, the most common use for this option is to inform SoX of the number of bits per sample in a `raw' (`headerless') audio file. For example
Code: [Select]
sox -r 16k -e signed -b 8 input.raw output.wav
converts a particular `raw' file to a self-describing `WAV' file.
For an output file, this option can be used (perhaps along with -e) to set the output encoding size. By default (i.e. if this option is not given), the output encoding size will (providing it is supported by the output file type) be set to the input encoding size. For example
Code: [Select]
sox input.cdda -b 24 output.wav
converts raw CD digital audio (16-bit, signed-integer) to a 24-bit (signed-integer) `WAV' file.

Increase bit-depth with Sox

Reply #4
It's right there in the documentation. The first input/output option described is for bits/sample.
Quote
Input & Output File Format Options

These options apply to the input or output file whose name they immediately precede on the command line and are used mainly when working with headerless file formats or when specifying a format for the output file that is different to that of the input file.
-b BITS, --bits BITS
The number of bits (a.k.a. bit-depth or sometimes word-length) in each encoded sample. Not applicable to complex encodings such as MP3 or GSM. Not necessary with encodings that have a fixed number of bits, e.g. A/µ-law, ADPCM.
For an input file, the most common use for this option is to inform SoX of the number of bits per sample in a `raw' (`headerless') audio file. For example
Code: [Select]
sox -r 16k -e signed -b 8 input.raw output.wav
converts a particular `raw' file to a self-describing `WAV' file.
For an output file, this option can be used (perhaps along with -e) to set the output encoding size. By default (i.e. if this option is not given), the output encoding size will (providing it is supported by the output file type) be set to the input encoding size. For example
Code: [Select]
sox input.cdda -b 24 output.wav
converts raw CD digital audio (16-bit, signed-integer) to a 24-bit (signed-integer) `WAV' file.



Bit-precision is different to bit depth of a file, my output file always have the right bit depth but not the bit precision...


Increase bit-depth with Sox

Reply #5
Do the following:

Code: [Select]
sox bs.wav -b 24 -t wavpcm bs24_1.wav -D vol 0.75
sox bs.wav -b 24 temp.wav -D
sox temp.wav -b 24 -t wavpcm bs24_2.wav -D vol 0.75

then compare bs24_1.wav and bs24_2.wav: they're bit-identical.

Increase bit-depth with Sox

Reply #6
Do the following:

Code: [Select]
sox bs.wav -b 24 -t wavpcm bs24_1.wav -D vol 0.75
sox bs.wav -b 24 temp.wav -D
sox temp.wav -b 24 -t wavpcm bs24_2.wav -D vol 0.75

then compare bs24_1.wav and bs24_2.wav: they're bit-identical.


It works... My problem is present only if I dither, if I avoid dithering the problem disappear

Try this:
sox -V5 bs.wav -b 24 -t wavpcm bs24_1.wav  deemph dither -f shibata
sox temp.wav -b 24 -t wavpcm bs24_2.wav
sox -V5 temp.wav -b 24 -t wavpcm bs24_2.wav  deemph dither -f shibata

in this case bs24_1.wav have only 16 bit precison

 

Increase bit-depth with Sox

Reply #7
Do the following:

Code: [Select]
sox bs.wav -b 24 -t wavpcm bs24_1.wav -D vol 0.75
sox bs.wav -b 24 temp.wav -D
sox temp.wav -b 24 -t wavpcm bs24_2.wav -D vol 0.75

then compare bs24_1.wav and bs24_2.wav: they're bit-identical.


It works... My problem is present only if I dither, if I avoid dithering the problem disappear

Try this:
sox -V5 bs.wav -b 24 -t wavpcm bs24_1.wav  deemph dither -f shibata
sox temp.wav -b 24 -t wavpcm bs24_2.wav
sox -V5 temp.wav -b 24 -t wavpcm bs24_2.wav  deemph dither -f shibata

in this case bs24_1.wav have only 16 bit precison


I understand dithering from 32 bit to 24 bit is overkill