1
0
mirror of https://github.com/cookiengineer/audacity synced 2026-03-03 05:04:24 +01:00

Extended pitch, tempo, and speed effects to operate on NoteTracks. Fixed off-by-one error on channel buttons.

This commit is contained in:
rbdannenberg
2010-10-28 17:57:14 +00:00
parent f3b91514d2
commit f274c9fb2b
6 changed files with 125 additions and 14 deletions

View File

@@ -156,6 +156,16 @@ bool EffectChangePitch::Process()
mSoundTouch = new SoundTouch();
SetTimeWarper(new IdentityTimeWarper());
mSoundTouch->setPitchSemiTones((float)(m_SemitonesChange));
#ifdef USE_MIDI
// Note: m_SemitonesChange is private to ChangePitch because it only
// needs to pass it along to mSoundTouch (above). I added mSemitones
// to SoundTouchEffect (the super class) to convey this value
// to process Note tracks. This approach minimizes changes to existing
// code, but it would be cleaner to change all m_SemitonesChange to
// mSemitones, make mSemitones exist with or without USE_MIDI, and
// eliminate the next line:
mSemitones = m_SemitonesChange;
#endif
return this->EffectSoundTouch::Process();
}

View File

@@ -34,6 +34,14 @@ bool EffectSoundTouch::ProcessLabelTrack(Track *track)
return true;
}
bool EffectSoundTouch::ProcessNoteTrack(Track *track)
{
NoteTrack *nt = (NoteTrack *) track;
if (nt == NULL) return false;
nt->WarpAndTransposeNotes(mCurT0, mCurT1, *GetTimeWarper(), mSemitones);
return true;
}
bool EffectSoundTouch::Process()
{
// Assumes that mSoundTouch has already been initialized
@@ -68,6 +76,17 @@ bool EffectSoundTouch::Process()
break;
}
}
#ifdef USE_MIDI
else if (t->GetKind() == Track::Note &&
(t->GetSelected() || (mustSync && t->IsSyncLockSelected())))
{
if (!ProcessNoteTrack(t))
{
bGoodResult = false;
break;
}
}
#endif
else if (t->GetKind() == Track::Wave && t->GetSelected())
{
WaveTrack* leftTrack = (WaveTrack*)t;

View File

@@ -36,6 +36,10 @@ class EffectSoundTouch:public Effect {
public:
virtual bool Process();
#ifdef USE_MIDI
double mSemitones; // pitch change for NoteTracks
EffectSoundTouch() { mSemitones = 0; }
#endif
protected:
SoundTouch *mSoundTouch;
@@ -44,6 +48,7 @@ class EffectSoundTouch:public Effect {
private:
bool ProcessLabelTrack(Track *track);
bool ProcessNoteTrack(Track *track);
bool ProcessOne(WaveTrack * t, sampleCount start, sampleCount end);
bool ProcessStereo(WaveTrack* leftTrack, WaveTrack* rightTrack,
sampleCount start, sampleCount end);