mirror of
https://github.com/cookiengineer/audacity
synced 2025-06-15 15:49:36 +02:00
Bug 1215 - Incorrect splits produced by Change Tempo with leading whitespace
This commit is contained in:
parent
3605d73d12
commit
6749d5b6fa
@ -19,6 +19,7 @@ effect that uses SBSMS to do its processing (TimeScale)
|
|||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
#include "../LabelTrack.h"
|
#include "../LabelTrack.h"
|
||||||
|
#include "../WaveClip.h"
|
||||||
#include "../WaveTrack.h"
|
#include "../WaveTrack.h"
|
||||||
#include "TimeWarper.h"
|
#include "TimeWarper.h"
|
||||||
|
|
||||||
@ -426,12 +427,9 @@ bool EffectSBSMS::Process()
|
|||||||
if(rightTrack)
|
if(rightTrack)
|
||||||
rb.outputRightTrack->Flush();
|
rb.outputRightTrack->Flush();
|
||||||
|
|
||||||
leftTrack->ClearAndPaste(mCurT0, mCurT1, rb.outputLeftTrack.get(),
|
Finalize(leftTrack, rb.outputLeftTrack.get(), warper.get());
|
||||||
true, false, warper.get());
|
|
||||||
|
|
||||||
if(rightTrack)
|
if(rightTrack)
|
||||||
rightTrack->ClearAndPaste(mCurT0, mCurT1, rb.outputRightTrack.get(),
|
Finalize(rightTrack, rb.outputRightTrack.get(), warper.get());
|
||||||
true, false, warper.get());
|
|
||||||
}
|
}
|
||||||
mCurTrackNum++;
|
mCurTrackNum++;
|
||||||
},
|
},
|
||||||
@ -454,4 +452,42 @@ bool EffectSBSMS::Process()
|
|||||||
return bGoodResult;
|
return bGoodResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EffectSBSMS::Finalize(WaveTrack* orig, WaveTrack* out, const TimeWarper *warper)
|
||||||
|
{
|
||||||
|
// Silenced samples will be inserted in gaps between clips, so capture where these
|
||||||
|
// gaps are for later deletion
|
||||||
|
std::vector<std::pair<double, double>> gaps;
|
||||||
|
double last = 0.0;
|
||||||
|
auto clips = orig->SortedClipArray();
|
||||||
|
auto front = clips.front();
|
||||||
|
auto back = clips.back();
|
||||||
|
for (auto &clip : clips) {
|
||||||
|
auto st = clip->GetStartTime();
|
||||||
|
auto et = clip->GetEndTime();
|
||||||
|
|
||||||
|
if (st >= mCurT0 || et < mCurT1) {
|
||||||
|
if (mCurT0 < st && clip == front) {
|
||||||
|
gaps.push_back(std::make_pair(mCurT0, st));
|
||||||
|
}
|
||||||
|
if (mCurT1 > et && clip == back) {
|
||||||
|
gaps.push_back(std::make_pair(et, mCurT1));
|
||||||
|
}
|
||||||
|
if (last >= mCurT0) {
|
||||||
|
gaps.push_back(std::make_pair(last, st));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
last = et;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Take the output track and insert it in place of the original sample data
|
||||||
|
orig->ClearAndPaste(mCurT0, mCurT1, out, true, true, warper);
|
||||||
|
|
||||||
|
// Finally, recreate the gaps
|
||||||
|
for (auto gap : gaps) {
|
||||||
|
auto st = orig->LongSamplesToTime(orig->TimeToLongSamples(gap.first));
|
||||||
|
auto et = orig->LongSamplesToTime(orig->TimeToLongSamples(gap.second));
|
||||||
|
orig->SplitDelete(warper->Warp(st), warper->Warp(et));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -45,6 +45,8 @@ protected:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
bool ProcessLabelTrack(LabelTrack *track);
|
bool ProcessLabelTrack(LabelTrack *track);
|
||||||
|
void Finalize(WaveTrack* orig, WaveTrack* out, const TimeWarper *warper);
|
||||||
|
|
||||||
double rateStart, rateEnd, pitchStart, pitchEnd;
|
double rateStart, rateEnd, pitchStart, pitchEnd;
|
||||||
bool bLinkRatePitch, bRateReferenceInput, bPitchReferenceInput;
|
bool bLinkRatePitch, bRateReferenceInput, bPitchReferenceInput;
|
||||||
SlideType rateSlideType;
|
SlideType rateSlideType;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user