27#include "../LabelTrack.h"
32#include "../widgets/NumericTextCtrl.h"
33#include "../widgets/valnum.h"
87{
XO(
"Change Speed") };
103 Parameters().Reset(*
this);
110 mbLoopDetect =
false;
112 SetLinearEffectFlag(
true);
128 return XO(
"Changes the speed of a track, also changing its pitch");
133 return L
"Change_Speed";
188 bool bGoodResult =
true;
205 return fallthrough();
264 S.StartVerticalLay(0);
267 S.AddTitle(
XO(
"Change Speed, affecting both Tempo and Pitch"));
271 S.StartMultiColumn(4, wxCENTER);
274 .Validator<FloatingPointValidator<double>>(
276 NumValidatorStyle::THREE_TRAILING_ZEROES,
278 .AddTextBox(
XXO(
"&Speed Multiplier:"), L
"", 12);
281 .Validator<FloatingPointValidator<double>>(
283 NumValidatorStyle::THREE_TRAILING_ZEROES,
285 .AddTextBox(
XXO(
"Percent C&hange:"), L
"", 12);
290 S.StartHorizontalLay(wxEXPAND);
293 .Name(
XO(
"Percent Change"))
294 .Style(wxSL_HORIZONTAL)
297 S.EndHorizontalLay();
300 S.StartMultiColumn(5, wxCENTER);
304 S.AddUnits(
XO(
"Standard Vinyl rpm:"));
310 .Name(
XO(
"From rpm"))
311 .MinSize( { 100, -1 } )
320 .MinSize( { 100, -1 } )
327 S.StartStatic(
XO(
"Selection Length"), 0);
329 S.StartMultiColumn(2, wxALIGN_LEFT);
331 S.AddPrompt(
XXO(
"C&urrent Length:"));
335 S.GetParent(), wxID_ANY,
341 .MenuEnabled(
false));
343 S.ToolTip(
XO(
"Current length of selection."))
345 .Name(
XC(
"from",
"change speed"))
346 .Position(wxALIGN_LEFT)
349 S.AddPrompt(
XXO(
"&New Length:"));
359 S.Name(
XC(
"to",
"change speed"))
360 .Position(wxALIGN_LEFT)
433 std::make_unique<LinearTimeWarper>(
mT0,
mT0,
456 auto len = (
end - start).as_double();
462 Floats inBuffer{ inBufferSize };
465 auto outBufferSize = size_t(
mFactor * inBufferSize + 10 );
466 Floats outBuffer{ outBufferSize };
474 auto samplePos = start;
475 while (samplePos <
end) {
483 track->
GetFloats(inBuffer.get(), samplePos, blockSize);
488 ((samplePos + blockSize) >=
end),
491 const auto outgen = results.second;
498 samplePos += results.first;
508 outputTrack->Flush();
512 double newLength = outputTrack->GetEndTime();
517 std::vector<std::pair<double, double>> gaps;
520 auto front = clips.front();
521 auto back = clips.back();
522 for (
auto &clip : clips) {
523 auto st = clip->GetPlayStartTime();
524 auto et = clip->GetPlayEndTime();
527 if (
mCurT0 < st && clip == front) {
528 gaps.push_back(std::make_pair(
mCurT0, st));
530 else if (last < st &&
mCurT0 <= last ) {
531 gaps.push_back(std::make_pair(last, st));
534 if (et <
mCurT1 && clip == back) {
535 gaps.push_back(std::make_pair(et,
mCurT1));
547 for (
auto gap : gaps) {
552 track->
SplitDelete(warper.Warp(st), warper.Warp(et));
715 int unwarpedi = (int)(unwarped + 0.5);
716 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 > mOutputTracks
void ReplaceProcessedTracks(const bool bGoodResult)
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
bool ProcessOne(WaveTrack *t, sampleCount start, sampleCount end)
void Update_TimeCtrl_ToLength()
wxChoice * mpChoice_ToVinyl
wxTextCtrl * mpTextCtrl_PercentChange
const EffectParameterMethods & Parameters() const override
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.
NumericFormatSymbol mFormat
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
void CopyInputTracks(bool allSyncLockSelected=false)
bool TrackProgress(int whichTrack, double frac, const TranslatableString &={}) const
Performs effect computation.
Hold values to send to effect output meters.
Interface for manipulations of an Effect's settings.
static FormatterContext SampleRateContext(double sampleRate)
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 NumericFormatSymbol &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, float *inBuffer, size_t inBufferLen, bool lastFlag, float *outBuffer, size_t outBufferLen)
Main processing function. Resamples from the input buffer to the output buffer.
bool GetFloats(float *buffer, sampleCount start, size_t len, fillFormat fill=fillZero, bool mayThrow=true, sampleCount *pNumWithinClips=nullptr) const
Retrieve samples from a track in floating-point format, regardless of the storage format.
double LongSamplesToTime(sampleCount pos) const
Convert correctly between a number of samples and an (absolute) time in seconds.
sampleCount TimeToLongSamples(double t0) const
Convert correctly between an (absolute) time in seconds and a number of samples.
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI.
static bool IsSelectedOrSyncLockSelected(const Track *pTrack)
static bool IsSyncLockSelected(const Track *pTrack)
Abstract base class for an object holding data associated with points on a time axis.
bool GetSelected() const
Selectedness is always the same for all channels of a group.
Continuation<> Fallthrough
Type of arguments passed as optional second parameter to TypeSwitch<void>() cases.
Holds a msgid for the translation catalog; may also bind format arguments.
A Track that contains audio waveform data.
void SplitDelete(double t0, double t1)
double GetStartTime() const override
Get the time at which the first clip in the track starts.
size_t GetMaxBlockSize() const override
This returns a nonnegative number of samples meant to size a memory buffer.
size_t GetBestBlockSize(sampleCount t) const override
This returns a nonnegative number of samples meant to size a memory buffer.
WaveClipPointers SortedClipArray()
double GetEndTime() const override
Get the time at which the last clip in the track ends, plus recorded stuff.
void ClearAndPaste(double t0, double t1, const Track *src, bool preserve=true, bool merge=true, const TimeWarper *effectWarper=NULL)
Holder EmptyCopy(const SampleBlockFactoryPtr &pFactory={}, bool keepLink=true) const
Positions or offsets within audio files need a wide type.
auto end(const Ptr< Type, BaseDeleter > &p)
Enables range-for.
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 Type min
Minimum value.
const Type max
Maximum value.
Externalized state of a plug-in.
Options & ReadOnly(bool enable)