Update of /cvsroot/audacity/audacity-src/src/effects
In directory sc8-pr-cvs11.sourceforge.net:/tmp/cvs-serv25401

Modified Files:
        NoiseRemoval.cpp NoiseRemoval.h 
Log Message:
New rewritten NoiseRemoval effect

Index: NoiseRemoval.h
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/effects/NoiseRemoval.h,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- NoiseRemoval.h      17 Jun 2005 17:33:17 -0000      1.14
+++ NoiseRemoval.h      11 Feb 2007 10:55:57 -0000      1.15
@@ -53,26 +53,59 @@
    void CleanSpeechMayReadNoisegate();
    void CleanSpeechMayWriteNoiseGate();
 
+   bool      mDoProfile;
+   bool      mHasProfile;
+   int       mLevel;
+
+   // Parameters chosen before the first phase
+   double    mSampleRate;
+   int       mWindowSize;
+   int       mSpectrumSize;
+   float     mMinSignalTime;    // in secs
+
+   // The frequency-indexed noise threshold derived during the first
+   // phase of analysis
+   float    *mNoiseThreshold;  // length is mSpectrumSize
+
+   // Parameters that affect the noise removal, regardless of how the
+   // noise profile was extracted
+   double     mFreqSmoothingHz;
+   double     mNoiseGain;              // in dB, should be negative
+   double     mAttackDecayTime;        // in secs
+
    bool ProcessOne(int count, WaveTrack * track,
                    longSampleCount start, sampleCount len);
 
-   void GetProfile(sampleCount len,
-                   float *buffer);
-   void RemoveNoise(sampleCount len,
-                    float *buffer);
-   
-   Envelope *mEnvelope;
+   void Initialize();
+   void StartNewTrack();
+   void ProcessSamples(sampleCount len, float *buffer);
+   void FillFirstHistoryWindow();
+   void ApplyFreqSmoothing(float *spec);
+   void GetProfile();
+   void RemoveNoise();
+   void RotateHistoryWindows();
+   void FinishTrack();
+   void Cleanup();
 
-   int       windowSize;
-   float    *mNoiseGate;
-   float    *sum;
-   float    *sumsq;
-   float    *smoothing;
-   int      *profileCount;
-   
-   bool      mDoProfile;
-   bool      mHasProfile;
-   int       mLevel;
+   // Variables that only exist during processing
+   WaveTrack            *mOutputTrack;
+   longSampleCount       mInSampleCount;
+   longSampleCount       mOutSampleCount;
+   int                   mInputPos;
+
+   int       mFreqSmoothingBins;
+   int       mAttackDecayBlocks;
+   float     mOneBlockAttackDecay;
+   int       mMinSignalBlocks;
+   int       mHistoryLen;
+   float    *mInWaveBuffer;     // mWindowSize
+   float    *mOutWaveBuffer;    // mWindowSize
+   float    *mOutImagBuffer;    // mWindowSize
+   float    *mOutOverlapBuffer; // mWindowSize
+   float   **mSpectrums;        // mHistoryLen x mSpectrumSize
+   float   **mGains;            // mHistoryLen x mSpectrumSize
+   float   **mRealFFTs;         // mHistoryLen x mWindowSize
+   float   **mImagFFTs;         // mHistoryLen x mWindowSize
 
 friend class NoiseRemovalDialog;
 };
@@ -85,18 +118,19 @@
 
 // Declare window functions
 
-class NoiseRemovalDialog: public wxDialog
+class NoiseRemovalDialog: public EffectDialog
 {
 public:
    // constructors and destructors
    NoiseRemovalDialog(EffectNoiseRemoval * effect,
-                                                               wxWindow 
*parent, wxWindowID id, 
-                                                               const wxString 
&title,
-                                                               const wxPoint& 
pos = wxDefaultPosition,
-                                                               const wxSize& 
size = wxDefaultSize,
-                                                               long style = 
wxDEFAULT_DIALOG_STYLE );
+                      wxWindow *parent);
 
-   wxSizer *MakeNoiseRemovalDialog(bool call_fit = true, bool set_sizer = 
true);
+   wxSizer *MakeNoiseRemovalDialog(bool call_fit = true,
+                                   bool set_sizer = true);
+
+   void PopulateOrExchange(ShuttleGui & S);
+   bool TransferDataToWindow();
+   bool TransferDataFromWindow();
    
 private:
    // handlers
@@ -105,19 +139,36 @@
    void OnRemoveNoise( wxCommandEvent &event );
    void OnCancel( wxCommandEvent &event );
    
-private:
-       EffectNoiseRemoval * m_pEffect;
+   void OnGainText(wxCommandEvent & event);
+   void OnFreqText(wxCommandEvent & event);
+   void OnTimeText(wxCommandEvent & event);
+   void OnGainSlider(wxCommandEvent & event);
+   void OnFreqSlider(wxCommandEvent & event);
+   void OnTimeSlider(wxCommandEvent & event);
+
+ public:
+
+   EffectNoiseRemoval * m_pEffect;
 
-public:
-//TIDY-ME: Is mLevel needed in the dialog??
-   int  mLevel;
    wxButton * m_pButton_GetProfile;
-   wxSlider * m_pSlider;
    wxButton * m_pButton_Preview;
    wxButton * m_pButton_RemoveNoise;
-   
+
+   wxSlider   *mGainS;
+   wxSlider   *mFreqS;
+   wxSlider   *mTimeS;
+
+   wxTextCtrl *mGainT;
+   wxTextCtrl *mFreqT;
+   wxTextCtrl *mTimeT;
+
+   float       mGain;
+   float       mFreq;
+   float       mTime;
+
 private:
    DECLARE_EVENT_TABLE()
+
 };
 
 #endif

Index: NoiseRemoval.cpp
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/effects/NoiseRemoval.cpp,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -d -r1.34 -r1.35
--- NoiseRemoval.cpp    23 Sep 2006 02:26:25 -0000      1.34
+++ NoiseRemoval.cpp    11 Feb 2007 10:55:57 -0000      1.35
@@ -9,11 +9,28 @@
 *******************************************************************//**
 
 \class EffectNoiseRemoval
-\brief An Effect.
+\brief A two-pass effect to remove background noise.
+
+  The first pass is done over just noise.  For each windowed sample
+  of the sound, we take a FFT and then statistics are tabulated for
+  each frequency band - specifically the maximum level achieved by
+  at least <n> sampling windows in a row, for various values of <n>.
+
[...1135 lines suppressed...]
+
+void NoiseRemovalDialog::OnGainSlider(wxCommandEvent & event)
+{
+   mGain = mGainS->GetValue();
+   mGainT->SetValue(wxString::Format(wxT("%d"), (int)mGain));
+}
+
+void NoiseRemovalDialog::OnFreqSlider(wxCommandEvent & event)
+{
+   mFreq = mFreqS->GetValue() * 10;
+   mFreqT->SetValue(wxString::Format(wxT("%d"), (int)mFreq));
+}
+
+void NoiseRemovalDialog::OnTimeSlider(wxCommandEvent & event)
+{
+   mTime = mTimeS->GetValue() * 0.01;
+   mTimeT->SetValue(wxString::Format(wxT("%.2f"), mTime));
 }
 
 // Indentation settings for Vim and Emacs and unique identifier for Arch, a


-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier.
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Audacity-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/audacity-cvs

Reply via email to