<p>After a bit of searching, I found <a href="http://www.sonicscoop.com/2013/05/30/the-best-noise-reduction-plugins-on-the-market/" rel="nofollow noreferrer">an article</a> surveying some of the commercial software noise reduction options.  For hiss/hum type noise removal (as opposed to crackles and pops), no approach other than noise-gates in multiple frequency bands was mentioned.  The differences between implementations are in the default settings, the control knobs available, and things like that.  (and whether the a noise sample is used to get a profile.  Apparently there are faster implementations that do well without needing a noise sample to build a tailored profile of the noise to remove.)</p>

<p>So AFAICT, Audacity's noise reduction plugin works the same way as commercial software implementations.</p>

<p>(For pops and crackles, Audacity allows making rectangular selections on the spectrum plot.  It might not have as sophisticated algorithms for filling in deleted glitches with similar-sounding audio from nearby, compared to some commercial software.  IDK, I haven't tried that.)</p>

<p>The other thing I was interested in was what's up with recent development activity in Audacity's Noise Reduction filter:</p>

<p>Following the svn history of <code>NoiseReduction.cpp</code>, there are really only changes to the GUI for setting parameters, from it's appearance in SVN r13591 (Nov 10, 2014) up to latest change in r13895 (Jan 24, 2015).</p>

<p>It replaces the over-optimistically-titled <code>NoiseRemoval.cpp</code>.  It appears to be a rewrite of the same basic design.  The intro comment describing the design is only slightly changed, and some of the same comments are kicking around in the code.  However, almost every line of code is different, and it's 1.9k lines of code instead of 870.</p>

<p>So it's probably not critical to get a pre-release build of Audacity 2.1 for noise removal.  If you get chimes / dropouts where you don't want them, or otherwise have problems, then go for a new version.  It looks at more data to decide if something is noise or not, as detailed below.</p>

<p>One critical part of the new filter now has several methods to choose from.  (<code>OLD_METHOD_AVAILABLE</code> is not enabled by default.  And <code>DM_DEFAULT_METHOD = DM_SECOND_GREATEST</code>)</p>

<p>(The code is well-commented.  I mostly just read the comments, on the assumption that the code matches well enough.)</p>

<pre class="lang-cpp prettyprint-override"><code>//***** NoiseReduction.cpp:1079
// Return true iff the given band of the "center" window looks like noise.
// Examine the band in a few neighboring windows to decide.
inline
bool EffectNoiseReduction::Worker::Classify(const Statistics &amp;statistics, int band)
{
   switch (mMethod) {
#ifdef OLD_METHOD_AVAILABLE
   case DM_OLD_METHOD:
      {
         float min = mQueue[0]-&gt;mSpectrums[band];
         for (int ii = 1; ii &lt; mNWindowsToExamine; ++ii)
            min = std::min(min, mQueue[ii]-&gt;mSpectrums[band]);
         return min &lt;= mOldSensitivityFactor * statistics.mNoiseThreshold[band];
      }
   // New methods suppose an exponential distribution of power values
   // in the noise; new sensitivity is meant to be log of probability
   // that noise strays above the threshold.  Call that probability
   // 1 - F.  The quantile function of an exponential distribution is
   // log (1 - F) * mean.  Thus simply multiply mean by sensitivity
   // to get the threshold.
   case DM_MEDIAN:
      // This method examines the window and all windows
      // that partly overlap it, and takes a median, to
      // avoid being fooled by up and down excursions into
      // either the mistake of classifying noise as not noise
      // (leaving a musical noise chime), or the opposite
      // (distorting the signal with a drop out). 
      if (mNWindowsToExamine == 3)
         // No different from second greatest.
         goto secondGreatest;
      else if (mNWindowsToExamine == 5)
      {
         float greatest = 0.0, second = 0.0, third = 0.0;
         for (int ii = 0; ii &lt; mNWindowsToExamine; ++ii) {
            const float power = mQueue[ii]-&gt;mSpectrums[band];
            if (power &gt;= greatest)
               third = second, second = greatest, greatest = power;
            else if (power &gt;= second)
               third = second, second = power;
            else if (power &gt;= third)
               third = power;
         }
         return third &lt;= mNewSensitivity * statistics.mMeans[band];
      }
      else {
         wxASSERT(false);
         return true;
      }
   secondGreatest:
   case DM_SECOND_GREATEST:
      {
         // This method just throws out the high outlier.  It
         // should be less prone to distortions and more prone to
         // chimes.
         float greatest = 0.0, second = 0.0;
         for (int ii = 0; ii &lt; mNWindowsToExamine; ++ii) {
            const float power = mQueue[ii]-&gt;mSpectrums[band];
            if (power &gt;= greatest)
               second = greatest, greatest = power;
            else if (power &gt;= second)
               second = power;
         }
         return second &lt;= mNewSensitivity * statistics.mMeans[band];
      }
   default:
      wxASSERT(false);
      return true;
   }
}
</code></pre>

<p>(why isn't <a href="https://meta.stackexchange.com/questions/184108/what-is-syntax-highlighting-and-how-does-it-work">syntax highlighting</a> working?  I put <code>&lt;!-- language: lang-cpp --&gt;</code> before the code block :/)</p>

<p>I'm probably going to build audacity from this SVN checkout I already have, but I'm not planning to compare noise reduction between the latest dev build and the stable 2.0.6 release.</p>

CC BY-SA 3.0
2015-02-28T04:44:48.457Z
2015-02-28T04:44:48.457Z
2017-03-20T10:32:30.783Z
Peter Cordes
<p>I am the author of the code you are reading.  It appears you were an alpha user of Audacity 2.1.0 in advance of its release, which was only days ago.  You have a version of the noise reduction effect with many experimental optional controls exposed to the user that are not in the release version.</p>

<p>You may be interested in what I wrote here about the inadequacies of the previous version of the effect that I tried to remedy with this rewrite.  But the overall procedure remains unchanged.</p>

<p><a href="http://wiki.audacityteam.org/wiki/Proposal_Noise_Removal#Critique_of_current_Audacity_Noise_Removal_by_Paul_Licameli" rel="nofollow">http://wiki.audacityteam.org/wiki/Proposal_Noise_Removal#Critique_of_current_Audacity_Noise_Removal_by_Paul_Licameli</a></p>

CC BY-SA 3.0
2015-04-17T01:50:29.697Z
Thanks for that link, some of the discussion sheds some light on significantly different ways of doing noise reduction (i.e. not just different ways for choosing which FFT bins to pass/reject), as well as good info on how audacity's filter chooses which frequency bins to gate.  And the effect of choosing a good windowing function.  Lots of neat stuff. :)
Peter Cordes
CC BY-SA 3.0
2015-04-05T13:57:07.510Z
2015-04-05T13:57:07.510Z
Paul Licameli
<p>Audacity's noise reduction filter is pretty good.  Before I use it, though, I want to know if I'm missing out on any fundamentally different approaches that may work better.</p>

<p>I have some recordings of my brother singing and playing piano.  It's pretty good as-is, but there's noticeable white noise.  There's also a 60Hz signal that's audible (but not really objectionable) during quieter portions of the recording.  Audacity does a pretty good job of getting rid of them.  So I'll almost certainly just use that, esp. since very recent audacity changes apparently have improved the noise-reduction filter.  (or maybe just the config UI?  I didn't look at the diffs).</p>

<p>The comments at the <a href="https://code.google.com/p/audacity/source/browse/audacity-src/trunk/src/effects/NoiseReduction.cpp" rel="nofollow">start of the file</a> describes the design pretty well, and what the settings sliders mean (esp. the frequency smoothing was a mystery until I thought to check the source, and found it had a great comment describing the design.)</p>

<p>It gets a profile of the kind of noise you want to remove from a clip of only noise.  For the main pass, it FFTs the input, and silences every frequency bin that is below a threshold.  So it's a bandpass filter that adapts to only let through frequencies with signals above the noise level for that bin.  (Thresholds established from the noise profile.)</p>

<p>So my question is, are there other designs for noise filters that work any better?  Mostly out of curiosity, since audacity works very well for my application.  (noise energy distributed over a wide frequency range, signal I want to keep made up of fairly narrow frequencies.)</p>

<audio><noise-reduction>
Audio noise reduction: how does audacity compare to other options?
Peter Cordes
# Audio noise reduction: how does audacity compare to other options?

(Asked by: username_0 on 2015-02-21)

Audacity's noise reduction filter is pretty good. Before I use it, though, I want to know if I'm missing out on any fundamentally different approaches that may work better.

I have some recordings of my brother singing and playing piano. It's pretty good as-is, but there's noticeable white noise. There's also a 60Hz signal that's audible (but not really objectionable) during quieter portions of the recording. Audacity does a pretty good job of getting rid of them. So I'll almost certainly just use that, esp. since very recent audacity changes apparently have improved the noise-reduction filter. (or maybe just the config UI? I didn't look at the diffs).

The comments at the [start of the file](https://code.google.com/p/audacity/source/browse/audacity-src/trunk/src/effects/NoiseReduction.cpp) describes the design pretty well, and what the settings sliders mean (esp. the frequency smoothing was a mystery until I thought to check the source, and found it had a great comment describing the design.)

It gets a profile of the kind of noise you want to remove from a clip of only noise. For the main pass, it FFTs the input, and silences every frequency bin that is below a threshold. So it's a bandpass filter that adapts to only let through frequencies with signals above the noise level for that bin. (Thresholds established from the noise profile.)

So my question is, are there other designs for noise filters that work any better? Mostly out of curiosity, since audacity works very well for my application. (noise energy distributed over a wide frequency range, signal I want to keep made up of fairly narrow frequencies.)

**Tags:** audio, noise-reduction


---

## 2 answers

### Answer by username_1 on 2015-04-05. Score: 3 | Accepted answer

I am the author of the code you are reading. It appears you were an alpha user of Audacity 2.1.0 in advance of its release, which was only days ago. You have a version of the noise reduction effect with many experimental optional controls exposed to the user that are not in the release version.

You may be interested in what I wrote here about the inadequacies of the previous version of the effect that I tried to remedy with this rewrite. But the overall procedure remains unchanged.

<http://wiki.audacityteam.org/wiki/Proposal_Noise_Removal#Critique_of_current_Audacity_Noise_Removal_by_Paul_Licameli>

> **Comments:**
> **username_0**: Thanks for that link, some of the discussion sheds some light on significantly different ways of doing noise reduction (i.e. not just different ways for choosing which FFT bins to pass/reject), as well as good info on how audacity's filter chooses which frequency bins to gate.  And the effect of choosing a good windowing function.  Lots of neat stuff. :)  

---

### Answer by username_0 on 2015-02-28. Score: 3

After a bit of searching, I found an article surveying some of the commercial software noise reduction options.  For hiss/hum type noise removal (as opposed to crackles and pops), no approach other than noise-gates in multiple frequency bands was mentioned.  The differences between implementations are in the default settings, the control knobs available, and things like that.  (and whether the a noise sample is used to get a profile.  Apparently there are faster implementations that do well without needing a noise sample to build a tailored profile of the noise to remove.)
So AFAICT, Audacity's noise reduction plugin works the same way as commercial software implementations.
(For pops and crackles, Audacity allows making rectangular selections on the spectrum plot.  It might not have as sophisticated algorithms for filling in deleted glitches with similar-sounding audio from nearby, compared to some commercial software.  IDK, I haven't tried that.)
The other thing I was interested in was what's up with recent development activity in Audacity's Noise Reduction filter:
Following the svn history of NoiseReduction.cpp, there are really only changes to the GUI for setting parameters, from it's appearance in SVN r13591 (Nov 10, 2014) up to latest change in r13895 (Jan 24, 2015).
It replaces the over-optimistically-titled NoiseRemoval.cpp.  It appears to be a rewrite of the same basic design.  The intro comment describing the design is only slightly changed, and some of the same comments are kicking around in the code.  However, almost every line of code is different, and it's 1.9k lines of code instead of 870.
So it's probably not critical to get a pre-release build of Audacity 2.1 for noise removal.  If you get chimes / dropouts where you don't want them, or otherwise have problems, then go for a new version.  It looks at more data to decide if something is noise or not, as detailed below.
One critical part of the new filter now has several methods to choose from.  (OLD_METHOD_AVAILABLE is not enabled by default.  And DM_DEFAULT_METHOD = DM_SECOND_GREATEST)
(The code is well-commented.  I mostly just read the comments, on the assumption that the code matches well enough.)
//***** NoiseReduction.cpp:1079
// Return true iff the given band of the "center" window looks like noise.
// Examine the band in a few neighboring windows to decide.
inline
bool EffectNoiseReduction::Worker::Classify(const Statistics &statistics, int band)
{
   switch (mMethod) {
#ifdef OLD_METHOD_AVAILABLE
   case DM_OLD_METHOD:
      {
         float min = mQueue[0]->mSpectrums[band];
         for (int ii = 1; ii < mNWindowsToExamine; ++ii)
            min = std::min(min, mQueue[ii]->mSpectrums[band]);
         return min <= mOldSensitivityFactor * statistics.mNoiseThreshold[band];
      }
   // New methods suppose an exponential distribution of power values
   // in the noise; new sensitivity is meant to be log of probability
   // that noise strays above the threshold.  Call that probability
   // 1 - F.  The quantile function of an exponential distribution is
   // log (1 - F) * mean.  Thus simply multiply mean by sensitivity
   // to get the threshold.
   case DM_MEDIAN:
      // This method examines the window and all windows
      // that partly overlap it, and takes a median, to
      // avoid being fooled by up and down excursions into
      // either the mistake of classifying noise as not noise
      // (leaving a musical noise chime), or the opposite
      // (distorting the signal with a drop out). 
      if (mNWindowsToExamine == 3)
         // No different from second greatest.
         goto secondGreatest;
      else if (mNWindowsToExamine == 5)
      {
         float greatest = 0.0, second = 0.0, third = 0.0;
         for (int ii = 0; ii < mNWindowsToExamine; ++ii) {
            const float power = mQueue[ii]->mSpectrums[band];
            if (power >= greatest)
               third = second, second = greatest, greatest = power;
            else if (power >= second)
               third = second, second = power;
            else if (power >= third)
               third = power;
         }
         return third <= mNewSensitivity * statistics.mMeans[band];
      }
      else {
         wxASSERT(false);
         return true;
      }
   secondGreatest:
   case DM_SECOND_GREATEST:
      {
         // This method just throws out the high outlier.  It
         // should be less prone to distortions and more prone to
         // chimes.
         float greatest = 0.0, second = 0.0;
         for (int ii = 0; ii < mNWindowsToExamine; ++ii) {
            const float power = mQueue[ii]->mSpectrums[band];
            if (power >= greatest)
               second = greatest, greatest = power;
            else if (power >= second)
               second = power;
         }
         return second <= mNewSensitivity * statistics.mMeans[band];
      }
   default:
      wxASSERT(false);
      return true;
   }
}

(why isn't syntax highlighting working?  I put  before the code block :/)
I'm probably going to build audacity from this SVN checkout I already have, but I'm not planning to compare noise reduction between the latest dev build and the stable 2.0.6 release.


---

