## Re: [Audacity-nyquist] Clipping with inversed polarity -

 Re: [Audacity-nyquist] Clipping with inversed polarity - From: Dr. Gary Nelson - 2008-12-24 23:14:06 ```Arnoud Onnink wrote: >> In it I have made an attempt to outline a computational model for fixing >> "inversed polarity clipping" (for lack of a better name), where a clipped >> signal turns negative. The binary values of samples are encoded in 2-complement with the most significant bit being the sign-bit -- 1 ==> negative, 0 ==> positive. The largest positive number is 0111 1111 1111 1111 or 32767 in integer format. If you add ONE to that number you get 32768 or 1000 0000 0000 0000 which is a negative number. So it is totally normal to get this rather awful result that clipping creates negative numbers. To finish the story, we convert a positive binary number to negative by inverting all bits and adding one. 0000 0000 0000 0111 is +7 in integer format. To create -7 we invert 1111 1111 1111 1000 and add + 1 1111 1111 1111 1001 is -7 in 2's complement It is necessary that +7 +(-7) = 0 0000 0000 0000 0111 1111 1111 1111 1001 ----------------------- 0000 0000 0000 0000 so 2's complement works The max negative number is 0111 1111 1111 1111 ,inverted becomes 1000 0000 0000 0000 +1 1 1000 0000 0000 0001 is negative max As an exercise, you can add positive max to negative max and get zero. Gary Nelson Port Townsend, WA ```

 [Audacity-nyquist] Clipping with inversed polarity - idea for a fix From: Arnoud Onnink - 2008-05-17 12:18:12 ```Dear mailing list, I would like to bring to your attention the following topic on the Audacity forums: http://audacityteam.org/forum/viewtopic.php?f=20&t=4377 In it I have made an attempt to outline a computational model for fixing "inversed polarity clipping" (for lack of a better name), where a clipped signal turns negative. Details (including waveform pictures) can be found in the link, not just the first post but also the follow-ups. Unfortunately I'm a lousy Nyquist programmer desperately in need for this fix. Hopefully the description in the topic could inspire you to write a Nyquist plugin that will convert "inversed clipping" to "normal clipping" which can then be treated with the regular clipfix.ny ? Thank you for your attention. Regards, Arnie ```
 Re: [Audacity-nyquist] Clipping with inversed polarity - idea for a fix From: Gale (Audacity Team) - 2008-12-22 09:33:50 ``` Arnoud Onnink wrote: > > I would like to bring to your attention the following topic on the > Audacity forums: > http://audacityteam.org/forum/viewtopic.php?f=20&t=4377 > In it I have made an attempt to outline a computational model for fixing > "inversed polarity clipping" (for lack of a better name), where a clipped > signal turns negative. Details (including waveform pictures) can be found > in the link, not just the first post but also the follow-ups. > > Unfortunately I'm a lousy Nyquist programmer desperately in need for this > fix. Hopefully the description in the topic could inspire you to write a > Nyquist plugin that will convert "inversed clipping" to "normal clipping" > which can then be treated with the regular clipfix.ny ? Since Arnoud posted this message there has been a lot more activity in the above thread, mostly enquiring if Clipfix can be rewritten to process faster/use less RAM in doing so. Do Edgar or Roger have any views? Clipfix is deservedly very popular but people do get frustrated with the performance. As someone else pointed out, it also deletes audio it can't handle, which means with the current "largenumber" of 100 million samples it is limited to some 37 minutes of 44100 Hz audio, even if the computer can process it. In fact there is a general problem in Audacity that if you cancel a Nyquist effect after starting processing, the audio that was never dealt with is deleted, so would I presume the Clipfix issue is part of that same problem? Another improvement that might be handy for Clipfix would be some kind of optional de-amplification before processing. Here is the current code, if anyone has any comments: http://audacity.cvs.sourceforge.net/viewvc/audacity/audacity-src/plug-ins/clipfix.ny?revision=1.3&view=markup Thanks, and Christmas greetings. Gale -- View this message in context: http://n2.nabble.com/Clipping-with-inversed-polarity---idea-for-a-fix-tp238860p1689443.html Sent from the audacity-nyquist mailing list archive at Nabble.com. ```
 Re: [Audacity-nyquist] Clipping with inversed polarity - From: Dr. Gary Nelson - 2008-12-24 23:14:06 ```Arnoud Onnink wrote: >> In it I have made an attempt to outline a computational model for fixing >> "inversed polarity clipping" (for lack of a better name), where a clipped >> signal turns negative. The binary values of samples are encoded in 2-complement with the most significant bit being the sign-bit -- 1 ==> negative, 0 ==> positive. The largest positive number is 0111 1111 1111 1111 or 32767 in integer format. If you add ONE to that number you get 32768 or 1000 0000 0000 0000 which is a negative number. So it is totally normal to get this rather awful result that clipping creates negative numbers. To finish the story, we convert a positive binary number to negative by inverting all bits and adding one. 0000 0000 0000 0111 is +7 in integer format. To create -7 we invert 1111 1111 1111 1000 and add + 1 1111 1111 1111 1001 is -7 in 2's complement It is necessary that +7 +(-7) = 0 0000 0000 0000 0111 1111 1111 1111 1001 ----------------------- 0000 0000 0000 0000 so 2's complement works The max negative number is 0111 1111 1111 1111 ,inverted becomes 1000 0000 0000 0000 +1 1 1000 0000 0000 0001 is negative max As an exercise, you can add positive max to negative max and get zero. Gary Nelson Port Townsend, WA ```