Wrong stats for 32bit float when the files exceeds the range of 24bit int and has positive db full scale..
The attached file has range [-147.554 db ... +26.876 db].
Also it plays with clipping.
Currently to be able to work with such files in sox, we have to load this file into other DAW and attenuate it to -26.876 db.
I think we cannot do it with sox.
Below is a terminal output:
sox -V6 32_bit_float.WAV -n stats -w 0.01
sox: SoX v14.4.2
time: Feb 22 2015 14:58:07
uname: Darwin 13.4.0 Darwin Kernel Version 13.4.0: Mon Jan 11 18:17:34 PST 2016; root:xnu-2422.115.15~1/RELEASE_X86_64 x86_64
compiler: gcc 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.56)
arch: 1288 48 88 L
sox INFO formats: detected file format type `wav'
sox DBUG wav: Searching for 66 6d 74 20
sox DBUG wav: WAV Chunk bext
sox DBUG wav: WAV Chunk iXML
sox DBUG wav: WAV Chunk fmt
sox WARN wav: wave header missing extended part of fmt chunk
sox DBUG wav: Searching for 64 61 74 61
sox DBUG wav: WAV Chunk data
sox DBUG wav: Reading Wave file: IEEE Float format, 2 channels, 48000 samp/sec
sox DBUG wav: 384000 byte/sec, 8 block align, 32 bits/samp, 2593552 data bytes
sox DBUG wav: 324194 Samps/chans
sox DBUG wav: Searching for 4c 49 53 54
Input File : '32_bit_float.WAV'
Channels : 2
Sample Rate : 48000
Precision : 25-bit
Duration : 00:00:06.75 = 324194 samples ~ 506.553 CDDA sectors
File Size : 2.60M
Bit Rate : 3.08M
Sample Encoding: 32-bit Floating Point PCM
Endian Type : little
Reverse Nibbles: no
Reverse Bits : no
Output File : '' (null)
Channels : 2
Sample Rate : 48000
Precision : 25-bit
Duration : 00:00:06.75 = 324194 samples ~ 506.553 CDDA sectors
sox DBUG effects: sox_add_effect: extending effects table, new size = 8
sox INFO sox: effects chain: input 48000Hz 2 channels (multi) 25 bits 00:00:06.75
sox INFO sox: effects chain: stats 48000Hz 2 channels 25 bits 00:00:06.75
sox INFO sox: effects chain: output 48000Hz 2 channels (multi) 25 bits 00:00:06.75
sox DBUG sox: start-up time = 0.013954
Overall Left Right
DC offset -0.008247 -0.008247 -0.008247
Min level -1.000000 -1.000000 -1.000000
Max level 1.000000 1.000000 1.000000
Pk lev dB 0.00 0.00 0.00
RMS lev dB -6.04 -6.04 -6.04
RMS Pk dB -0.15 -0.15 -0.15
RMS Tr dB -45.47 -45.47 -45.47
Crest factor - 2.00 2.00
Flat factor 28.85 28.85 28.85
Pk count 68.3k 68.3k 68.3k
Bit-depth 32/32 32/32 32/32
Num samples 324k
Length s 6.754
Scale max 1.000000
Window s 0.010
sox WARN sox: `32_bit_float.WAV' input clipped 136698 samples
Confirmed. Using Samplitude I created a 32-bit float .wav file in mono which contained a peak of +10 dB. No matter how I try to reduce the volume, sox clips the input before reducing the volume, leading to distortion. Example:
sox -v 0.1 loud.wav -b 16 output.wavI am having this problem too. There is no way to get 32bit float files with volume over 0dbfs to not clip.
Last edit: Maurice Casteene 2022-07-02
There is a way:
https://codeberg.org/sox_ng/sox_ng/issues/422
I think sox must avoid clipping whenever possible. If this workaround is the easiest solution then, when sox determines the user wants 32 bit float as output or stats, it must start using libsndfile implicitely without specifying -t sndfile.