SoX -1 produces clipped samples? |
SoX -1 produces clipped samples? |
Oct 7 2012, 02:33
Post
#1
|
|
|
Group: Members Posts: 10 Joined: 27-November 11 Member No.: 95436 |
I was trying to invert the absolute phase of some audio files using SoX, and for one of those files SoX reports that 2 peaks have been clipped. This occurs with both the -v switch and the -vol effect. both set at exactly -1. When I set the amount to 0.9, clipping does not occur.
Why is this one file clipping at -1? Thanks. |
|
|
|
![]() |
Oct 7 2012, 03:18
Post
#2
|
|
![]() Group: Members Posts: 735 Joined: 17-September 06 Member No.: 35307 |
I was trying to invert the absolute phase of some audio files using SoX, and for one of those files SoX reports that 2 peaks have been clipped. This occurs with both the -v switch and the -vol effect. both set at exactly -1. When I set the amount to 0.9, clipping does not occur. Why is this one file clipping at -1? Thanks. This would be a pure inversion of normalised values, where the normalised range -1 to 0 to +1 is inverted to +1 to 0 to -1. (If you have waves more complicated than a continuous sinusoid in mind, forget phase, think polarity inversion, that's what's actually being done) In non-floating point, e.g. 16-bit, signed value 0 is defined as zero - no audio, no DC component, so the range of allowed signed integer values goes from -32768 to +32767. Regardless of whether you define -1 to be -32768 or -32767, it's impossible to invert the -32768 to +32768 because the latter value is not permitted in 16-bit signed representation so it must be clipped to +32767. Setting volume scaling to 0.99996948 (=32767/32768) would be enough to prevent clipping (requires dither to decorrelate quantization noise). If you want mathematical perfection, the best way is to convert to floating point output, e.g. 32-bit float. Such minor clipping is almost certainly inaudible, however, if you just do what you already did. |
|
|
|
Oct 7 2012, 03:45
Post
#3
|
|
|
Group: Members Posts: 10 Joined: 27-November 11 Member No.: 95436 |
I was trying to invert the absolute phase of some audio files using SoX, and for one of those files SoX reports that 2 peaks have been clipped. This occurs with both the -v switch and the -vol effect. both set at exactly -1. When I set the amount to 0.9, clipping does not occur. Why is this one file clipping at -1? Thanks. This would be a pure inversion of normalised values, where the normalised range -1 to 0 to +1 is inverted to +1 to 0 to -1. (If you have waves more complicated than a continuous sinusoid in mind, forget phase, think polarity inversion, that's what's actually being done) In non-floating point, e.g. 16-bit, signed value 0 is defined as zero - no audio, no DC component, so the range of allowed signed integer values goes from -32768 to +32767. Regardless of whether you define -1 to be -32768 or -32767, it's impossible to invert the -32768 to +32768 because the latter value is not permitted in 16-bit signed representation so it must be clipped to +32767. Setting volume scaling to 0.99996948 (=32767/32768) would be enough to prevent clipping (requires dither to decorrelate quantization noise). If you want mathematical perfection, the best way is to convert to floating point output, e.g. 32-bit float. Such minor clipping is almost certainly inaudible, however, if you just do what you already did. Interesting. I just realized that I've never inverted an audio file that had a 100% peak until now. Thanks for clarifying! EDIT: So, to make sure I understand you, if I set the scaling to 0.999969482421875 (or how many digits I can calculate This post has been edited by Morality124: Oct 7 2012, 03:53 |
|
|
|
Morality124 SoX -1 produces clipped samples? Oct 7 2012, 02:33
Dynamic sox -gain h --volume -1 -gain r input.wav output.w... Oct 8 2012, 00:46![]() ![]() |
|
Lo-Fi Version | Time is now: 23rd May 2013 - 08:03 |