1 /********************************************************************** 2 3 Audacity: A Digital Audio Editor 4 5 SoundTouchEffect.h 6 7 Dominic Mazzoni, Vaughan Johnson 8 9 This abstract class contains all of the common code for an 10 effect that uses SoundTouch to do its processing (ChangeTempo 11 and ChangePitch). 12 13 **********************************************************************/ 14 15 16 17 #if USE_SOUNDTOUCH 18 19 #ifndef __AUDACITY_EFFECT_SOUNDTOUCH__ 20 #define __AUDACITY_EFFECT_SOUNDTOUCH__ 21 22 #include "Effect.h" 23 24 // forward declaration of a class defined in SoundTouch.h 25 // which is not included here 26 namespace soundtouch { class SoundTouch; } 27 28 29 class TimeWarper; 30 class WaveTrack; 31 32 class EffectSoundTouch /* not final */ : public Effect 33 { 34 public: 35 36 // Effect implementation 37 38 void End() override; 39 40 // EffectSoundTouch implementation 41 42 #ifdef USE_MIDI 43 double mSemitones; // pitch change for NoteTracks 44 EffectSoundTouch(); 45 #endif 46 ~EffectSoundTouch() override; 47 48 protected: 49 // Effect implementation 50 51 using InitFunction = std::function< void(soundtouch::SoundTouch *soundtouch) >; 52 bool ProcessWithTimeWarper(InitFunction initer, 53 const TimeWarper &warper, 54 bool preserveLength); 55 56 std::unique_ptr<soundtouch::SoundTouch> mSoundTouch; 57 double mCurT0; 58 double mCurT1; 59 60 private: 61 bool ProcessLabelTrack(LabelTrack *track, const TimeWarper &warper); 62 #ifdef USE_MIDI 63 bool ProcessNoteTrack(NoteTrack *track, const TimeWarper &warper); 64 #endif 65 bool ProcessOne( 66 WaveTrack * t, sampleCount start, sampleCount end, 67 const TimeWarper &warper); 68 bool ProcessStereo(WaveTrack* leftTrack, WaveTrack* rightTrack, 69 sampleCount start, sampleCount end, 70 const TimeWarper &warper); 71 bool ProcessStereoResults(const size_t outputCount, 72 WaveTrack* outputLeftTrack, 73 WaveTrack* outputRightTrack); 74 void Finalize(WaveTrack* orig, WaveTrack* out, const TimeWarper &warper); 75 76 bool mPreserveLength; 77 78 int mCurTrackNum; 79 80 double m_maxNewLength; 81 }; 82 83 #endif 84 85 #endif 86