Clipping with inversed polarity - idea for a fix

6 Messages Forum Options Options
Embed this topic
Permalink
Arnoud Onnink
Clipping with inversed polarity - idea for a fix
Reply Threaded MoreMore options
Print post
Permalink
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


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Audacity-nyquist mailing list
Audacity-nyquist@...
https://lists.sourceforge.net/lists/listinfo/audacity-nyquist
Gale (Audacity Team)
Re: Clipping with inversed polarity - idea for a fix
Reply Threaded MoreMore options
Print post
Permalink
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




       
Roger Dannenberg
Re: Clipping with inversed polarity - idea for a fix
Reply Threaded MoreMore options
Print post
Permalink
In reply to this post by Arnoud Onnink
Since the clipfix code begins by making copy of the input sound, I can
understand why the code uses a lot of memory. The algorithm used by the
code is undocumented and the indentation does not match the program
structure, so I didn't get very far trying to quickly grasp what's
really going on there. I'd be happy to comment on approaches if anyone
plans to do some rewriting. -Roger


------------------------------------------------------------------------------
_______________________________________________
Audacity-nyquist mailing list
Audacity-nyquist@...
https://lists.sourceforge.net/lists/listinfo/audacity-nyquist
paul beach-2
Re: Clipping with inversed polarity - idea for a fix
Reply Threaded MoreMore options
Print post
Permalink
Season's Greeting,

I am changing topic, or going back to something related to the original
thread.

Can the low pas roll off be 6 or 12 decibels per octave?

(simrep ( i  n) can make a sin wave series. If the cut off of the low
pass filter is set to the first harmonic, it will be similar to a
Fourier series.

Question two, see plug-in, the first operation can only be + for the
next step
(hzosc (+ (* i p) p) )

Perhaps I don't understan simrep.


I want to use this for something practical, (for me).

Consider the propeller noise of an airplane. There will be a beat for
two engines, and also for the turbulence at the wings tips. This wasted
energy would look like a helix at the edge of the air foil.

The attached plug has a sine series of 11 overtones. The default setting
mixes this with a sine of 5 hertz which is quite audible; that is you
certainly do hear lower than 20 herz if it is part of the waveform.

If  A.M. is set to 30 herz it sounds like a motor boat. At 1 or less it
sounds like an airplane. With some frequency modulation it could sound
like a dogfight.

A higher Fundamental setting at 600 hertz sounds like a mosquito, but as
mentioned, there should be a low pass roll off of 6 or 12 decibels.


On Wed, 24 Dec 2008 11:09:40 -0500, "Roger Dannenberg" <rbd@...>
said:

> Since the clipfix code begins by making copy of the input sound, I can
> understand why the code uses a lot of memory. The algorithm used by the
> code is undocumented and the indentation does not match the program
> structure, so I didn't get very far trying to quickly grasp what's
> really going on there. I'd be happy to comment on approaches if anyone
> plans to do some rewriting. -Roger
>
>
> ------------------------------------------------------------------------------
> _______________________________________________
> Audacity-nyquist mailing list
> Audacity-nyquist@...
> https://lists.sourceforge.net/lists/listinfo/audacity-nyquist
--
  paul beach
  sniffyraven@...



------------------------------------------------------------------------------

_______________________________________________
Audacity-nyquist mailing list
Audacity-nyquist@...
https://lists.sourceforge.net/lists/listinfo/audacity-nyquist

a1-fourier.ny (448 bytes) Download Attachment
Dr. Gary Nelson
Re: Clipping with inversed polarity -
Reply Threaded MoreMore options
Print post
Permalink
In reply to this post by Gale (Audacity Team)
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 mailing list
Audacity-nyquist@...
https://lists.sourceforge.net/lists/listinfo/audacity-nyquist
Arnoud Onnink
Re: Clipping with inversed polarity -
Reply Threaded MoreMore options
Print post
Permalink
Dear Dr. Nelson,

Thank you for your reply. It is good to know the underlying cause of such artifacts. I have a basic understanding of digital systems and base-2, and I also have a cheap mixer which probably just doesn't properly correct for natural glitches such as this.

But most importantly: do you think it is possible to use the relation you described in your reply as an alternative way for the Clipfix Nyquist plugin to restore or approximate the original signal? I'm not sure Nyquist supports direct binary operations on individual samples. I wish one could just buy programming experience instead of having to invest time... :-)

Regards,

Arnoud

Dr. Gary Nelson, 24-12-2008 23:33:51:

>
>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 mailing list
Audacity-nyquist@...
https://lists.sourceforge.net/lists/listinfo/audacity-nyquist