2010-01-23 19:44:49 +00:00
|
|
|
/**********************************************************************
|
|
|
|
|
|
|
|
Audacity: A Digital Audio Editor
|
|
|
|
|
|
|
|
SoundTouchEffect.h
|
|
|
|
|
|
|
|
Dominic Mazzoni, Vaughan Johnson
|
|
|
|
|
|
|
|
This abstract class contains all of the common code for an
|
|
|
|
effect that uses SoundTouch to do its processing (ChangeTempo
|
|
|
|
and ChangePitch).
|
|
|
|
|
|
|
|
**********************************************************************/
|
|
|
|
|
2021-05-09 15:16:56 +00:00
|
|
|
|
2014-10-27 07:34:17 +00:00
|
|
|
|
2010-01-23 19:44:49 +00:00
|
|
|
#if USE_SOUNDTOUCH
|
|
|
|
|
|
|
|
#ifndef __AUDACITY_EFFECT_SOUNDTOUCH__
|
|
|
|
#define __AUDACITY_EFFECT_SOUNDTOUCH__
|
|
|
|
|
|
|
|
#include "Effect.h"
|
|
|
|
|
2018-07-23 18:27:44 +00:00
|
|
|
// forward declaration of a class defined in SoundTouch.h
|
|
|
|
// which is not included here
|
|
|
|
namespace soundtouch { class SoundTouch; }
|
2010-01-23 19:44:49 +00:00
|
|
|
|
|
|
|
|
2016-12-16 17:37:15 +00:00
|
|
|
class TimeWarper;
|
2010-01-23 19:44:49 +00:00
|
|
|
class WaveTrack;
|
|
|
|
|
2016-02-24 06:06:39 +00:00
|
|
|
class EffectSoundTouch /* not final */ : public Effect
|
2015-04-17 03:53:42 +00:00
|
|
|
{
|
|
|
|
public:
|
2018-07-23 18:27:44 +00:00
|
|
|
|
2016-12-15 12:30:14 +00:00
|
|
|
// Effect implementation
|
|
|
|
|
|
|
|
void End() override;
|
|
|
|
|
2015-04-17 03:53:42 +00:00
|
|
|
// EffectSoundTouch implementation
|
|
|
|
|
2010-10-28 17:57:14 +00:00
|
|
|
#ifdef USE_MIDI
|
|
|
|
double mSemitones; // pitch change for NoteTracks
|
2018-07-23 18:27:44 +00:00
|
|
|
EffectSoundTouch();
|
2010-10-28 17:57:14 +00:00
|
|
|
#endif
|
2018-07-23 18:27:44 +00:00
|
|
|
~EffectSoundTouch() override;
|
2010-01-23 19:44:49 +00:00
|
|
|
|
2015-04-17 03:53:42 +00:00
|
|
|
protected:
|
2016-12-16 17:37:15 +00:00
|
|
|
// Effect implementation
|
|
|
|
|
2020-09-06 08:37:57 +00:00
|
|
|
using InitFunction = std::function< void(soundtouch::SoundTouch *soundtouch) >;
|
2020-09-18 04:22:00 +00:00
|
|
|
bool ProcessWithTimeWarper(InitFunction initer,
|
|
|
|
const TimeWarper &warper,
|
|
|
|
bool preserveLength);
|
2016-12-16 17:37:15 +00:00
|
|
|
|
2018-07-23 18:27:44 +00:00
|
|
|
std::unique_ptr<soundtouch::SoundTouch> mSoundTouch;
|
2010-01-23 19:44:49 +00:00
|
|
|
double mCurT0;
|
|
|
|
double mCurT1;
|
|
|
|
|
2015-04-17 03:53:42 +00:00
|
|
|
private:
|
2016-12-16 17:37:15 +00:00
|
|
|
bool ProcessLabelTrack(LabelTrack *track, const TimeWarper &warper);
|
2012-07-18 03:44:34 +00:00
|
|
|
#ifdef USE_MIDI
|
2016-12-16 17:37:15 +00:00
|
|
|
bool ProcessNoteTrack(NoteTrack *track, const TimeWarper &warper);
|
2012-07-18 03:44:34 +00:00
|
|
|
#endif
|
2016-12-16 17:37:15 +00:00
|
|
|
bool ProcessOne(
|
|
|
|
WaveTrack * t, sampleCount start, sampleCount end,
|
|
|
|
const TimeWarper &warper);
|
2014-06-03 20:30:19 +00:00
|
|
|
bool ProcessStereo(WaveTrack* leftTrack, WaveTrack* rightTrack,
|
2016-12-16 17:37:15 +00:00
|
|
|
sampleCount start, sampleCount end,
|
|
|
|
const TimeWarper &warper);
|
2016-12-15 12:30:14 +00:00
|
|
|
bool ProcessStereoResults(const size_t outputCount,
|
2014-06-03 20:30:19 +00:00
|
|
|
WaveTrack* outputLeftTrack,
|
2010-01-23 19:44:49 +00:00
|
|
|
WaveTrack* outputRightTrack);
|
2020-09-18 04:22:00 +00:00
|
|
|
void Finalize(WaveTrack* orig, WaveTrack* out, const TimeWarper &warper);
|
|
|
|
|
|
|
|
bool mPreserveLength;
|
2010-01-23 19:44:49 +00:00
|
|
|
|
|
|
|
int mCurTrackNum;
|
|
|
|
|
2010-02-16 20:50:38 +00:00
|
|
|
double m_maxNewLength;
|
2010-01-23 19:44:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|