newest rectifier plugs

classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

newest rectifier plugs

David R. Sky
Hi Edgar,

Attached are the latest rectifier plugs with the hp filter added.
rectimo3.ny is the North American version, recti3eu.ny ("Rectifier with
Modulation 3 (European)") is the European version with , instead of . in
float numbers, hope I got it right.

I don't play guitar myself, I was just interested in making a rectifier
plug which could be re-applied, so this came from that.  After 2 or 3
applications to a sinewave, I start to hear drop-outs in the audio here
and there, but I'm satisfied with the plug 'as is', unless you got
something else to add or suggest.

David

rectimo3.ny (3K) Download Attachment
recti3eu.ny (3K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: newest rectifier plugs

edgar-rft
David wrote: I have attached the DC bias removal effect from Audacity 1.3

Edgar: I know that plugin but it causes exactly the same problem but over
a period of 10 seconds. I assume this low value was chosen to make the
ripple inaudible by choosing a very low frequency. There is a better
dc removal function inside Dominic's normalize effect in the effect menu.

The out-commented line is an archive registry stamp from Sourceforge,
it has nothing to do with the function of the filter.

With ripple I mean a decreasing wave form for example like a drum sound.
It starts with a high amplitude but decreases very fast and is already
finished after a few periods. I always read this term in data sheets of
operational amplifiers and analog filters. A direct german to english
translation whould be like "over-swinging". Maybe I only have used the
wrong word. If anybody knows a better word please tell me...

I fully agree with the explanations of Sami, but exactly the same problem
is with the capacitors in an audio amplifier at the moment when the
amplifier is switch on. There will be a big plop sound coming out of the
speakers because first the capacitors have to get charged. Only then the
average effect of the capacitors starts to work. The noise is usually
avoided by a relais that connects the speakers a few seconds after the
amplifier has been switched on. But this plop sound is nothing but the
ripple of the capacitors which work as high pass filters.

The problem with high pass filters in general is that the filter at the
beginning of the sound cannot know about a dc bias because in case of
the Nyquist filter it only knows the value of the first sample.

The high pass filter removes the dc bias by calculating the average, but
the filter cannot look ahead and can only calculate the average of samples
it already has passed.

Imagine a rectified sine wave with only positive samples but the negatives
cut off. At the beginning of the sound the wave starts with zero and then
rises upwards until the Audacity track limit of 1.0, then decreases down to
zero. The filter still cannot know that the nagative values are missing.

During the negative half of the wave the samples remain at zero because of
the rectifier. Only then the average calculation starts to become positive
so there is always a delay until the filter can realize that there is a dc
offset. This delay time is dependent to the frequency of the audio signal.

The reaction time of the filter to this average calculation defines
the cutoff frequency of the filter what means that there is a further
artificial delay that slows down the reation time. The lower the cutoff
frequency the slower the reaction of the filter becomes.

This delay time of the filter is one divided by the cutoff frequency.

In case of a cutoff frequency of 20 Hz this means a delay 50 milliseconds,
in case of the Audacity dc removal plugin with a cutoff frequency of 0.1 Hz
this means a delay of 10 seconds.

In my opinion the offset problem can only be solved by a two pass filter
with first analyzing the offset of the sound by calculating the average of
all samples and then adding an opposite offset to all samples in a second
pass.

Unfortunately you cannot rely on the maximum and minimum peaks, this only
works with symmetrical signals like sine waves but not with complex signals
like music or voice recordings. To get a real working offset compensation
on complex signals you really need to calculate all samples.

Now there are two problems. First, Nyquist is designed to work in one pass
only. This not a bad idea because this way cou can work with a minimum of
memory because all audio data can be left on the hard disc, in principle
only the actual sample is needed. But this leads to the next problem: if
you want to write a two pass filter you have to keep the sound in memory
between the first and the second pass by assigning it for example to a
global variable what quickly can lead to a memory overflow depending to
the length of the audio.

There could be a solution by using the snd-fetch function with that you can
access single sample values. For example like fetch the first sample and
save its value in a variable, then fetch the second sample, add it to the
value in the variable and store the result again in the same variable. By
adding up all samples one after the other in the same variable and dividing
the variable value at the end by the number of samples that is given by the
len variable you could calculate the average off all samples with only one
variable.

But this is only a theory because I never have worked with the snd-fetch
function and neither with the xlisp object system that is needed for this.
Maybe Steven or Sami (or whoever reads this) knows how to do. Or maybe
this is a reason to learn more about the xlisp object system.

The snd-fetch function and how this could work is explained in the Nyquist
manual under "DSP in XLisp".

Anybody a better idea ?

- edgar

P.S. to David: just got your new plugins, still not tested, I will write later
on about the tests.

--
The author of this email does not necessarily endorse the
following advertisements, which are the sole responsibility
of the advertiser:

______________________________________________________________________
XXL-Speicher, PC-Virenschutz, Spartarife & mehr: Nur im WEB.DE Club!
Jetzt gratis testen! http://freemail.web.de/home/landingpad/?mc=021130



-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
Audacity-nyquist mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/audacity-nyquist
Reply | Threaded
Open this post in threaded view
|

Re: newest rectifier plugs

Alex S. Brown, PMP
I cannot speak to your DC/filter issues, but I have used the snd-fetch function
quite a bit working on sound detection. I would warn you that snd-fetch is best
used as a one-pass method to examine and manipulate a sound. If you try to keep
the whole sound in memory and use snd-fetch to move through it, the RAM use for
your script will grow dramatically with the length of the sound. Basically,
Nyquist will read the entire sound into memory and hold onto the whole thing
until the script is done.

Depending on your algorithm, there may be ways around this effect, but generally
snd-fetch does not let you go backwards or do random access within the sound. I
believe Nyquist will accumulate all the samples in RAM if you try to hold onto
the sound variable while using snd-fetch to move through it.

The DSP in XLisp chapter is excellent to start working with those functions, but
the memory utilization of these functions takes some time to understand. The
plug-ins that ship with Audacity actually suffers from some of these problems.
Others on this mailing list helped me a lot to fix up my plug-ins.

I think your proposal of using snd-fetch to add the samples into a single
variable would either destroy the sound variable or accumulate all samples in
memory if you tried to keep a copy of the sound variable. There may be a
built-in function of Nyquist that does a similar calculation, without the
memory problems. Something like snd-avg might help, although sometimes these
functions have the same memory-use problems as snd-fetch.

If anyone has suggestions, please jump in! I hate posting a reply only about the
problems of a suggested approach.

Quoting [hidden email]:
[snip]

> Now there are two problems. First, Nyquist is designed to work in one pass
> only. This not a bad idea because this way cou can work with a minimum of
> memory because all audio data can be left on the hard disc, in principle
> only the actual sample is needed. But this leads to the next problem: if
> you want to write a two pass filter you have to keep the sound in memory
> between the first and the second pass by assigning it for example to a
> global variable what quickly can lead to a memory overflow depending to
> the length of the audio.
>
> There could be a solution by using the snd-fetch function with that you can
> access single sample values. For example like fetch the first sample and
> save its value in a variable, then fetch the second sample, add it to the
> value in the variable and store the result again in the same variable. By
> adding up all samples one after the other in the same variable and dividing
> the variable value at the end by the number of samples that is given by the
> len variable you could calculate the average off all samples with only one
> variable.
>
> But this is only a theory because I never have worked with the snd-fetch
> function and neither with the xlisp object system that is needed for this.
> Maybe Steven or Sami (or whoever reads this) knows how to do. Or maybe
> this is a reason to learn more about the xlisp object system.
>
> The snd-fetch function and how this could work is explained in the Nyquist
> manual under "DSP in XLisp".

----------------------
Alex S. Brown, PMP
[hidden email]
http://www.alexsbrown.com/


-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
Audacity-nyquist mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/audacity-nyquist
Reply | Threaded
Open this post in threaded view
|

Re: newest rectifier plugs

David R. Sky
In reply to this post by edgar-rft
Hi Edgar,

Thanks very much for explaining clearly what Sami wrote, and other
filter-related stuff. I think 'oscillations' would be a term for
'ripples'? Are the oscillations sine waves, what frequency, or does that
depend on the input signal?

I've experimented and found the best auditory result is (in the rectify
function)

(hp (mult 2.0 (sum -0.475
[actual rectify code]
20)))

That produces the least audio drop-out with repeated applications, to my
ears. (Note I changed the 0.1 hp freq back to 20)

David



-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
Audacity-nyquist mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/audacity-nyquist
Reply | Threaded
Open this post in threaded view
|

Re: newest rectifier plugs

David R. Sky
In reply to this post by Alex S. Brown, PMP
Thanks Alex for explaining about snd-fetch and memory issues using
it. I'm working with only 64megs of RAM, I have observed very long
'crunching time' on some plugs I've written, especially when applying them
to a long (minutes) selection, I don't want further delays. *chuckle*

David



-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
Audacity-nyquist mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/audacity-nyquist
Reply | Threaded
Open this post in threaded view
|

Re: newest rectifier plugs

edgar-rft
In reply to this post by David R. Sky

Thanks to Alex S. Brown:

> If you try to keep the whole sound in memory and use snd-fetch to move
> through it, the RAM use for your script will grow dramatically with the
> length of the sound.

The intention was just the opposite: I wanted to use snd-fetch to avoid
keeping the whole sound in memory.

> Depending on your algorithm, there may be ways around this effect, but
> generally snd-fetch does not let you go backwards or do random access
> within the sound.

I only whould need a simple sequencial function that reads one sample
after the other, sum it up in a single varible (or two in case of stereo)
and immediately after reading and adding the sample the snd-fetch memory
could be freed again (or garbage collected).

I know there is a problem that snd-fetch affects the samples so I'm not
sure wether I have to snd-copy the whole sound into memory before I can
work on it with snd-fetch. This of course whould turn the whole
snd-fetch theory quite useless.

Unfortunately I cannot reduce the sample frequency to 100 Hz or similar
so I assume a snd-fetch analyzer routine whold be very slow.

> The DSP in XLisp chapter is excellent to start working with those functions,
> but the memory utilization of these functions takes some time to understand.

I know ... (but this is no valid excuse not to learn it)

> There may be a built-in function of Nyquist that does a similar calculation

Unfortunately there is not, I had the same problem several times ago, at
the moment, as far as I know, only the maximum peak is available. The
snd-avg function for example calculates the geometrical average (RMS) what
is fine for dynamic compressors but unfortunately useless in this case.

> If anyone has suggestions, please jump in! I hate posting a reply only
> about the problems of a suggested approach.

doesn't matter - thank you for your reply

- edgar

message to david: just got the code changes, I will test it immediately,
answer follows in  about half an hour.



the rest is transcription

[hidden email] schrieb am 29.11.05 19:50:13:

>
> I cannot speak to your DC/filter issues, but I have used the snd-fetch function
> quite a bit working on sound detection. I would warn you that snd-fetch is best
> used as a one-pass method to examine and manipulate a sound. If you try to keep
> the whole sound in memory and use snd-fetch to move through it, the RAM use for
> your script will grow dramatically with the length of the sound. Basically,
> Nyquist will read the entire sound into memory and hold onto the whole thing
> until the script is done.
>
> Depending on your algorithm, there may be ways around this effect, but generally
> snd-fetch does not let you go backwards or do random access within the sound. I
> believe Nyquist will accumulate all the samples in RAM if you try to hold onto
> the sound variable while using snd-fetch to move through it.
>
> The DSP in XLisp chapter is excellent to start working with those functions, but
> the memory utilization of these functions takes some time to understand. The
> plug-ins that ship with Audacity actually suffers from some of these problems.
> Others on this mailing list helped me a lot to fix up my plug-ins.
>
> I think your proposal of using snd-fetch to add the samples into a single
> variable would either destroy the sound variable or accumulate all samples in
> memory if you tried to keep a copy of the sound variable. There may be a
> built-in function of Nyquist that does a similar calculation, without the
> memory problems. Something like snd-avg might help, although sometimes these
> functions have the same memory-use problems as snd-fetch.
>
> If anyone has suggestions, please jump in! I hate posting a reply only about the
> problems of a suggested approach.
>
> Quoting [hidden email]:
> [snip]
> > Now there are two problems. First, Nyquist is designed to work in one pass
> > only. This not a bad idea because this way cou can work with a minimum of
> > memory because all audio data can be left on the hard disc, in principle
> > only the actual sample is needed. But this leads to the next problem: if
> > you want to write a two pass filter you have to keep the sound in memory
> > between the first and the second pass by assigning it for example to a
> > global variable what quickly can lead to a memory overflow depending to
> > the length of the audio.
> >
> > There could be a solution by using the snd-fetch function with that you can
> > access single sample values. For example like fetch the first sample and
> > save its value in a variable, then fetch the second sample, add it to the
> > value in the variable and store the result again in the same variable. By
> > adding up all samples one after the other in the same variable and dividing
> > the variable value at the end by the number of samples that is given by the
> > len variable you could calculate the average off all samples with only one
> > variable.
> >
> > But this is only a theory because I never have worked with the snd-fetch
> > function and neither with the xlisp object system that is needed for this.
> > Maybe Steven or Sami (or whoever reads this) knows how to do. Or maybe
> > this is a reason to learn more about the xlisp object system.
> >
> > The snd-fetch function and how this could work is explained in the Nyquist
> > manual under "DSP in XLisp".
>
> ----------------------
> Alex S. Brown, PMP
> [hidden email]
> http://www.alexsbrown.com/
>
>
> -------------------------------------------------------
> This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
> for problems?  Stop!  Download the new AJAX search engine that makes
> searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
> http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
> _______________________________________________
> Audacity-nyquist mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/audacity-nyquist

--
The author of this email does not necessarily endorse the
following advertisements, which are the sole responsibility
of the advertiser:

______________________________________________________________
Verschicken Sie romantische, coole und witzige Bilder per SMS!
Jetzt bei WEB.DE FreeMail: http://f.web.de/?mc=021193



-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
Audacity-nyquist mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/audacity-nyquist
Reply | Threaded
Open this post in threaded view
|

Re: newest rectifier plugs

edgar-rft
In reply to this post by David R. Sky
Hi David,

David wrote: Are the oscillations sine waves, what frequency, or does
that depend on the input signal?

Edgar: The the oscillations are always sine waves and the frequency of the
oscillations is always equal to the cutoff frequency of the filter where
high pass or low pass doesn't matter.

The higher the degree of the filter the worse the oscillations.
For example highpass8 causes more oscillations than highpass2.

In electronics an oscillator is nothing but a filter with a feedback of
1.0 or more so the filter never stops to oscillate. In principle both
are the same.

Unfortunately in this case the oscillations are at a frequency of 20 Hz or
below so I think they are impossible or at least extremely difficult to
hear with headphones or loudspeakers.

I just have tested your code modifications and it seems that you are right
and this works best until now. It seems means I cannot say it surely because
as usual the amount of oscillations at the beginning are dependent to the
waveform of the sound or better to the offset caused by the rectification.
The worse the offset, the worse the oscillations.

To give you an imagination: the oscillations are about double a s high as
the maximum peak of the sound after the oscillations.

I will read more about that snd-fetch function later on, I also have some
manuals about the xlisp object system, maybe this helps but I cannot
promise.

Unfortunately this is very difficult to fix without visual feedback.

On the other hand: a rectifier is an effect that you usually use on a
complete sound. What is a complete sound ? I mean you do not use it on
a single word in the middle of a sentence in a speech recording. You
usually first generate a synthesizer sound and apply the effect on it
so in case of doubt you can fade away the oscillations afterwards.

I know this is no perfect solution but what is perfect in life ?

- edgar





______________________________________________________________
Verschicken Sie romantische, coole und witzige Bilder per SMS!
Jetzt bei WEB.DE FreeMail: http://f.web.de/?mc=021193



-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
Audacity-nyquist mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/audacity-nyquist
Reply | Threaded
Open this post in threaded view
|

Re: newest rectifier plugs

David R. Sky
Hi Edgar,

Do _all_ filters oscillate when they first encounter a sound?  What would
happen if we applied a notch filter at 20Hz to the hp result? what about
adding  an inverted 50ms burst of 20Hz to the result? I know this is
speculation, at the same time I'm curious.

I'm not at all discouraged about what we've been talking about, it's all
new to me, I'm enjoying learning. :)

David





-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
Audacity-nyquist mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/audacity-nyquist
Reply | Threaded
Open this post in threaded view
|

Re: newest rectifier plugs

edgar-rft
In reply to this post by David R. Sky
Hi David,

David wrote: Do _all_ filters oscillate when they first encounter a sound?

Edgar: The exact answer is: not all filters oscillate, only filters which
are based on feedback loops tend to oscillate. But most filters are
constructed out of feedback loops and generally all filters have side
effects in time wether they work with feedback or not doesn't matter.

For example all first order filters like the Nyquist hp and lp functions
do not oscillate. Even tough they cause a delayed response dependent on
their cutoff frequency.

The counter conclusion is also true: you cannot build an oscillator out of
a single first order filter.

Remember what Sami wrote about the bias jump in the first sample when the
filter is applied. From the view of the filter there is a sudden step from
zero bias to a bias of for example 0.5 within a distance of only one sample.

If you want to have a filter that is fast enough to calculate the average
of two neighbour samples in a 44100 Hz signal you whould need a low pass
filter with a cutoff frequency of 22050 Hz.

Because 22050 Hz is the theoretically highest possible frequency to be
produced with a sample frequency af 44100 Hz anyway (in practice it is
even lower) this filter whouldn't make much sense to your ears.

If you whould like to have a high pass filter that is fast enough to remove
the step between two neighbour samples you whould need a filter that is
faster than the sample frequency, in this case the filter whould need to
have a cutoff frequency of at least 44100 Hz or even higher.

But you have already noticed that this whould make no sense at all because
the filter also whould cut off the entire audio signal and the result
whould be the most complicated silence generator ever.

Now some counter considerations: I think we all agree that a high pass
filter af 20 Hz whold be the highest acceptable cutoff frequency if you
want to ensure that the plugin can handle all audible frequencies.

My pocket calculator says that a 20 Hz highpass filter at a sample frequency
of 44100 Hz needs 2205 or in letters more than two thousand samples to
produce a reliable average result. To make it short: this equals to the
50 milliseconds of ripple or oscillations I am always talking about.

David: What would happen if we applied a notch filter at 20Hz to the result?

Edgar: A notch filter of 20 Hz of course has the same reaction time like a
20 Hz high pass filter so it is too slow to compensate the high pass error.
Even tough I have tried, but unfortunately I have to say that the theory is
true and it doesn't work.

David: what about adding an inverted 50ms burst of 20Hz to the result?

Edgar: I also had the idea to produce a counter error signal but the problem
is that the waveform of the oscillations depends on the value of the offset
caused by the rectifier so to produce such a signal we first whould have to
calculate the offset, then produce a counter error signal to add it to the
plugin output signal.

Therefore we whould also need a two pass plugin and the calculations whould
be even more complicated than simply substract the offset from the rectifier
signal so I have skipped this idea.

In my opinion it makes no sense to fix the error of the high pass filter.
If we want to remove this error we have to compensate the offset of the
rectifier. I still have on other idea than a two pass plugin.

Do not be worried: First off all, the sound of the plugin is good in the
way it already is.

Second: I wanted to try writing a two pass plugin anyway because this way
it whould be possible to build for example an automatic dynamic compressor
as far as this is possible at all. Dynamic compression is a science of its
own.

After several hours of trying and modifying your plugin I have finally
changed it back to the code as you had sent me. Leave it as is.

I will do some snd-fetch experiments during the next few days.

I hope I will learn something ...

- edgar

just got the generator.ny -  reply will follow ...


______________________________________________________________
Verschicken Sie romantische, coole und witzige Bilder per SMS!
Jetzt bei WEB.DE FreeMail: http://f.web.de/?mc=021193



-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
Audacity-nyquist mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/audacity-nyquist
Reply | Threaded
Open this post in threaded view
|

Re: newest rectifier plugs

David R. Sky
Hi Edgar,

I don't know if you consciously intend this... you write in a very
entertaining and at the same time informative manner which I enjoy
reading.

Thanks very much!

David

On Wed, 30 Nov 2005, [hidden email] wrote:

> If you whould like to have a high pass filter that is fast enough to remove
> the step between two neighbour samples you whould need a filter that is
> faster than the sample frequency, in this case the filter whould need to
> have a cutoff frequency of at least 44100 Hz or even higher.
>
> But you have already noticed that this whould make no sense at all because
> the filter also whould cut off the entire audio signal and the result
> whould be the most complicated silence generator ever.



-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
Audacity-nyquist mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/audacity-nyquist