28#include "../LabelTrack.h"
33#include "../widgets/NumericTextCtrl.h"
34#include "../widgets/valnum.h"
88{
XO(
"Change Speed and Pitch") };
104 Parameters().Reset(*
this);
111 mbLoopDetect =
false;
113 SetLinearEffectFlag(
true);
129 return XO(
"Changes the speed of a track, also changing its pitch");
134 return L
"Change_Speed";
182 const WaveTrack &track,
const double curT0,
const double curT1) ->
Gaps
187 const auto newGap = [&](
double st,
double et){
188 gaps.emplace_back(track.SnapToSample(st), track.SnapToSample(et));
191 auto clips = track.SortedIntervalArray();
192 auto front = clips.front();
193 auto back = clips.back();
194 for (
auto &clip : clips) {
195 auto st = clip->GetPlayStartTime();
196 auto et = clip->GetPlayEndTime();
197 if (st >= curT0 || et < curT1) {
198 if (curT0 < st && clip == front)
200 else if (last < st && curT0 <= last)
202 if (et < curT1 && clip == back)
218 bool bGoodResult =
true;
224 outputs.Get().Any().VisitWhile(bGoodResult,
231 [&](
auto &&fallthrough){
return [&](
WaveTrack &outWaveTrack) {
232 if (!outWaveTrack.GetSelected())
233 return fallthrough();
236 mCurT0 = outWaveTrack.GetStartTime();
237 mCurT1 = outWaveTrack.GetEndTime();
247 auto start = outWaveTrack.TimeToLongSamples(
mCurT0);
248 auto end = outWaveTrack.TimeToLongSamples(
mCurT1);
252 auto pNewTrack = outWaveTrack.EmptyCopy();
253 auto iter = pNewTrack->Channels().begin();
254 for (
const auto pChannel : outWaveTrack.Channels()) {
269 const double newLength = pNewTrack->GetEndTime();
274 *pNewTrack,
true,
true, &warper);
277 for (
const auto [st, et] : gaps)
279 outWaveTrack.SplitDelete(warper.Warp(st), warper.Warp(et));
320 S.StartVerticalLay(0);
323 S.StartMultiColumn(4, wxCENTER);
326 .Validator<FloatingPointValidator<double>>(
328 NumValidatorStyle::THREE_TRAILING_ZEROES,
330 .AddTextBox(
XXO(
"&Speed Multiplier:"), L
"", 12);
333 .Validator<FloatingPointValidator<double>>(
335 NumValidatorStyle::THREE_TRAILING_ZEROES,
337 .AddTextBox(
XXO(
"Percent C&hange:"), L
"", 12);
342 S.StartHorizontalLay(wxEXPAND);
345 .Name(
XO(
"Percent Change"))
346 .Style(wxSL_HORIZONTAL)
349 S.EndHorizontalLay();
352 S.StartMultiColumn(5, wxCENTER);
356 S.AddUnits(
XO(
"Standard Vinyl rpm:"));
362 .Name(
XO(
"From rpm"))
363 .MinSize( { 100, -1 } )
372 .MinSize( { 100, -1 } )
379 S.StartStatic(
XO(
"Selection Length"), 0);
381 S.StartMultiColumn(2, wxALIGN_LEFT);
383 S.AddPrompt(
XXO(
"C&urrent Length:"));
387 S.GetParent(), wxID_ANY,
393 .MenuEnabled(
false));
395 S.ToolTip(
XO(
"Current length of selection."))
397 .Name(
XC(
"from",
"change speed"))
398 .Position(wxALIGN_LEFT)
401 S.AddPrompt(
XXO(
"&New Length:"));
411 S.Name(
XC(
"to",
"change speed"))
412 .Position(wxALIGN_LEFT)
485 std::make_unique<LinearTimeWarper>(
mT0,
mT0,
500 auto len = (
end - start).as_double();
506 Floats inBuffer{ inBufferSize };
509 auto outBufferSize = size_t(
mFactor * inBufferSize + 10 );
510 Floats outBuffer{ outBufferSize };
518 auto samplePos = start;
519 while (samplePos <
end) {
527 track.
GetFloats(inBuffer.get(), samplePos, blockSize);
532 ((samplePos + blockSize) >=
end),
535 const auto outgen = results.second;
542 samplePos += results.first;
706 int unwarpedi = (int)(unwarped + 0.5);
707 unwarpedi = std::min<int>(unwarpedi, (
int)
kSliderMax);
static const double kSliderMax
static const TranslatableStrings kVinylStrings
static const double kSliderWarp
const RegistryPath & CurrentSettingsGroup()
Component of a configuration key path, for last-used destructive settings.
std::optional< std::unique_ptr< EffectSettingsAccess::Message > > OptionalMessage
XXO("&Cut/Copy/Paste Toolbar")
EVT_COMMAND(wxID_ANY, EVT_FREQUENCYTEXTCTRL_UPDATED, LabelDialog::OnFreqUpdate) LabelDialog
const NumericConverterType & NumericConverterType_TIME()
size_t limitSampleBufferSize(size_t bufferSize, sampleCount limit)
Contains declarations for TimeWarper, IdentityTimeWarper, ShiftTimeWarper, LinearTimeWarper,...
static Settings & settings()
std::vector< TranslatableString > TranslatableStrings
Generates EffectParameterMethods overrides from variadic template arguments.
ComponentInterfaceSymbol pairs a persistent string identifier used internally with an optional,...
const wxString & Internal() const
std::shared_ptr< TrackList > mTracks
An Effect that affects both pitch & speed.
void OnText_PercentChange(wxCommandEvent &evt)
NumericTextCtrl * mpToLengthCtrl
EffectType GetType() const override
Type determines how it behaves.
bool CheckWhetherSkipEffect(const EffectSettings &settings) const override
After Init(), tell whether Process() should be skipped.
virtual ~EffectChangeSpeed()
static const ComponentInterfaceSymbol Symbol
OptionalMessage LoadFactoryDefaults(EffectSettings &settings) const override
void OnChoice_Vinyl(wxCommandEvent &evt)
void OnText_Multiplier(wxCommandEvent &evt)
bool TransferDataToWindow(const EffectSettings &settings) override
void Update_Slider_PercentChange()
OptionalMessage DoLoadFactoryDefaults(EffectSettings &settings)
std::unique_ptr< EffectEditor > PopulateOrExchange(ShuttleGui &S, EffectInstance &instance, EffectSettingsAccess &access, const EffectOutputs *pOutputs) override
Add controls to effect panel; always succeeds.
wxTextCtrl * mpTextCtrl_Multiplier
void Update_TimeCtrl_ToLength()
wxChoice * mpChoice_ToVinyl
wxTextCtrl * mpTextCtrl_PercentChange
const EffectParameterMethods & Parameters() const override
Gaps FindGaps(const WaveTrack &track, const double curT0, const double curT1)
bool ProcessOne(const WaveChannel &track, WaveChannel &outputTrack, sampleCount start, sampleCount end)
wxWeakRef< wxWindow > mUIParent
void Update_Text_PercentChange()
bool Process(EffectInstance &instance, EffectSettings &settings) override
wxChoice * mpChoice_FromVinyl
void OnTimeCtrl_ToLength(wxCommandEvent &evt)
void Update_Text_Multiplier()
void OnSlider_PercentChange(wxCommandEvent &evt)
ComponentInterfaceSymbol GetSymbol() const override
ManualPageID ManualPage() const override
Name of a page in the Audacity alpha manual, default is empty.
bool TransferDataFromWindow(EffectSettings &settings) override
void OnTimeCtrlUpdate(wxCommandEvent &evt)
static constexpr EffectParameter Percentage
bool ProcessLabelTrack(LabelTrack *t)
wxSlider * mpSlider_PercentChange
double CalcPreviewInputLength(const EffectSettings &settings, double previewLength) const override
TranslatableString GetDescription() const override
NumericTextCtrl * mpFromLengthCtrl
static bool EnableApply(wxWindow *parent, bool enable=true)
Enable or disable the Apply button of the dialog that contains parent.
const EffectSettingsManager & GetDefinition() const override
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.
Hold values to send to effect output meters.
Interface for manipulations of an Effect's settings.
static FormatterContext SampleRateContext(double sampleRate)
const wxString & GET() const
Explicit conversion to wxString, meant to be ugly-looking and demanding of a comment why it's correct...
A LabelTrack is a Track that holds labels (LabelStruct).
void WarpLabels(const TimeWarper &warper)
Linear scaling, initialised by giving two points on the line.
bool SetFormatName(const NumericFormatID &formatName)
void SetValue(double newValue)
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.
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI.
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.
bool SetConfig(const EffectDefinitionInterface &ident, ConfigurationType type, const RegistryPath &group, const RegistryPath &key, const Value &value)
bool GetConfig(const EffectDefinitionInterface &ident, ConfigurationType type, const RegistryPath &group, const RegistryPath &key, Value &var, const Value &defval)
BuiltinEffectsModule::Registration< EffectChangeSpeed > reg
const char * end(const char *str) noexcept
const Type min
Minimum value.
const Type max
Maximum value.
Externalized state of a plug-in.
Options & ReadOnly(bool enable)