Update of /cvsroot/audacity/audacity-src/src/effects
In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv10020/effects

Modified Files:
        DtmfGen.h Effect.cpp Effect.h FindClipping.cpp FindClipping.h 
        Noise.h Silence.h SimplePairedTwoTrack.h ToneGen.cpp ToneGen.h 
Log Message:
Several effects defined their own GetSamples() method, but they
were all the same, so I moved it to the Effect class and removed
it from the others.

Many effects defined a GetEffectFlags() method, but rather than
incur the extra class overhead for it, I removed the method and
replaced it with a call to SetEffectFlags().  This also put the
handling of the Effect flags into one class (Effect).


Index: Noise.h
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/effects/Noise.h,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -d -r1.17 -r1.18
--- Noise.h     25 Mar 2009 04:14:44 -0000      1.17
+++ Noise.h     20 May 2009 06:22:49 -0000      1.18
@@ -33,8 +33,9 @@
 
  public:
    EffectNoise() {
-       noiseType=0;
-       noiseAmplitude=1.0;
+      SetEffectFlags(BUILTIN_EFFECT | INSERT_EFFECT);
+      noiseType = 0;
+      noiseAmplitude = 1.0;
    }
 
    virtual wxString GetEffectName() {
@@ -59,10 +60,6 @@
       return wxString(_("Generating Noise"));
    }
 
-   virtual int GetEffectFlags() {
-      return BUILTIN_EFFECT | INSERT_EFFECT;
-   }
-
    virtual bool PromptUser();
    virtual bool TransferParameters( Shuttle & shuttle );
 

Index: DtmfGen.h
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/effects/DtmfGen.h,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- DtmfGen.h   25 Mar 2009 04:14:43 -0000      1.12
+++ DtmfGen.h   20 May 2009 06:22:49 -0000      1.13
@@ -33,6 +33,7 @@
 
  public:
    EffectDtmf() {
+      SetEffectFlags(BUILTIN_EFFECT | INSERT_EFFECT);
    }
 
    virtual wxString GetEffectName() {
@@ -57,10 +58,6 @@
       return wxString(_("Generating DTMF tones"));
    }
 
-   virtual int GetEffectFlags() {
-      return BUILTIN_EFFECT | INSERT_EFFECT;
-   }
-
    virtual bool PromptUser();
    virtual bool TransferParameters( Shuttle & shuttle );
 

Index: Effect.h
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/effects/Effect.h,v
retrieving revision 1.43
retrieving revision 1.44
diff -u -d -r1.43 -r1.44
--- Effect.h    4 Apr 2009 05:45:05 -0000       1.43
+++ Effect.h    20 May 2009 06:22:49 -0000      1.44
@@ -106,6 +106,7 @@
       // covers most built-in effects.
       return mFlags;
    }
+
    virtual bool TransferParameters( Shuttle & shuttle ){
       return true;
    }
@@ -226,6 +227,9 @@
 
    int GetNumWaveGroups() { return mNumGroups; }
 
+   // Calculates the start time and selection length in samples
+   void GetSamples(WaveTrack *track, sampleCount *start, sampleCount *len);
+
  //
  // protected static data
  //
@@ -234,6 +238,7 @@
  protected:
    static double sDefaultGenerateLen;
    int mFlags;
+   double mLength;
  
  //
  // private methods

Index: Silence.h
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/effects/Silence.h,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -d -r1.17 -r1.18
--- Silence.h   25 Mar 2009 04:14:44 -0000      1.17
+++ Silence.h   20 May 2009 06:22:49 -0000      1.18
@@ -26,7 +26,9 @@
 class EffectSilence : public Generator {
 
  public:
-   EffectSilence() { }
+   EffectSilence() {
+      SetEffectFlags(BUILTIN_EFFECT | INSERT_EFFECT);
+   }
 
    virtual wxString GetEffectName() {
       return wxString(_("Silence..."));
@@ -51,10 +53,6 @@
       return wxString::Format(_("Applied effect: Generate Silence, %.6lf 
seconds"), mDuration); 
    } 
 
-   virtual int GetEffectFlags() {
-      return BUILTIN_EFFECT | INSERT_EFFECT;
-   }
-
    virtual bool PromptUser();
  protected:
    bool GenerateTrack(WaveTrack *tmp, const WaveTrack &track, int ntrack);

Index: Effect.cpp
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/effects/Effect.cpp,v
retrieving revision 1.72
retrieving revision 1.73
diff -u -d -r1.72 -r1.73
--- Effect.cpp  25 Apr 2009 22:59:41 -0000      1.72
+++ Effect.cpp  20 May 2009 06:22:49 -0000      1.73
@@ -61,10 +61,11 @@
 {
    mTracks = NULL;
    mOutputWaveTracks = NULL;
+   mLength = 0;
 
    // Can change effect flags later (this is the new way)
    // OR using the old way, over-ride GetEffectFlags().
-   mFlags = BUILTIN_EFFECT | PROCESS_EFFECT | ADVANCED_EFFECT ;
+   mFlags = BUILTIN_EFFECT | PROCESS_EFFECT | ADVANCED_EFFECT;
 }
 
 bool Effect::DoEffect(wxWindow *parent, int flags,
@@ -148,6 +149,32 @@
    return true;
 }
 
+void Effect::GetSamples(WaveTrack *track, sampleCount *start, sampleCount *len)
+{
+   double trackStart = track->GetStartTime();
+   double trackEnd = track->GetEndTime();
+   double t0 = mT0 < trackStart ? trackStart : mT0;
+   double t1 = mT1 > trackEnd ? trackEnd : mT1;
+
+   if (mFlags & INSERT_EFFECT) {
+      t1 = t0 + mLength;
+      if (mT0 == mT1) {
+         // Not really part of the calculation, but convenient to put here
+         track->InsertSilence(t0, t1);
+      }
+   }
+
+   if (t1 > t0) {
+      *start = track->TimeToLongSamples(t0);
+      sampleCount end = track->TimeToLongSamples(t1);
+      *len = (sampleCount)(end - *start);
+   }
+   else {
+      *start = 0;
+      *len  = 0;
+   }
+}
+
 //
 // private methods
 //

Index: SimplePairedTwoTrack.h
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/effects/SimplePairedTwoTrack.h,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- SimplePairedTwoTrack.h      12 Jul 2008 15:25:47 -0000      1.12
+++ SimplePairedTwoTrack.h      20 May 2009 06:22:49 -0000      1.13
@@ -66,11 +66,6 @@
                                                        sampleCount rstart, 
sampleCount len);
 
    // It is not usually necessary to override this method
-   void GetSamples(WaveTrack *track, 
-                      sampleCount *start,
-                                  sampleCount *len);
-
-   // It is not usually necessary to override this method
    void End();
 
  protected:  
@@ -226,27 +221,6 @@
 }
 
 template<class _DataType,sampleFormat _xxxSample>
-void EffectSimplePairedTwoTrack<_DataType,_xxxSample>::GetSamples(WaveTrack 
*track,
-                                                                               
         sampleCount *start,
-                                                                               
         sampleCount *len)
-{
-   double trackStart = track->GetStartTime();
-   double trackEnd = track->GetEndTime();
-   double t0 = mT0 < trackStart? trackStart: mT0;
-   double t1 = mT1 > trackEnd? trackEnd: mT1;
-   
-   if (t1 > t0) {
-      *start = track->TimeToLongSamples(t0);
-      sampleCount end = track->TimeToLongSamples(t1);
-      *len = (sampleCount)(end - *start);
-   }
-   else {
-      *start = 0;
-      *len  = 0;
-   }
-}
-
-template<class _DataType,sampleFormat _xxxSample>
 void EffectSimplePairedTwoTrack<_DataType,_xxxSample>::End()
 {
    if (mnBlockSize) {

Index: FindClipping.h
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/effects/FindClipping.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- FindClipping.h      12 Jul 2008 15:25:46 -0000      1.5
+++ FindClipping.h      20 May 2009 06:22:49 -0000      1.6
@@ -53,10 +53,6 @@
    {
       return wxString(_("Detecting clipping"));
    }
-   
-   virtual int GetEffectFlags() {
-      return BUILTIN_EFFECT | ANALYZE_EFFECT;
-   }
 
    virtual wxString GetEffectDescription(); 
 

Index: ToneGen.cpp
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/effects/ToneGen.cpp,v
retrieving revision 1.65
retrieving revision 1.66
diff -u -d -r1.65 -r1.66
--- ToneGen.cpp 25 Mar 2009 04:14:44 -0000      1.65
+++ ToneGen.cpp 20 May 2009 06:22:49 -0000      1.66
@@ -42,14 +42,15 @@
 
 EffectToneGen::EffectToneGen()
 {
-   mbChirp=false;
-   mbLogInterpolation=false;
+   SetEffectFlags(BUILTIN_EFFECT | INSERT_EFFECT);
+   mbChirp = false;
+   mbLogInterpolation = false;
    waveform = 0;                //sine
    frequency[0] = float(440.0);          //Hz
    frequency[1] = float(1320.0);          //Hz
    amplitude[0] = float(0.8);
    amplitude[1] = float(0.8);
-   interpolation=0;
+   interpolation = 0;
 }
 
 wxString EffectToneGen::GetEffectDescription() { 

Index: ToneGen.h
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/effects/ToneGen.h,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -d -r1.29 -r1.30
--- ToneGen.h   25 Mar 2009 04:14:44 -0000      1.29
+++ ToneGen.h   20 May 2009 06:22:49 -0000      1.30
@@ -57,10 +57,6 @@
    // Useful only after PromptUser values have been set.
    virtual wxString GetEffectDescription(); 
 
-   virtual int GetEffectFlags() {
-      return BUILTIN_EFFECT | INSERT_EFFECT;
-   }
-
    virtual bool PromptUser();
    virtual bool TransferParameters( Shuttle & shuttle );
 

Index: FindClipping.cpp
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/effects/FindClipping.cpp,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- FindClipping.cpp    23 Mar 2009 00:32:54 -0000      1.8
+++ FindClipping.cpp    20 May 2009 06:22:49 -0000      1.9
@@ -40,6 +40,7 @@
 
 EffectFindClipping::EffectFindClipping()
 {
+   SetEffectFlags(BUILTIN_EFFECT | ANALYZE_EFFECT);
    mStart = 3;
    mStop = 3;
 }


------------------------------------------------------------------------------
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables 
unlimited royalty-free distribution of the report engine 
for externally facing server and web deployment. 
http://p.sf.net/sfu/businessobjects
_______________________________________________
Audacity-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/audacity-cvs

Reply via email to