Bug 2367 - Change Pitch effect may create spurious clip at end
Fixes residual mentioned in Comment #11
This commit is contained in:
parent
90a69a0173
commit
5342d980fb
|
@ -207,7 +207,6 @@ bool EffectChangePitch::LoadFactoryDefaults()
|
||||||
|
|
||||||
bool EffectChangePitch::Init()
|
bool EffectChangePitch::Init()
|
||||||
{
|
{
|
||||||
mSoundTouch.reset();
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -230,9 +229,11 @@ bool EffectChangePitch::Process()
|
||||||
// ensure that m_dSemitonesChange is set.
|
// ensure that m_dSemitonesChange is set.
|
||||||
Calc_SemitonesChange_fromPercentChange();
|
Calc_SemitonesChange_fromPercentChange();
|
||||||
|
|
||||||
mSoundTouch = std::make_unique<soundtouch::SoundTouch>();
|
auto initer = [&](soundtouch::SoundTouch *soundtouch)
|
||||||
|
{
|
||||||
|
soundtouch->setPitchSemiTones((float)(m_dSemitonesChange));
|
||||||
|
};
|
||||||
IdentityTimeWarper warper;
|
IdentityTimeWarper warper;
|
||||||
mSoundTouch->setPitchSemiTones((float)(m_dSemitonesChange));
|
|
||||||
#ifdef USE_MIDI
|
#ifdef USE_MIDI
|
||||||
// Pitch shifting note tracks is currently only supported by SoundTouchEffect
|
// Pitch shifting note tracks is currently only supported by SoundTouchEffect
|
||||||
// and non-real-time-preview effects require an audio track selection.
|
// and non-real-time-preview effects require an audio track selection.
|
||||||
|
@ -246,7 +247,7 @@ bool EffectChangePitch::Process()
|
||||||
// eliminate the next line:
|
// eliminate the next line:
|
||||||
mSemitones = m_dSemitonesChange;
|
mSemitones = m_dSemitonesChange;
|
||||||
#endif
|
#endif
|
||||||
return EffectSoundTouch::ProcessWithTimeWarper(warper);
|
return EffectSoundTouch::ProcessWithTimeWarper(initer, warper);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -553,7 +553,7 @@ bool EffectChangeSpeed::ProcessOne(WaveTrack * track,
|
||||||
{
|
{
|
||||||
LinearTimeWarper warper { mCurT0, mCurT0, mCurT1, mCurT0 + newLength };
|
LinearTimeWarper warper { mCurT0, mCurT0, mCurT1, mCurT0 + newLength };
|
||||||
track->ClearAndPaste(
|
track->ClearAndPaste(
|
||||||
mCurT0, mCurT1, outputTrack.get(), false, true, &warper);
|
mCurT0, mCurT1, outputTrack.get(), true, false, &warper);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (newLength > mMaxNewLength)
|
if (newLength > mMaxNewLength)
|
||||||
|
|
|
@ -191,8 +191,6 @@ bool EffectChangeTempo::Init()
|
||||||
m_FromLength = mT1 - mT0;
|
m_FromLength = mT1 - mT0;
|
||||||
m_ToLength = (m_FromLength * 100.0) / (100.0 + m_PercentChange);
|
m_ToLength = (m_FromLength * 100.0) / (100.0 + m_PercentChange);
|
||||||
|
|
||||||
mSoundTouch.reset();
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -212,12 +210,14 @@ bool EffectChangeTempo::Process()
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
mSoundTouch = std::make_unique<soundtouch::SoundTouch>();
|
auto initer = [&](soundtouch::SoundTouch *soundtouch)
|
||||||
mSoundTouch->setTempoChange(m_PercentChange);
|
{
|
||||||
|
soundtouch->setTempoChange(m_PercentChange);
|
||||||
|
};
|
||||||
double mT1Dashed = mT0 + (mT1 - mT0)/(m_PercentChange/100.0 + 1.0);
|
double mT1Dashed = mT0 + (mT1 - mT0)/(m_PercentChange/100.0 + 1.0);
|
||||||
RegionTimeWarper warper{ mT0, mT1,
|
RegionTimeWarper warper{ mT0, mT1,
|
||||||
std::make_unique<LinearTimeWarper>(mT0, mT0, mT1, mT1Dashed ) };
|
std::make_unique<LinearTimeWarper>(mT0, mT0, mT1, mT1Dashed ) };
|
||||||
success = EffectSoundTouch::ProcessWithTimeWarper(warper);
|
success = EffectSoundTouch::ProcessWithTimeWarper(initer, warper);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(success)
|
if(success)
|
||||||
|
|
|
@ -67,7 +67,7 @@ bool EffectSoundTouch::ProcessNoteTrack(NoteTrack *nt, const TimeWarper &warper)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
bool EffectSoundTouch::ProcessWithTimeWarper(const TimeWarper &warper)
|
bool EffectSoundTouch::ProcessWithTimeWarper(InitFunction initer, const TimeWarper &warper)
|
||||||
{
|
{
|
||||||
// Assumes that mSoundTouch has already been initialized
|
// Assumes that mSoundTouch has already been initialized
|
||||||
// by the subclass for subclass-specific parameters. The
|
// by the subclass for subclass-specific parameters. The
|
||||||
|
@ -118,6 +118,8 @@ bool EffectSoundTouch::ProcessWithTimeWarper(const TimeWarper &warper)
|
||||||
|
|
||||||
// Process only if the right marker is to the right of the left marker
|
// Process only if the right marker is to the right of the left marker
|
||||||
if (mCurT1 > mCurT0) {
|
if (mCurT1 > mCurT0) {
|
||||||
|
mSoundTouch = std::make_unique<soundtouch::SoundTouch>();
|
||||||
|
initer(mSoundTouch.get());
|
||||||
|
|
||||||
// TODO: more-than-two-channels
|
// TODO: more-than-two-channels
|
||||||
auto channels = TrackList::Channels(leftTrack);
|
auto channels = TrackList::Channels(leftTrack);
|
||||||
|
@ -158,6 +160,8 @@ bool EffectSoundTouch::ProcessWithTimeWarper(const TimeWarper &warper)
|
||||||
if (!ProcessOne(leftTrack, start, end, warper))
|
if (!ProcessOne(leftTrack, start, end, warper))
|
||||||
bGoodResult = false;
|
bGoodResult = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mSoundTouch.reset();
|
||||||
}
|
}
|
||||||
mCurTrackNum++;
|
mCurTrackNum++;
|
||||||
},
|
},
|
||||||
|
|
|
@ -48,7 +48,8 @@ public:
|
||||||
protected:
|
protected:
|
||||||
// Effect implementation
|
// Effect implementation
|
||||||
|
|
||||||
bool ProcessWithTimeWarper(const TimeWarper &warper);
|
using InitFunction = std::function< void(soundtouch::SoundTouch *soundtouch) >;
|
||||||
|
bool ProcessWithTimeWarper(InitFunction initer, const TimeWarper &warper);
|
||||||
|
|
||||||
std::unique_ptr<soundtouch::SoundTouch> mSoundTouch;
|
std::unique_ptr<soundtouch::SoundTouch> mSoundTouch;
|
||||||
double mCurT0;
|
double mCurT0;
|
||||||
|
|
Loading…
Reference in New Issue