Menu

#295 clipping warning even with guard

open
nobody
None
5
2024-11-30
2017-07-28
danadam
No

The following command:

sox -G input.flac -b 16 output.flac

prints: WARN dither: dither clipped 136 samples; decrease volume?

But this command, which I thought should be equivalent, does not:

sox input.flac -b 16 output.flac gain -h dither -s

Is that expected behavior?

Below are logs when run with -V -V:

sox -V -V -G input.flac -b 16 output.flac

Input File     : 'input.flac'
Channels       : 2
Sample Rate    : 44100
Precision      : 24-bit
Duration       : 00:08:41.00 = 22976100 samples = 39075 CDDA sectors
File Size      : 86.4M
Bit Rate       : 1.33M
Sample Encoding: 24-bit FLAC
Endian Type    : little
Reverse Nibbles: no
Reverse Bits   : no

sox INFO flac: encoding at 16 bits per sample

Output File    : 'output.flac'
Channels       : 2
Sample Rate    : 44100
Precision      : 16-bit
Duration       : 00:08:41.00 = 22976100 samples = 39075 CDDA sectors
Sample Encoding: 16-bit FLAC
Endian Type    : little
Reverse Nibbles: no
Reverse Bits   : no

sox DBUG dither: mult=0.999969
sox DBUG output: mult=0.999969
sox INFO sox: effects chain: input        44100Hz  2 channels (multi) 24 bits 00:08:41.00
sox INFO sox: effects chain: gain         44100Hz  2 channels         24 bits 00:08:41.00
sox INFO sox: effects chain: dither       44100Hz  2 channels         16 bits 00:08:41.00
sox INFO sox: effects chain: output       44100Hz  2 channels (multi) 16 bits 00:08:41.00
sox WARN dither: dither clipped 136 samples; decrease volume?

sox -V -V input.flac -b 16 output.flac gain -h dither -s

Input File     : 'input.flac'
Channels       : 2
Sample Rate    : 44100
Precision      : 24-bit
Duration       : 00:08:41.00 = 22976100 samples = 39075 CDDA sectors
File Size      : 86.4M
Bit Rate       : 1.33M
Sample Encoding: 24-bit FLAC
Endian Type    : little
Reverse Nibbles: no
Reverse Bits   : no

sox INFO flac: encoding at 16 bits per sample

Output File    : 'output.flac'
Channels       : 2
Sample Rate    : 44100
Precision      : 16-bit
Duration       : 00:08:41.00 = 22976100 samples = 39075 CDDA sectors
Sample Encoding: 16-bit FLAC
Endian Type    : little
Reverse Nibbles: no
Reverse Bits   : no

sox DBUG dither: mult=0.998589
sox DBUG output: mult=0.998589
sox INFO sox: effects chain: input        44100Hz  2 channels (multi) 24 bits 00:08:41.00
sox INFO sox: effects chain: gain         44100Hz  2 channels         24 bits 00:08:41.00
sox INFO sox: effects chain: dither       44100Hz  2 channels         16 bits 00:08:41.00
sox INFO sox: effects chain: output       44100Hz  2 channels (multi) 16 bits 00:08:41.00

Discussion

  • Laszlo Ersek

    Laszlo Ersek - 2024-11-08

    Actually, after a bit of experimenting, the difference is not beween the global -G option and the explicit gain effect. Instead, it's the -s option of the dither effect that makes the difference. The -s option selects the Shibata noise-shaping filter for dither.

    There are three cases:

    sox -G in.wav -r 44100 -b 16 -e signed-integer out.wav
    sox    in.wav -r 44100 -b 16 -e signed-integer out.wav gain -h dither
    sox    in.wav -r 44100 -b 16 -e signed-integer out.wav gain -h dither -s
    

    The first two are identical; both will clip samples (dependent on the pseudo-random noise generated, of course). The third one is the only one that selects the Shibata noise-shaping filter for dither, and will not clip samples.

     

Log in to post a comment.

MongoDB Logo MongoDB