1 /********************************************************************** 2 3 Audacity: A Digital Audio Editor 4 5 TwoPassSimpleMono.h 6 7 Dominic Mazzoni 8 9 This bit by Martyn Shaw. 10 11 **********************************************************************/ 12 #ifndef __AUDACITY_EFFECT_TWOPASSSIMPLEMONO__ 13 #define __AUDACITY_EFFECT_TWOPASSSIMPLEMONO__ 14 15 #include "SimpleMono.h" 16 17 18 class WaveTrack; 19 20 class AUDACITY_DLL_API EffectTwoPassSimpleMono /* not final */ : public Effect 21 { 22 public: 23 // Effect implementation 24 25 bool Process() override; 26 27 protected: 28 // EffectTwoPassSimpleMono implementation 29 30 // Override these methods if you need to initialize something 31 // before each pass. Return None if processing should stop. 32 // These should not depend on mOutputTracks having been set up via CopyInputTracks(). 33 bool InitPass1() override; 34 bool InitPass2() override; 35 36 // NEW virtuals 37 38 // Override these methods if you need to do things 39 // before every track (including the first one) 40 virtual bool NewTrackPass1(); 41 virtual bool NewTrackPass2(); 42 43 // Override this method to actually process audio ProcessPass1(float * WXUNUSED (buffer),size_t WXUNUSED (len))44 virtual bool ProcessPass1 45 (float * WXUNUSED(buffer), size_t WXUNUSED(len)) 46 { return false; } 47 ProcessPass2(float * WXUNUSED (buffer),size_t WXUNUSED (len))48 virtual bool ProcessPass2 49 (float * WXUNUSED(buffer), size_t WXUNUSED(len)) 50 { return false; } 51 52 // Override this method to actually process audio with access to 2 sequential buffers at a time 53 // Either buffer1 or buffer2 may be modified as needed 54 // This allows implementation of processing with delays 55 // The default just calls the one-buffer-at-a-time method TwoBufferProcessPass1(float * buffer1,size_t len1,float * WXUNUSED (buffer2),size_t WXUNUSED (len2))56 virtual bool TwoBufferProcessPass1 57 (float *buffer1, size_t len1, float * WXUNUSED(buffer2), size_t WXUNUSED(len2)) 58 { if(buffer1 != NULL) return ProcessPass1(buffer1, len1); else return true; } TwoBufferProcessPass2(float * buffer1,size_t len1,float * WXUNUSED (buffer2),size_t WXUNUSED (len2))59 virtual bool TwoBufferProcessPass2 60 (float *buffer1, size_t len1, float * WXUNUSED(buffer2), size_t WXUNUSED(len2)) 61 { if(buffer1 != NULL) return ProcessPass2(buffer1, len1); else return true; } 62 63 // End of NEW virtuals 64 65 // Call this if you know in advance that no second pass will be needed. 66 // This is used as a hint for the progress bar DisableSecondPass()67 void DisableSecondPass() { mSecondPassDisabled = true; } 68 69 // Other useful information 70 int mCurTrackNum; 71 double mCurRate; 72 double mCurT0; 73 double mCurT1; 74 int mCurChannel; 75 int mPass; 76 bool mSecondPassDisabled; 77 78 std::shared_ptr<TrackList> mWorkTracks; 79 std::shared_ptr<TrackList> *mTrackLists[2]; 80 81 private: 82 bool ProcessOne(WaveTrack * t, WaveTrack * outTrack, 83 sampleCount start, sampleCount end); 84 bool ProcessPass() override; 85 }; 86 87 #endif 88