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

Modified Files:
        Equalization.cpp Equalization.h 
Log Message:
Added batch capabilities.

Index: Equalization.cpp
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/effects/Equalization.cpp,v
retrieving revision 1.59
retrieving revision 1.60
diff -u -d -r1.59 -r1.60
--- Equalization.cpp    28 Mar 2007 04:14:04 -0000      1.59
+++ Equalization.cpp    30 Apr 2007 23:18:14 -0000      1.60
@@ -300,6 +300,8 @@
    mFilterFuncR = new float[windowSize];
    mFilterFuncI = new float[windowSize];
    mM = 4001;
+   mCurveName = wxString(wxT("custom"));
+   mLin = false;
    mdBMin = -30.;
    mdBMax = 30.;
 }
@@ -315,7 +317,6 @@
    mFilterFuncI = NULL;
 }
 
-
 bool EffectEqualization::PromptUser()
 {
    TrackListIterator iter(mWaveTracks);
@@ -328,9 +329,11 @@
 
 
    EqualizationDialog dlog(this, ((double)loFreqI), hiFreq, mFilterFuncR, 
mFilterFuncI,
-                           windowSize, mParent, -1, _("Equalization"));
+                           windowSize, mCurveName, mParent, -1, 
_("Equalization"));
 
    dlog.M = mM;
+   dlog.curveName = mCurveName;
+   dlog.linCheck = mLin;
    dlog.dBMin = mdBMin;
    dlog.dBMax = mdBMax;
    dlog.TransferDataToWindow();
@@ -341,21 +344,49 @@
       return false;
 
    mM = dlog.M;
+   mCurveName = dlog.curveName;
+   mLin = dlog.linCheck;
    mdBMin = dlog.dBMin;
    mdBMax = dlog.dBMax;
 
    return true;
 }
 
+bool EffectEqualization::DontPromptUser()
+{
+   TrackListIterator iter(mWaveTracks);
+   WaveTrack *t = (WaveTrack *) iter.First();
+   float hiFreq;
+   if (t)
+      hiFreq = ((float)(t->GetRate())/2.);
+   else
+      hiFreq = ((float)(GetActiveProject()->GetRate())/2.);
+
+
+   EqualizationDialog dlog(this, ((double)loFreqI), hiFreq, mFilterFuncR, 
mFilterFuncI,
+                           windowSize, mCurveName, mParent, -1, 
_("Equalization"));
+
+   dlog.M = mM;
+   dlog.curveName = mCurveName;
+   dlog.linCheck = mLin;
+   dlog.TransferDataToWindow();
+   dlog.CalcFilter();
+
+   return true;
+}
+
 bool EffectEqualization::TransferParameters( Shuttle & shuttle )
 {
-   //TODO: Lots of parameters...
-//   shuttle.TransferInt("",,0);
+   shuttle.TransferInt(wxT("FilterLength"),mM,4001);
+   shuttle.TransferString(wxT("CurveName"),mCurveName,wxT("eric"));
+   shuttle.TransferBool(wxT("InterpolateLin"),mLin,false);
+
    return true;
 }
 
 bool EffectEqualization::Process()
 {
+   DontPromptUser();
    TrackListIterator iter(mWaveTracks);
    WaveTrack *track = (WaveTrack *) iter.First();
    int count = 0;
@@ -796,6 +827,7 @@
                      float *filterFuncR,
                      float *filterFuncI,
                      long windowSize,
+                     wxString curveName,
                      wxWindow *parent, wxWindowID id,
                      const wxString &title,
                      const wxPoint &position,
@@ -806,6 +838,8 @@
    m_pEffect = effect;
 
    M = 4001;
+   curveName = wxT("custom");
+   linCheck = false;
    dBMin = -30.;
    dBMax = 30;
 
@@ -838,7 +872,7 @@
    MakeEqualizationDialog();
 
    // Set initial curve
-   setCurve( mLogEnvelope );
+   setCurve( mLogEnvelope, curveName );
 
    bandsInUse = NUMBER_OF_BANDS;
    //double loLog = log10(mLoFreq);
@@ -1262,6 +1296,11 @@
 //
 bool EqualizationDialog::TransferDataToWindow()
 {
+   // Set log or lin freq scale (affects interpolation as well)
+   mLinFreq->SetValue( linCheck );
+   wxCommandEvent dummyEvent;
+   OnLinFreq(dummyEvent);
+
    MSlider->SetValue((M-1)/2);
    M = 0;                        // force refresh in TransferDataFromWindow()
 
@@ -1271,6 +1310,9 @@
    dBMaxSlider->SetValue((int)dBMax);
    dBMax = 0;                    // force refresh in TransferDataFromWindow()
 
+   // Set initial curve
+   setCurve( mLogEnvelope, curveName );
+
    return TransferDataFromWindow();
 }
 
@@ -1488,6 +1530,21 @@
    setCurve( env, (int) mCurves.GetCount()-1);
 }
 
+void EqualizationDialog::setCurve(Envelope *env, wxString curveName)
+{
+   unsigned i = 0;
+   for( i = 0; i < mCurves.GetCount(); i++ )
+      if( curveName == mCurves[ i ].Name )
+         break;
+   if( i == mCurves.GetCount())
+   {
+      wxMessageBox( wxT("Requested curve not found, using 'custom'"), 
wxT("Curve not found"), wxOK|wxICON_ERROR );
+      setCurve( env, (int) mCurves.GetCount()-1);
+   }
+   else
+      setCurve( env, i );
+}
+
 //
 // Set new curve selection and manage state of delete button
 //
@@ -1495,6 +1552,7 @@
 {
    // Set current choice
    mCurve->SetSelection( curve );
+   curveName = mCurves[ curve ].Name;
 
    // If the "custom" curve became active
    if( curve == mCurve->GetCount() - 1 )
@@ -2095,6 +2153,7 @@
       freqRuler->ruler.SetRange(0, mHiFreq);
       EnvLogToLin();
       mPanel->mEnvelope = mLinEnvelope;
+      linCheck = true;
    }
    else  //going from lin to log freq scale
    {
@@ -2102,6 +2161,7 @@
       freqRuler->ruler.SetRange(mLoFreq, mHiFreq);
       EnvLinToLog();
       mPanel->mEnvelope = mLogEnvelope;
+      linCheck = false;
    }
    CalcFilter();
    freqRuler->Refresh(false);
@@ -2451,28 +2511,29 @@
    {
       // Update custom curve (so it's there for next time)
       //(done in a hurry, may not be the neatest -MJS)
-      int i, j;
-      int numPoints = mLogEnvelope->GetNumberOfPoints();
-      double *when = new double[ numPoints ];
-      double *value = new double[ numPoints ];
-      mLogEnvelope->GetPoints( when, value, numPoints );
-      for(i=0,j=0;j<numPoints-2;i++,j++)
+      if( mDirty == true )
       {
-         if( (value[i]<value[i+1]+.05) && (value[i]>value[i+1]-.05) &&
-             (value[i+1]<value[i+2]+.05) && (value[i+1]>value[i+2]-.05) )
-         {   // within < 0.05 dB?
-            mLogEnvelope->Delete(j+1);
-            numPoints--;
-            j--;
+         int i, j;
+         int numPoints = mLogEnvelope->GetNumberOfPoints();
+         double *when = new double[ numPoints ];
+         double *value = new double[ numPoints ];
+         mLogEnvelope->GetPoints( when, value, numPoints );
+         for(i=0,j=0;j<numPoints-2;i++,j++)
+         {
+            if( (value[i]<value[i+1]+.05) && (value[i]>value[i+1]-.05) &&
+                (value[i+1]<value[i+2]+.05) && (value[i+1]>value[i+2]-.05) )
+            {   // within < 0.05 dB?
+               mLogEnvelope->Delete(j+1);
+               numPoints--;
+               j--;
+            }
          }
+         delete [] when;
+         delete [] value;
+         Select( (int) mCurves.GetCount()-1 );
       }
-      Select( (int) mCurves.GetCount()-1 );
-      EnvelopeUpdated();
-      mDirty = true;
       SaveCurves();
 
-      delete [] when;
-      delete [] value;
       if(mLogEnvelope)
          delete mLogEnvelope;
       mLogEnvelope = NULL;

Index: Equalization.h
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/effects/Equalization.h,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -d -r1.25 -r1.26
--- Equalization.h      15 Apr 2007 02:23:26 -0000      1.25
+++ Equalization.h      30 Apr 2007 23:18:14 -0000      1.26
@@ -96,6 +96,7 @@
    }
 
    virtual bool PromptUser();
+   virtual bool DontPromptUser();
    virtual bool TransferParameters( Shuttle & shuttle );
 
    virtual bool Process();
@@ -117,6 +118,8 @@
    float *mFilterFuncR;
    float *mFilterFuncI;
    int mM;
+   wxString mCurveName;
+   bool mLin;
    float mdBMax;
    float mdBMin;
 
@@ -198,7 +201,7 @@
    // constructors and destructors
    EqualizationDialog(EffectEqualization * effect,
                double loFreq, double hiFreq,
-               float *filterFuncR, float *filterFuncI, long windowSize,
+               float *filterFuncR, float *filterFuncI, long windowSize, 
wxString CurveName,
                wxWindow *parent, wxWindowID id,
                const wxString &title,
                const wxPoint& pos = wxDefaultPosition,
@@ -217,6 +220,8 @@
    wxChoice *mInterpChoice;
    wxCheckBox *mLinFreq;
    int M;
+   wxString curveName;
+   bool linCheck;
    float dBMin;
    float dBMax;
    double whens[NUM_PTS];
@@ -231,6 +236,7 @@
    void SaveCurves();
    void Select(int sel);
    void setCurve(Envelope *env, int currentCurve);
+   void setCurve(Envelope *env, wxString curveName);
    void setCurve(Envelope *env);
    void GraphicEQ(Envelope *env);
    void spline(double x[], double y[], int n, double y2[]);


-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Audacity-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/audacity-cvs

Reply via email to