23 "Change Speed and Pitch") };
50 return XO(
"Changes the speed of a track, also changing its pitch");
55 return L
"Change_Speed";
98 const WaveTrack& track,
const double curT0,
const double curT1) ->
Gaps
103 const auto newGap = [&](
double st,
double et) {
104 gaps.emplace_back(track.SnapToSample(st), track.SnapToSample(et));
107 auto clips = track.SortedIntervalArray();
108 auto front = clips.front();
109 auto back = clips.back();
110 for (
auto& clip : clips)
112 auto st = clip->GetPlayStartTime();
113 auto et = clip->GetPlayEndTime();
114 if (st >= curT0 || et < curT1)
116 if (curT0 < st && clip == front)
118 else if (last < st && curT0 <= last)
120 if (et < curT1 && clip == back)
136 bool bGoodResult =
true;
142 outputs.Get().Any().VisitWhile(
151 [&](
auto&& fallthrough) {
153 if (!outWaveTrack.GetSelected())
154 return fallthrough();
157 mCurT0 = outWaveTrack.GetStartTime();
158 mCurT1 = outWaveTrack.GetEndTime();
170 auto start = outWaveTrack.TimeToLongSamples(
mCurT0);
171 auto end = outWaveTrack.TimeToLongSamples(
mCurT1);
175 auto pNewTrack = outWaveTrack.EmptyCopy();
176 auto iter = pNewTrack->Channels().begin();
177 for (
const auto pChannel : outWaveTrack.Channels())
195 const double newLength = pNewTrack->GetEndTime();
199 outWaveTrack.ClearAndPaste(
203 for (
const auto [st, et] : gaps)
205 outWaveTrack.SplitDelete(warper.Warp(st), warper.Warp(et));
230 std::make_unique<LinearTimeWarper>(
245 auto len = (
end - start).as_double();
251 Floats inBuffer { inBufferSize };
254 auto outBufferSize = size_t(
mFactor * inBufferSize + 10);
255 Floats outBuffer { outBufferSize };
263 auto samplePos = start;
264 while (samplePos <
end)
271 track.
GetFloats(inBuffer.get(), samplePos, blockSize);
273 const auto results = resample.
Process(
274 mFactor, inBuffer.get(), blockSize, ((samplePos + blockSize) >=
end),
275 outBuffer.get(), outBufferSize);
276 const auto outgen = results.second;
282 samplePos += results.first;
std::optional< std::unique_ptr< EffectSettingsAccess::Message > > OptionalMessage
size_t limitSampleBufferSize(size_t bufferSize, sampleCount limit)
Contains declarations for TimeWarper, IdentityTimeWarper, ShiftTimeWarper, LinearTimeWarper,...
static Settings & settings()
Generates EffectParameterMethods overrides from variadic template arguments.
An Effect that affects both pitch & speed.
ManualPageID ManualPage() const override
Name of a page in the Audacity alpha manual, default is empty.
OptionalMessage DoLoadFactoryDefaults(EffectSettings &settings)
bool ProcessLabelTrack(LabelTrack *t)
bool CheckWhetherSkipEffect(const EffectSettings &settings) const override
After Init(), tell whether Process() should be skipped.
static const ComponentInterfaceSymbol Symbol
const EffectParameterMethods & Parameters() const override
ComponentInterfaceSymbol GetSymbol() const override
OptionalMessage LoadFactoryDefaults(EffectSettings &settings) const override
Gaps FindGaps(const WaveTrack &track, const double curT0, const double curT1)
bool ProcessOne(const WaveChannel &track, WaveChannel &outputTrack, sampleCount start, sampleCount end)
TranslatableString GetDescription() const override
double CalcPreviewInputLength(const EffectSettings &settings, double previewLength) const override
virtual ~ChangeSpeedBase()
bool Process(EffectInstance &instance, EffectSettings &settings) override
EffectType GetType() const override
Type determines how it behaves.
ComponentInterfaceSymbol pairs a persistent string identifier used internally with an optional,...
const wxString & Internal() const
void SetLinearEffectFlag(bool linearEffectFlag)
std::shared_ptr< TrackList > mTracks
OptionalMessage LoadFactoryDefaults(EffectSettings &settings) const override
bool TrackProgress(int whichTrack, double frac, const TranslatableString &={}) const
Performs effect computation.
Use this object to copy the input tracks to tentative outputTracks.
Interface for manipulations of an Effect's settings.
virtual void Reset(Effect &effect) const =0
A LabelTrack is a Track that holds labels (LabelStruct).
void WarpLabels(const TimeWarper &warper)
Linear scaling, initialised by giving two points on the line.
No change before the specified region; during the region, warp according to the given warper; after t...
std::pair< size_t, size_t > Process(double factor, const float *inBuffer, size_t inBufferLen, bool lastFlag, float *outBuffer, size_t outBufferLen)
Main processing function. Resamples from the input buffer to the output buffer.
static bool IsSelectedOrSyncLockSelected(const Track &track)
static bool IsSyncLockSelected(const Track &track)
Abstract base class for an object holding data associated with points on a time axis.
Holds a msgid for the translation catalog; may also bind format arguments.
bool Append(constSamplePtr buffer, sampleFormat format, size_t len)
bool GetFloats(float *buffer, sampleCount start, size_t len, fillFormat fill=FillFormat::fillZero, bool mayThrow=true, sampleCount *pNumWithinClips=nullptr) const
"narrow" overload fetches from the unique channel
size_t GetBestBlockSize(sampleCount t) const
A hint for sizing of well aligned fetches.
size_t GetMaxBlockSize() const
A Track that contains audio waveform data.
Positions or offsets within audio files need a wide type.
const char * end(const char *str) noexcept
Externalized state of a plug-in.