Notch Filter (wiki)
Forum rules
This Forum is an archive of old topics concerning Nyquist plug-ins.
Feedback and questions relating to topics may be posted, but please
DO NOT POST NEW TOPICS HERE.
New plug-ins may be posted on the New Plug-Ins board.
Other posts relating to Nyquist should be posted to the main Nyquist board.
The main repository for Audacity/Nyquist Plug-ins is on the Audacity Wiki.
This Forum is an archive of old topics concerning Nyquist plug-ins.
Feedback and questions relating to topics may be posted, but please
DO NOT POST NEW TOPICS HERE.
New plug-ins may be posted on the New Plug-Ins board.
Other posts relating to Nyquist should be posted to the main Nyquist board.
The main repository for Audacity/Nyquist Plug-ins is on the Audacity Wiki.
Re: Notch Filter
Sorry if that last post appeared rather brusk, it was posted in a rush.
Having given it some consideration;
I think that for accuracy the name of the Q control should be "Q" or "Q factor" rather than "Width" but by including "(higher value reduces width)" the meaning is made clear for all.
I have reservations about the error message "Frequency must be at least 0 Hz." because although it is accurate in as far as 0Hz does not produce an error, I feel that it implies that 0Hz is a reasonable value, when in practice it does nothing. Currently the user has to wait for the sound to be written back (unaltered) to the track, which could be a significant wait for a long track. I think it would be better if the user was informed straight away that the effect is doing nothing.
So the situation is:
1) Negative frequencies are invalid and so should generate an error
2) 0 Hz should not produce an error, but it should be clear that it does nothing.
What I propose is:
1) For a negative frequency value the error message should be "ErrornNegative frequency is invalid." (or something similar)
2) 0 Hz should generate a "non-error" message of "Nothing to be done." (or something similar).
Thanks for the feedback Gale, I'm in full agreement with the other changes that you've made.
(I've also added the expanded GPL license information in the comment as discussed previously)
Having given it some consideration;
I think that for accuracy the name of the Q control should be "Q" or "Q factor" rather than "Width" but by including "(higher value reduces width)" the meaning is made clear for all.
I have reservations about the error message "Frequency must be at least 0 Hz." because although it is accurate in as far as 0Hz does not produce an error, I feel that it implies that 0Hz is a reasonable value, when in practice it does nothing. Currently the user has to wait for the sound to be written back (unaltered) to the track, which could be a significant wait for a long track. I think it would be better if the user was informed straight away that the effect is doing nothing.
So the situation is:
1) Negative frequencies are invalid and so should generate an error
2) 0 Hz should not produce an error, but it should be clear that it does nothing.
What I propose is:
1) For a negative frequency value the error message should be "ErrornNegative frequency is invalid." (or something similar)
2) 0 Hz should generate a "non-error" message of "Nothing to be done." (or something similar).
Thanks for the feedback Gale, I'm in full agreement with the other changes that you've made.
(I've also added the expanded GPL license information in the comment as discussed previously)
- Attachments
-
- notch-Sep-28-2010.ny
- (818 Bytes) Downloaded 278 times
Learn more about Nyquist programming at audionyq.com
-
Gale Andrews
- Quality Assurance
- Posts: 41761
- Joined: Fri Jul 27, 2007 12:02 am
- Operating System: Windows 10 / 11
Re: Notch Filter
It didn't, but thanksstevethefiddle wrote:Sorry if that last post appeared rather brusk
That's fine, I looked up the Nyquist Manual afterwards and came (more or less) to your conclusion. I think one of the problems is that "Q" on its own looks more confusing than "Notch Q" which is what we called it before.stevethefiddle wrote:"width" is sometimes used for band pass/stop filters where it refers to the number of octaves and a higher number is a wider frequency band...I think that for accuracy the name of the Q control should be "Q" or "Q factor" rather than "Width" but by including "(higher value reduces width)" the meaning is made clear for all.
I did find in the index of the Manual an entry for "Q":
q = Quarter = 1.0
so I really think "Q factor" is better and it doesn't look unreasonably wide. It also matches with the reference on the Wiki Noise Removal page to Q factor if you run notch filter at a Nyquist prompt. So can we agree to "Q factor" for the name of the control, and then the unit at the end of the slider is "Q" (there should really be a unit I think)?
Everything else is fine now with me, so I assume if no-one objects in the near future on -quality to including it in Audacity, I'll commit it.
I'm figuring that because notch filter is mentioned in the popular Wiki Noise Removal page, we should retain it on the Wiki Download Nyquist Plug-ins page at least until 2.0, and possibly even after then for people on legacy OS'es? Generally once a Nyquist plug-in is included in the major and Beta releases the practice has been not to include it on the Nyquist Plug-ins pages any longer.
Gale
________________________________________FOR INSTANT HELP: (Click on Link below)
* * * * * Tips * * * * * Tutorials * * * * * Quick Start Guide * * * * * Audacity Manual
* * * * * Tips * * * * * Tutorials * * * * * Quick Start Guide * * * * * Audacity Manual
-
billw58
- Posts: 5832
- Joined: Wed Aug 12, 2009 2:10 am
- Operating System: macOS 10.15 Catalina or later
Re: Notch Filter
"Q factor" is fine as the name of the control. Technically speaking, "Q" is a dimensionless parameter. Therefore it shouldn't have a unit. The q factor of a filter is not "10 Q" it's just "10".Gale Andrews wrote: So can we agree to "Q factor" for the name of the control, and then the unit at the end of the slider is "Q" (there should really be a unit I think)?
Gale
-- Bill
Re: Notch Filter
You took the words out of my mouth 
Learn more about Nyquist programming at audionyq.com
-
Gale Andrews
- Quality Assurance
- Posts: 41761
- Joined: Fri Jul 27, 2007 12:02 am
- Operating System: Windows 10 / 11
Re: Notch Filter
I assume this is the reason this plug-in fails in 1.2.6 on stereo audio (tested on Windows 7 by generating a 440 Hz stereo sine tone and cutting a 100 Hz notch at q = 0.1). That's a shame as I thought it would be nice to update David's version on Download Nyquist Plug-ins with yours.steve wrote:For recent/current versions of Audacity the "(if (arrayp s)(vector.." business is not required as the (notch2 ..) function now supports stereo tracks.
Do you want to produce a "legacy" compatible version with the new UI just for that page, or include the code that enables stereo processing in 1.2.6 in your version?
Gale
________________________________________FOR INSTANT HELP: (Click on Link below)
* * * * * Tips * * * * * Tutorials * * * * * Quick Start Guide * * * * * Audacity Manual
* * * * * Tips * * * * * Tutorials * * * * * Quick Start Guide * * * * * Audacity Manual
Re: Notch Filter
Here's a "legacy" compatible version.
The only change to the code is that
has been changed to
I've also added a comment:
I'm assuming that this will be the final version, so I've changed the file name to "notch.ny"
The only change to the code is that
Code: Select all
(notch2 s freq q)Code: Select all
(multichan-expand #'notch2 s freq q)Code: Select all
;; (multichan-expand) provides legacy support for old versions of Audacity
;; in which the (notch2) function only supports mono tracks.- Attachments
-
- notch.ny
- (975 Bytes) Downloaded 326 times
Learn more about Nyquist programming at audionyq.com
-
Gale Andrews
- Quality Assurance
- Posts: 41761
- Joined: Fri Jul 27, 2007 12:02 am
- Operating System: Windows 10 / 11
Re: Notch Filter
OK, thanks. So as I understand it "Download Nyquist Plug-ins" will have the version you last attached in the post above, and that same version will also be included in 1.3.13 Beta.steve wrote:Here's a "legacy" compatible version... I'm assuming that this will be the final version, so I've changed the file name to "notch.ny"
The plug-ins listed on "Download Nyquist Plug-Ins" are are usually stored on audacity.sourceforge.net (so committed to the web site SVN) and usually include a text file in a zip with the .ny file. As I can't use the old text file that David wrote, here's my attempt at the replacement text:
Code: Select all
Notch filter sharply reduces the volume of audio centered on a
specified frequency. When you look at the resultant audio in
Audacity's Analyze > Plot Spectrum, you will see a "notch"
cut out of the audio in an area surrounding the specified
frequency.
Frequency: Use the slider to choose any frequency up to 10000 Hz
(default is 60 Hz). Frequencies above 10000 Hz can be entered
by typing in the text box. You cannot enter a frequency greater
than half the sample rate of the track, because a track can
only contain frequencies up to half its sample rate.
Q Factor: This determines the width of the notch cut from your
audio (default value is 1). Use the slider to choose a Q Factor
between 0.1 and 20. Values above 1 create a narrower notch,
and values below 1 create a wider notch. Values outside the
slider range can be entered by typing in the text box (the
Q Factor must be at least 0.01).
Tips for hum removal: For mains hum removal, choose 60 Hz as
"Frequency" for North America, or 50 Hz for the United Kingdom
and elsewhere. Note that significant hum on a recording will
usually contain noisy harmonic frequencies above the fundamental
frequency of the hum. A good approach is often to apply Notch
Filter to the fundamental hum frequency (for example 50 Hz or
60 Hz), then use Effect > Noise Removal to remove residual
harmonics.
Gale
________________________________________FOR INSTANT HELP: (Click on Link below)
* * * * * Tips * * * * * Tutorials * * * * * Quick Start Guide * * * * * Audacity Manual
* * * * * Tips * * * * * Tutorials * * * * * Quick Start Guide * * * * * Audacity Manual
Re: Notch Filter
The description looks accurate to me.
The only part that I would query is regarding hum removal. In many cases better results can be achieved by notching out a few of the strongest harmonics before using Noise Removal. For example, if "Plot Spectrum" shows strong peaks at 60, 180 and 300 Hz, then all three of these may be removed (one at a time) with the notch filter. For the higher harmonics it is generally better to increase the Q factor so as to lessen the damage to the audio, but the Q factor should not be raised too high as that can cause ringing (Gibbs phenomena) to occur on transients. Generally a Q of between 2 and 10 works well for "mains hum" removal with higher value being more selective, but increasing the risk of ringing. In the manual, don't think that it's worth mentioning the Gibbs phenomenon as it's rarely noticeable unless a lot of extreme filtering is applied, but it may be worth a brief mention in the wiki?
The only part that I would query is regarding hum removal. In many cases better results can be achieved by notching out a few of the strongest harmonics before using Noise Removal. For example, if "Plot Spectrum" shows strong peaks at 60, 180 and 300 Hz, then all three of these may be removed (one at a time) with the notch filter. For the higher harmonics it is generally better to increase the Q factor so as to lessen the damage to the audio, but the Q factor should not be raised too high as that can cause ringing (Gibbs phenomena) to occur on transients. Generally a Q of between 2 and 10 works well for "mains hum" removal with higher value being more selective, but increasing the risk of ringing. In the manual, don't think that it's worth mentioning the Gibbs phenomenon as it's rarely noticeable unless a lot of extreme filtering is applied, but it may be worth a brief mention in the wiki?
Learn more about Nyquist programming at audionyq.com
-
kozikowski
- Posts: 71535
- Joined: Thu Aug 02, 2007 5:57 pm
- Operating System: macOS 10.13 High Sierra
Re: Notch Filter
My slider would not have gone below 20Hz, but that's just me. And a job I had recently had digital trash centered around 13 KHz, which I can enter manually.
Is there a slider for dB reduction? You get the frequency and Q factor (I learned it as "Quality," the ratio of width to height) exactly right, but you want to leave some of the material behind without affecting the shape of the curve.
Also, in a bid for ease of use, how would I transfer the shape of a spike of garbage in Analyze > Plot Spectrum to the notch tool so it exactly matches?
Can I save a notch and mail it to me mum?
Koz
Is there a slider for dB reduction? You get the frequency and Q factor (I learned it as "Quality," the ratio of width to height) exactly right, but you want to leave some of the material behind without affecting the shape of the curve.
Also, in a bid for ease of use, how would I transfer the shape of a spike of garbage in Analyze > Plot Spectrum to the notch tool so it exactly matches?
Can I save a notch and mail it to me mum?
Koz
Re: Notch Filter
It makes not much sense to match exactly to the "Plot Spectrum" curve, because the "Plot Spectrum" curve contains interpolation errors from the different "windowing" functions, which you can choose in the lower left corner of the "Plot Spectrum" window. Because there is no windowing function known without errors, you will have to appoximate your notch filter settings from the curves by trial-and-error.kozikowski wrote:How would I transfer the shape of a spike of garbage in Analyze > Plot Spectrum to the notch tool so it exactly matches?
Here is how to get the values you need for that:
- q = center_frequency / bandwidth
- bandwidth = upper_cutoff_frequency - lower_cutoff_frequency
To get the center_frequency, move the mouse pointer into the spike in the "Plot Spectrum" curve, and below the curve you see:
Cursor: <number> Hz (<pitch>) = <number> dB --- Peak: <number> Hz (<pitch>) = <number> dB
The number from "Peak: <number> Hz" is the center_frequency of the spike (and the notch filter).
Now move the mouse pointer horizontally and try to match the "Cursor: <number> Hz" and "Peak: <number> Hz" as close as possible. Then write down the "dB" value form the "Cursor:" side. Do not use the dB value from the "Peak:" side, because the "Cursor:" and "Peak:" sides are computed with different algorithms, and usually have different values at the same frequency (because different algorithms produce different errors).
The dB value from "Cursor: ... = <number> dB" at the center_frequency is what I now call "maximum_peak_dB" value.
Now move the cursor from the peak of the spike downhill to the left until the "Cursor:" dB value has been fallen by -3dB to:
- maximum_peak_dB - 3dB
Then move the cursor from the peak of the spike downhill to the right until the "Cursor:" dB value has been fallen again by -3dB and write down the frequency number from "Cursor: <number> Hz", this is the "upper_cutoff_frequency".
Now you can compute the q-factor:
- q = center_frequency / (upper_cutoff_frequency - lower_cutoff_frequency)
Keep in mind that the only sounds with a flat frequency response are "white noise" and "silence", and both sound boring.
- edgar
Last edited by edgar-rft on Thu Jan 13, 2011 11:37 am, edited 1 time in total.