Audacity 3.2.0
Public Member Functions | Static Public Member Functions | Static Public Attributes | Private Types | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
EffectChangeSpeed Class Referencefinal

An Effect that affects both pitch & speed. More...

#include <ChangeSpeed.h>

Inheritance diagram for EffectChangeSpeed:
[legend]
Collaboration diagram for EffectChangeSpeed:
[legend]

Public Member Functions

 EffectChangeSpeed ()
 
virtual ~EffectChangeSpeed ()
 
ComponentInterfaceSymbol GetSymbol () const override
 
TranslatableString GetDescription () const override
 
ManualPageID ManualPage () const override
 Name of a page in the Audacity alpha manual, default is empty. More...
 
EffectType GetType () const override
 Type determines how it behaves. More...
 
OptionalMessage LoadFactoryDefaults (EffectSettings &settings) const override
 
OptionalMessage DoLoadFactoryDefaults (EffectSettings &settings)
 
bool CheckWhetherSkipEffect (const EffectSettings &settings) const override
 After Init(), tell whether Process() should be skipped. More...
 
double CalcPreviewInputLength (const EffectSettings &settings, double previewLength) const override
 
bool Init () override
 
bool Process (EffectInstance &instance, EffectSettings &settings) override
 
std::unique_ptr< EffectEditorPopulateOrExchange (ShuttleGui &S, EffectInstance &instance, EffectSettingsAccess &access, const EffectOutputs *pOutputs) override
 Add controls to effect panel; always succeeds. More...
 
bool TransferDataToWindow (const EffectSettings &settings) override
 
bool TransferDataFromWindow (EffectSettings &settings) override
 
- Public Member Functions inherited from StatefulEffect
 ~StatefulEffect () override
 
std::shared_ptr< EffectInstanceMakeInstance () const override
 Make an object maintaining short-term state of an Effect. More...
 
- Public Member Functions inherited from StatefulEffectBase
virtual bool Init ()
 
virtual bool Process (EffectInstance &instance, EffectSettings &settings)=0
 
virtual bool RealtimeInitialize (EffectSettings &settings, double sampleRate)
 
virtual bool RealtimeAddProcessor (EffectSettings &settings, EffectOutputs *pOutputs, unsigned numChannels, float sampleRate)
 
virtual bool RealtimeSuspend ()
 
virtual bool RealtimeResume ()
 
virtual bool RealtimeProcessStart (MessagePackage &package)
 settings are possibly changed, since last call, by an asynchronous dialog More...
 
virtual size_t RealtimeProcess (size_t group, EffectSettings &settings, const float *const *inBuf, float *const *outBuf, size_t numSamples)
 
virtual bool RealtimeProcessEnd (EffectSettings &settings) noexcept
 settings can be updated to let a dialog change appearance at idle More...
 
virtual bool RealtimeFinalize (EffectSettings &settings) noexcept
 
virtual size_t SetBlockSize (size_t maxBlockSize)
 
virtual size_t GetBlockSize () const
 
virtual unsigned GetAudioInCount () const
 How many input buffers to allocate at once. More...
 
virtual unsigned GetAudioOutCount () const
 How many output buffers to allocate at once. More...
 
virtual sampleCount GetLatency () const
 
virtual bool NeedsDither () const
 
virtual bool ProcessInitialize (EffectSettings &settings, double sampleRate, ChannelNames chanMap=nullptr)
 
virtual bool ProcessFinalize () noexcept
 
- Public Member Functions inherited from Effect
 Effect ()
 
virtual ~Effect ()
 
PluginPath GetPath () const override
 
bool VisitSettings (SettingsVisitor &visitor, EffectSettings &settings) override
 
bool VisitSettings (ConstSettingsVisitor &visitor, const EffectSettings &settings) const override
 
ComponentInterfaceSymbol GetSymbol () const override
 
VendorSymbol GetVendor () const override
 
wxString GetVersion () const override
 
TranslatableString GetDescription () const override
 
EffectFamilySymbol GetFamily () const override
 Report identifier and user-visible name of the effect protocol. More...
 
bool IsInteractive () const override
 Whether the effect needs a dialog for entry of settings. More...
 
bool IsDefault () const override
 Whether the effect sorts "above the line" in the menus. More...
 
RealtimeSince RealtimeSupport () const override
 Since which version of Audacity has the effect supported realtime? More...
 
bool SupportsAutomation () const override
 Whether the effect has any automatable controls. More...
 
bool SaveSettings (const EffectSettings &settings, CommandParameters &parms) const override
 Store settings as keys and values. More...
 
bool LoadSettings (const CommandParameters &parms, EffectSettings &settings) const override
 Restore settings from keys and values. More...
 
OptionalMessage LoadUserPreset (const RegistryPath &name, EffectSettings &settings) const override
 
bool SaveUserPreset (const RegistryPath &name, const EffectSettings &settings) const override
 Save settings in the configuration file as a user-named preset. More...
 
RegistryPaths GetFactoryPresets () const override
 Report names of factory presets. More...
 
OptionalMessage LoadFactoryPreset (int id, EffectSettings &settings) const override
 
OptionalMessage LoadFactoryDefaults (EffectSettings &settings) const override
 
virtual const EffectParameterMethodsParameters () const
 
bool CanExportPresets () const override
 Whether the effect supports export of presets to files, and importing too. More...
 
bool HasOptions () const override
 
const EffectSettingsManagerGetDefinition () const override
 
virtual NumericFormatID GetSelectionFormat ()
 
bool SaveSettingsAsString (const EffectSettings &settings, wxString &parms) const override
 
OptionalMessage LoadSettingsFromString (const wxString &parms, EffectSettings &settings) const override
 
bool IsBatchProcessing () const override
 
void SetBatchProcessing () override
 
void UnsetBatchProcessing () override
 
unsigned TestUIFlags (unsigned mask)
 
bool Delegate (Effect &delegate, EffectSettings &settings, InstanceFinder finder={})
 Re-invoke DoEffect on another Effect object that implements the work. More...
 
- Public Member Functions inherited from EffectBase
 EffectBase ()
 
 ~EffectBase () override
 
bool IsLinearEffect () const
 
bool PreviewsFullSelection () const
 
void SetTracks (TrackList *pTracks)
 
virtual std::any BeginPreview (const EffectSettings &settings)
 Called when Preview() starts, to allow temporary effect state changes. More...
 
bool DoEffect (EffectSettings &settings, const InstanceFinder &finder, double projectRate, TrackList *list, WaveTrackFactory *factory, NotifyingSelectedRegion &selectedRegion, unsigned flags, const EffectSettingsAccessPtr &pAccess) override
 
virtual double CalcPreviewInputLength (const EffectSettings &settings, double previewLength) const =0
 
void CountWaveTracks ()
 
- Public Member Functions inherited from EffectPlugin
EffectPluginoperator= (EffectPlugin &)=delete
 
virtual ~EffectPlugin ()
 
virtual bool HasOptions () const =0
 
virtual bool CanExportPresets () const =0
 Whether the effect supports export of presets to files, and importing too. More...
 
virtual const EffectSettingsManagerGetDefinition () const =0
 
virtual bool SaveSettingsAsString (const EffectSettings &settings, wxString &parms) const =0
 
virtual OptionalMessage LoadSettingsFromString (const wxString &parms, EffectSettings &settings) const =0
 
virtual bool IsBatchProcessing () const =0
 
virtual void SetBatchProcessing ()=0
 
virtual void UnsetBatchProcessing ()=0
 
virtual bool DoEffect (EffectSettings &settings, const InstanceFinder &finder, double projectRate, TrackList *list, WaveTrackFactory *factory, NotifyingSelectedRegion &selectedRegion, unsigned flags, const EffectSettingsAccessPtr &pAccess=nullptr)=0
 
- Public Member Functions inherited from EffectInstanceFactory
virtual ~EffectInstanceFactory ()
 
virtual std::shared_ptr< EffectInstanceMakeInstance () const =0
 Make an object maintaining short-term state of an Effect. More...
 
- Public Member Functions inherited from EffectSettingsManager
virtual ~EffectSettingsManager ()
 
virtual bool VisitSettings (SettingsVisitor &visitor, EffectSettings &settings)
 
virtual bool VisitSettings (ConstSettingsVisitor &visitor, const EffectSettings &settings) const
 
virtual EffectSettings MakeSettings () const
 
virtual bool CopySettingsContents (const EffectSettings &src, EffectSettings &dst) const
 Update one settings object from another. More...
 
virtual std::unique_ptr< EffectOutputsMakeOutputs () const
 Produce an object to hold values to send to effect output meters. More...
 
- Public Member Functions inherited from EffectDefinitionInterface
virtual ~EffectDefinitionInterface ()
 
virtual EffectType GetType () const =0
 Type determines how it behaves. More...
 
virtual EffectType GetClassification () const
 Determines which menu it appears in; default same as GetType(). More...
 
virtual EffectFamilySymbol GetFamily () const =0
 Report identifier and user-visible name of the effect protocol. More...
 
virtual bool IsInteractive () const =0
 Whether the effect needs a dialog for entry of settings. More...
 
virtual bool IsDefault () const =0
 Whether the effect sorts "above the line" in the menus. More...
 
virtual RealtimeSince RealtimeSupport () const =0
 Since which version of Audacity has the effect supported realtime? More...
 
bool SupportsRealtime () const
 
virtual bool SupportsAutomation () const =0
 Whether the effect has any automatable controls. More...
 
virtual bool EnablesDebug () const
 Whether the effect dialog should have a Debug button; default, always false. More...
 
virtual ManualPageID ManualPage () const
 Name of a page in the Audacity alpha manual, default is empty. More...
 
virtual FilePath HelpPage () const
 Fully qualified local help file name, default is empty. More...
 
virtual bool IsHiddenFromMenus () const
 Default is false. More...
 
- Public Member Functions inherited from ComponentInterface
virtual ~ComponentInterface ()
 
virtual PluginPath GetPath () const =0
 
virtual ComponentInterfaceSymbol GetSymbol () const =0
 
virtual VendorSymbol GetVendor () const =0
 
virtual wxString GetVersion () const =0
 
virtual TranslatableString GetDescription () const =0
 
TranslatableString GetName () const
 
- Public Member Functions inherited from StatefulEffectUIServices
 ~StatefulEffectUIServices () override
 
std::unique_ptr< EffectEditorPopulateUI (const EffectPlugin &plugin, ShuttleGui &S, EffectInstance &instance, EffectSettingsAccess &access, const EffectOutputs *pOutputs) const override
 Allows PopulateOrExchange to return null. More...
 
virtual std::unique_ptr< EffectEditorPopulateOrExchange (ShuttleGui &S, EffectInstance &instance, EffectSettingsAccess &access, const EffectOutputs *pOutputs)
 Add controls to effect panel; always succeeds. More...
 
virtual bool TransferDataToWindow (const EffectSettings &settings)
 
virtual bool TransferDataFromWindow (EffectSettings &settings)
 
- Public Member Functions inherited from BasicEffectUIServices
int ShowClientInterface (const EffectPlugin &plugin, wxWindow &parent, wxDialog &dialog, EffectEditor *pEditor, bool forceModal) const override
 
void ExportPresets (const EffectPlugin &plugin, const EffectSettings &settings) const override
 
OptionalMessage ImportPresets (const EffectPlugin &plugin, EffectSettings &settings) const override
 
void ShowOptions (const EffectPlugin &plugin) const override
 
bool ValidateUI (const EffectPlugin &context, EffectSettings &) const override
 
bool CloseUI () const override
 
- Public Member Functions inherited from EffectUIServices
virtual ~EffectUIServices ()
 
virtual int ShowHostInterface (EffectBase &plugin, wxWindow &parent, const EffectDialogFactory &factory, std::shared_ptr< EffectInstance > &pInstance, EffectSettingsAccess &access, bool forceModal=false)
 
virtual int ShowClientInterface (const EffectPlugin &plugin, wxWindow &parent, wxDialog &dialog, EffectEditor *pEditor, bool forceModal=false) const =0
 
virtual std::unique_ptr< EffectEditorPopulateUI (const EffectPlugin &plugin, ShuttleGui &S, EffectInstance &instance, EffectSettingsAccess &access, const EffectOutputs *pOutputs) const =0
 Adds controls to a panel that is given as the parent window of S More...
 
virtual void ExportPresets (const EffectPlugin &plugin, const EffectSettings &settings) const =0
 
virtual OptionalMessage ImportPresets (const EffectPlugin &plugin, EffectSettings &settings) const =0
 
virtual void ShowOptions (const EffectPlugin &plugin) const =0
 
virtual bool ValidateUI (const EffectPlugin &context, EffectSettings &settings) const =0
 
virtual bool CloseUI () const =0
 

Static Public Member Functions

static EffectChangeSpeedFetchParameters (EffectChangeSpeed &e, EffectSettings &)
 
- Static Public Member Functions inherited from Effect
static EffectFetchParameters (Effect &e, EffectSettings &)
 
- Static Public Member Functions inherited from EffectBase
static std::optional< InstancePointerFindInstance (EffectPlugin &plugin)
 
static InstanceFinder DefaultInstanceFinder (EffectPlugin &plugin)
 
- Static Public Member Functions inherited from EffectDefinitionInterface
static Identifier GetSquashedName (const Identifier &ident)
 A utility that strips spaces and CamelCases a name. More...
 
- Static Public Member Functions inherited from EffectUIServices
static int DoMessageBox (const EffectPlugin &plugin, const TranslatableString &message, long style=DefaultMessageBoxStyle, const TranslatableString &titleStr={})
 

Static Public Attributes

static const ComponentInterfaceSymbol Symbol { XO("Change Speed and Pitch") }
 
- Static Public Attributes inherited from EffectPlugin
static const wxString kUserPresetIdent = wxT("User Preset:")
 
static const wxString kFactoryPresetIdent = wxT("Factory Preset:")
 
static const wxString kCurrentSettingsIdent = wxT("<Current Settings>")
 
static const wxString kFactoryDefaultsIdent = wxT("<Factory Defaults>")
 

Private Types

using Gap = std::pair< double, double >
 
using Gaps = std::vector< Gap >
 

Private Member Functions

Gaps FindGaps (const WaveTrack &track, const double curT0, const double curT1)
 
bool ProcessOne (const WaveChannel &track, WaveChannel &outputTrack, sampleCount start, sampleCount end)
 
bool ProcessLabelTrack (LabelTrack *t)
 
void OnText_PercentChange (wxCommandEvent &evt)
 
void OnText_Multiplier (wxCommandEvent &evt)
 
void OnSlider_PercentChange (wxCommandEvent &evt)
 
void OnChoice_Vinyl (wxCommandEvent &evt)
 
void OnTimeCtrl_ToLength (wxCommandEvent &evt)
 
void OnTimeCtrlUpdate (wxCommandEvent &evt)
 
void Update_Text_PercentChange ()
 
void Update_Text_Multiplier ()
 
void Update_Slider_PercentChange ()
 
void Update_Vinyl ()
 
void Update_TimeCtrl_ToLength ()
 
void UpdateUI ()
 
const EffectParameterMethodsParameters () const override
 

Private Attributes

wxWeakRef< wxWindow > mUIParent {}
 
int mCurTrackNum
 
double mCurT0
 
double mCurT1
 
double m_PercentChange
 
int mFromVinyl
 
double mFactor
 
double mFromLength
 
int mTimeCtrlFormat
 
double mMultiplier
 
bool mbLoopDetect
 
wxTextCtrl * mpTextCtrl_PercentChange
 
wxTextCtrl * mpTextCtrl_Multiplier
 
wxSlider * mpSlider_PercentChange
 
wxChoice * mpChoice_FromVinyl
 
wxChoice * mpChoice_ToVinyl
 
NumericTextCtrlmpFromLengthCtrl
 
NumericTextCtrlmpToLengthCtrl
 
double mRate
 
int mToVinyl
 
double mToLength
 
NumericFormatID mFormat
 

Static Private Attributes

static constexpr EffectParameter Percentage
 

Additional Inherited Members

- Public Types inherited from StatefulEffectBase
using MessagePackage = EffectInstance::MessagePackage
 
- Public Types inherited from EffectPlugin
using EffectSettingsAccessPtr = std::shared_ptr< EffectSettingsAccess >
 
using InstancePointer = std::shared_ptr< EffectInstanceEx >
 
using InstanceFinder = std::function< std::optional< InstancePointer >(EffectSettings &settings) >
 
- Public Types inherited from EffectDefinitionInterface
enum class  RealtimeSince : unsigned { Never , After_3_1 , Always }
 In which versions of Audacity was an effect realtime capable? More...
 
- Public Types inherited from EffectUIServices
enum  : long { DefaultMessageBoxStyle = wxOK | wxCENTRE }
 
- Public Attributes inherited from EffectBase
std::shared_ptr< TrackListmTracks {}
 
int mNumTracks {}
 
BasicUI::ProgressDialogmProgress {}
 
double mProjectRate {}
 
WaveTrackFactorymFactory {}
 
double mT0 {}
 
double mT1 {}
 
bool mIsPreview { false }
 
- Protected Member Functions inherited from Effect
bool CheckWhetherSkipEffect (const EffectSettings &settings) const override
 Default implementation returns false. More...
 
double CalcPreviewInputLength (const EffectSettings &settings, double previewLength) const override
 Default implementation returns previewLength More...
 
bool TotalProgress (double frac, const TranslatableString &={}) const
 
bool TrackProgress (int whichTrack, double frac, const TranslatableString &={}) const
 
bool TrackGroupProgress (int whichGroup, double frac, const TranslatableString &={}) const
 
int GetNumWaveTracks () const
 
int GetNumWaveGroups () const
 
void GetBounds (const WaveTrack &track, sampleCount *start, sampleCount *len)
 
- Protected Member Functions inherited from EffectBase
virtual bool CheckWhetherSkipEffect (const EffectSettings &settings) const =0
 After Init(), tell whether Process() should be skipped. More...
 
void SetLinearEffectFlag (bool linearEffectFlag)
 
void SetPreviewFullSelectionFlag (bool previewDurationFlag)
 
bool IsPreviewing () const
 
const TrackListinputTracks () const
 
const AudacityProjectFindProject () const
 
- Protected Attributes inherited from EffectBase
double mF0 {}
 
double mF1 {}
 
wxArrayString mPresetNames
 
unsigned mUIFlags { 0 }
 

Detailed Description

An Effect that affects both pitch & speed.

Definition at line 28 of file ChangeSpeed.h.

Member Typedef Documentation

◆ Gap

using EffectChangeSpeed::Gap = std::pair<double, double>
private

Definition at line 65 of file ChangeSpeed.h.

◆ Gaps

using EffectChangeSpeed::Gaps = std::vector<Gap>
private

Definition at line 66 of file ChangeSpeed.h.

Constructor & Destructor Documentation

◆ EffectChangeSpeed()

EffectChangeSpeed::EffectChangeSpeed ( )

Definition at line 102 of file ChangeSpeed.cpp.

103{
104 Parameters().Reset(*this);
105
108 mFromLength = 0.0;
109 mToLength = 0.0;
111 mbLoopDetect = false;
112
114}
@ kVinyl_33AndAThird
Definition: ChangeSpeed.cpp:55
const wxString & Internal() const
void SetLinearEffectFlag(bool linearEffectFlag)
Definition: EffectBase.cpp:210
NumericFormatID mFormat
Definition: ChangeSpeed.h:123
const EffectParameterMethods & Parameters() const override
Definition: ChangeSpeed.cpp:71
virtual void Reset(Effect &effect) const =0
NUMERIC_FORMATS_API NumericFormatSymbol DefaultSelectionFormat()

References NumericConverterFormats::DefaultSelectionFormat(), ComponentInterfaceSymbol::Internal(), and kVinyl_33AndAThird.

Referenced by Parameters().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ~EffectChangeSpeed()

EffectChangeSpeed::~EffectChangeSpeed ( )
virtual

Definition at line 116 of file ChangeSpeed.cpp.

117{
118}

Member Function Documentation

◆ CalcPreviewInputLength()

double EffectChangeSpeed::CalcPreviewInputLength ( const EffectSettings settings,
double  previewLength 
) const
overridevirtual

Implements EffectBase.

Definition at line 167 of file ChangeSpeed.cpp.

169{
170 return previewLength * (100.0 + m_PercentChange) / 100.0;
171}
double m_PercentChange
Definition: ChangeSpeed.h:99

References m_PercentChange.

◆ CheckWhetherSkipEffect()

bool EffectChangeSpeed::CheckWhetherSkipEffect ( const EffectSettings settings) const
overridevirtual

After Init(), tell whether Process() should be skipped.

Implements EffectBase.

Definition at line 162 of file ChangeSpeed.cpp.

163{
164 return (m_PercentChange == 0.0);
165}

References m_PercentChange.

◆ DoLoadFactoryDefaults()

OptionalMessage EffectChangeSpeed::DoLoadFactoryDefaults ( EffectSettings settings)

Definition at line 152 of file ChangeSpeed.cpp.

153{
156
158}
static Settings & settings()
Definition: TrackInfo.cpp:69
OptionalMessage LoadFactoryDefaults(EffectSettings &settings) const override
Definition: Effect.cpp:165

References NumericConverterFormats::DefaultSelectionFormat(), ComponentInterfaceSymbol::Internal(), kVinyl_33AndAThird, Effect::LoadFactoryDefaults(), mFormat, mFromVinyl, and settings().

Referenced by LoadFactoryDefaults().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ FetchParameters()

static EffectChangeSpeed * EffectChangeSpeed::FetchParameters ( EffectChangeSpeed e,
EffectSettings  
)
inlinestatic

Definition at line 32 of file ChangeSpeed.h.

32{ return &e; }

◆ FindGaps()

auto EffectChangeSpeed::FindGaps ( const WaveTrack track,
const double  curT0,
const double  curT1 
)
private

Definition at line 181 of file ChangeSpeed.cpp.

183{
184 // Silenced samples will be inserted in gaps between clips, so capture where
185 // these gaps are for later deletion
186 Gaps gaps;
187 const auto newGap = [&](double st, double et){
188 gaps.emplace_back(track.SnapToSample(st), track.SnapToSample(et));
189 };
190 double last = curT0;
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)
199 newGap(curT0, st);
200 else if (last < st && curT0 <= last)
201 newGap(last, st);
202 if (et < curT1 && clip == back)
203 newGap(et, curT1);
204 }
205 last = et;
206 }
207 return gaps;
208}
std::vector< Gap > Gaps
Definition: ChangeSpeed.h:66
IntervalHolders SortedIntervalArray()
Return all WaveClips sorted by clip play start time.
Definition: WaveTrack.cpp:3270
double SnapToSample(double t) const

Referenced by Process().

Here is the caller graph for this function:

◆ GetDescription()

TranslatableString EffectChangeSpeed::GetDescription ( ) const
overridevirtual

Implements ComponentInterface.

Definition at line 127 of file ChangeSpeed.cpp.

128{
129 return XO("Changes the speed of a track, also changing its pitch");
130}
XO("Cut/Copy/Paste")

References XO().

Here is the call graph for this function:

◆ GetSymbol()

ComponentInterfaceSymbol EffectChangeSpeed::GetSymbol ( ) const
overridevirtual

Implements ComponentInterface.

Definition at line 122 of file ChangeSpeed.cpp.

123{
124 return Symbol;
125}
static const ComponentInterfaceSymbol Symbol
Definition: ChangeSpeed.h:33

References Symbol.

◆ GetType()

EffectType EffectChangeSpeed::GetType ( ) const
overridevirtual

Type determines how it behaves.

Implements EffectDefinitionInterface.

Definition at line 140 of file ChangeSpeed.cpp.

141{
142 return EffectTypeProcess;
143}
@ EffectTypeProcess

References EffectTypeProcess.

Referenced by Process().

Here is the caller graph for this function:

◆ Init()

bool EffectChangeSpeed::Init ( )
overridevirtual

Default implementation does nothing, returns true

Reimplemented from StatefulEffectBase.

Definition at line 173 of file ChangeSpeed.cpp.

174{
175 // The selection might have changed since the last time EffectChangeSpeed
176 // was invoked, so recalculate the Length parameters.
177 mFromLength = mT1 - mT0;
178 return true;
179}
double mT1
Definition: EffectBase.h:114
double mT0
Definition: EffectBase.h:113

References mFromLength, EffectBase::mT0, and EffectBase::mT1.

◆ LoadFactoryDefaults()

OptionalMessage EffectChangeSpeed::LoadFactoryDefaults ( EffectSettings settings) const
overridevirtual

Change settings back to "factory default"

Returns
nullopt for failure

Implements EffectSettingsManager.

Definition at line 145 of file ChangeSpeed.cpp.

146{
147 // To do: externalize state so const_cast isn't needed
148 return const_cast<EffectChangeSpeed&>(*this).DoLoadFactoryDefaults(settings);
149}
An Effect that affects both pitch & speed.
Definition: ChangeSpeed.h:29
OptionalMessage DoLoadFactoryDefaults(EffectSettings &settings)

References DoLoadFactoryDefaults(), and settings().

Here is the call graph for this function:

◆ ManualPage()

ManualPageID EffectChangeSpeed::ManualPage ( ) const
overridevirtual

Name of a page in the Audacity alpha manual, default is empty.

Reimplemented from EffectDefinitionInterface.

Definition at line 132 of file ChangeSpeed.cpp.

133{
134 return L"Change_Speed";
135}

◆ OnChoice_Vinyl()

void EffectChangeSpeed::OnChoice_Vinyl ( wxCommandEvent &  evt)
private

Definition at line 608 of file ChangeSpeed.cpp.

609{
610 // Treat mpChoice_FromVinyl and mpChoice_ToVinyl as one control since we need
611 // both to calculate Percent Change.
612 mFromVinyl = mpChoice_FromVinyl->GetSelection();
613 mToVinyl = mpChoice_ToVinyl->GetSelection();
614 // Use this as the 'preferred' choice.
615 if (mFromVinyl != kVinyl_NA) {
617 CurrentSettingsGroup(), wxT("VinylChoice"), mFromVinyl);
618 }
619
620 // If mFromVinyl & mToVinyl are set, then there's a NEW percent change.
621 if ((mFromVinyl != kVinyl_NA) && (mToVinyl != kVinyl_NA))
622 {
623 double fromRPM;
624 double toRPM;
625 switch (mFromVinyl) {
626 default:
627 case kVinyl_33AndAThird: fromRPM = 33.0 + (1.0 / 3.0); break;
628 case kVinyl_45: fromRPM = 45.0; break;
629 case kVinyl_78: fromRPM = 78; break;
630 }
631 switch (mToVinyl) {
632 default:
633 case kVinyl_33AndAThird: toRPM = 33.0 + (1.0 / 3.0); break;
634 case kVinyl_45: toRPM = 45.0; break;
635 case kVinyl_78: toRPM = 78; break;
636 }
637 m_PercentChange = ((toRPM * 100.0) / fromRPM) - 100.0;
638 UpdateUI();
639
640 mbLoopDetect = true;
645 }
646 mbLoopDetect = false;
647}
wxT("CloseDown"))
@ kVinyl_78
Definition: ChangeSpeed.cpp:57
@ kVinyl_45
Definition: ChangeSpeed.cpp:56
@ kVinyl_NA
Definition: ChangeSpeed.cpp:58
const RegistryPath & CurrentSettingsGroup()
Component of a configuration key path, for last-used destructive settings.
void Update_Slider_PercentChange()
void Update_TimeCtrl_ToLength()
wxChoice * mpChoice_ToVinyl
Definition: ChangeSpeed.h:115
void Update_Text_PercentChange()
wxChoice * mpChoice_FromVinyl
Definition: ChangeSpeed.h:114
void Update_Text_Multiplier()
const EffectSettingsManager & GetDefinition() const override
Definition: Effect.cpp:182
bool SetConfig(const EffectDefinitionInterface &ident, ConfigurationType type, const RegistryPath &group, const RegistryPath &key, const Value &value)

References CurrentSettingsGroup(), Effect::GetDefinition(), kVinyl_33AndAThird, kVinyl_45, kVinyl_78, kVinyl_NA, m_PercentChange, mbLoopDetect, mFromVinyl, mpChoice_FromVinyl, mpChoice_ToVinyl, mToVinyl, PluginSettings::Private, PluginSettings::SetConfig(), Update_Slider_PercentChange(), Update_Text_Multiplier(), Update_Text_PercentChange(), Update_TimeCtrl_ToLength(), UpdateUI(), and wxT().

Here is the call graph for this function:

◆ OnSlider_PercentChange()

void EffectChangeSpeed::OnSlider_PercentChange ( wxCommandEvent &  evt)
private

Definition at line 589 of file ChangeSpeed.cpp.

590{
591 if (mbLoopDetect)
592 return;
593
594 m_PercentChange = (double)(mpSlider_PercentChange->GetValue());
595 // Warp positive values to actually go up faster & further than negatives.
596 if (m_PercentChange > 0.0)
598 UpdateUI();
599
600 mbLoopDetect = true;
603 Update_Vinyl();
605 mbLoopDetect = false;
606}
static const double kSliderWarp
Definition: ChangeSpeed.cpp:81
wxSlider * mpSlider_PercentChange
Definition: ChangeSpeed.h:113

References kSliderWarp, m_PercentChange, mbLoopDetect, mpSlider_PercentChange, Update_Text_Multiplier(), Update_Text_PercentChange(), Update_TimeCtrl_ToLength(), Update_Vinyl(), and UpdateUI().

Here is the call graph for this function:

◆ OnText_Multiplier()

void EffectChangeSpeed::OnText_Multiplier ( wxCommandEvent &  evt)
private

Definition at line 572 of file ChangeSpeed.cpp.

573{
574 if (mbLoopDetect)
575 return;
576
577 mpTextCtrl_Multiplier->GetValidator()->TransferFromWindow();
578 m_PercentChange = 100 * (mMultiplier - 1);
579 UpdateUI();
580
581 mbLoopDetect = true;
584 Update_Vinyl();
586 mbLoopDetect = false;
587}
wxTextCtrl * mpTextCtrl_Multiplier
Definition: ChangeSpeed.h:112

References m_PercentChange, mbLoopDetect, mMultiplier, mpTextCtrl_Multiplier, Update_Slider_PercentChange(), Update_Text_PercentChange(), Update_TimeCtrl_ToLength(), Update_Vinyl(), and UpdateUI().

Here is the call graph for this function:

◆ OnText_PercentChange()

void EffectChangeSpeed::OnText_PercentChange ( wxCommandEvent &  evt)
private

Definition at line 556 of file ChangeSpeed.cpp.

557{
558 if (mbLoopDetect)
559 return;
560
561 mpTextCtrl_PercentChange->GetValidator()->TransferFromWindow();
562 UpdateUI();
563
564 mbLoopDetect = true;
567 Update_Vinyl();
569 mbLoopDetect = false;
570}
wxTextCtrl * mpTextCtrl_PercentChange
Definition: ChangeSpeed.h:111

References mbLoopDetect, mpTextCtrl_PercentChange, Update_Slider_PercentChange(), Update_Text_Multiplier(), Update_TimeCtrl_ToLength(), Update_Vinyl(), and UpdateUI().

Here is the call graph for this function:

◆ OnTimeCtrl_ToLength()

void EffectChangeSpeed::OnTimeCtrl_ToLength ( wxCommandEvent &  evt)
private

Definition at line 649 of file ChangeSpeed.cpp.

650{
651 if (mbLoopDetect)
652 return;
653
655 // Division by (double) 0.0 is not an error and we want to show "infinite" in
656 // text controls, so take care that we handle infinite values when they occur.
657 m_PercentChange = ((mFromLength * 100.0) / mToLength) - 100.0;
658 UpdateUI();
659
660 mbLoopDetect = true;
661
665 Update_Vinyl();
666
667 mbLoopDetect = false;
668}
NumericTextCtrl * mpToLengthCtrl
Definition: ChangeSpeed.h:117

References NumericConverter::GetValue(), m_PercentChange, mbLoopDetect, mFromLength, mpToLengthCtrl, mToLength, Update_Slider_PercentChange(), Update_Text_Multiplier(), Update_Text_PercentChange(), Update_Vinyl(), and UpdateUI().

Here is the call graph for this function:

◆ OnTimeCtrlUpdate()

void EffectChangeSpeed::OnTimeCtrlUpdate ( wxCommandEvent &  evt)
private

Definition at line 670 of file ChangeSpeed.cpp.

671{
674 NumericConverterType_TIME(), evt.GetString()).Internal();
675
677 // Update From/To Length controls (precision has changed).
680}
const NumericConverterType & NumericConverterType_TIME()
double mProjectRate
Definition: EffectBase.h:110
NumericTextCtrl * mpFromLengthCtrl
Definition: ChangeSpeed.h:116
static FormatterContext SampleRateContext(double sampleRate)
bool SetFormatName(const NumericFormatID &formatName)
void SetValue(double newValue)
NUMERIC_FORMATS_API NumericFormatSymbol Lookup(const FormatterContext &context, const NumericConverterType &type, const NumericFormatID &formatIdentifier)
Looks up the format, returns Default for the type if the format is not registered.

References ComponentInterfaceSymbol::Internal(), NumericConverterFormats::Lookup(), mFormat, mFromLength, mpFromLengthCtrl, EffectBase::mProjectRate, mpToLengthCtrl, mToLength, NumericConverterType_TIME(), FormatterContext::SampleRateContext(), NumericTextCtrl::SetFormatName(), and NumericTextCtrl::SetValue().

Here is the call graph for this function:

◆ Parameters()

const EffectParameterMethods & EffectChangeSpeed::Parameters ( ) const
overrideprivatevirtual

Reimplemented from Effect.

Definition at line 71 of file ChangeSpeed.cpp.

72{
75 > parameters;
76 return parameters;
77}
Generates EffectParameterMethods overrides from variadic template arguments.
static constexpr EffectParameter Percentage
Definition: ChangeSpeed.h:128

References EffectChangeSpeed(), and Percentage.

Here is the call graph for this function:

◆ PopulateOrExchange()

std::unique_ptr< EffectEditor > EffectChangeSpeed::PopulateOrExchange ( ShuttleGui S,
EffectInstance instance,
EffectSettingsAccess access,
const EffectOutputs pOutputs 
)
overridevirtual

Add controls to effect panel; always succeeds.

Returns
if not null, then return it from PopulateUI instead of a DefaultEffectEditor; default implementation returns null

Reimplemented from StatefulEffectUIServices.

Definition at line 299 of file ChangeSpeed.cpp.

302{
303 mUIParent = S.GetParent();
304
305 {
306 wxString formatId;
309 wxT("TimeFormat"), formatId, mFormat.GET());
312 NumericConverterType_TIME(), formatId).Internal();
313 }
316 wxT("VinylChoice"), mFromVinyl, mFromVinyl);
317
318 S.SetBorder(5);
319
320 S.StartVerticalLay(0);
321 {
322 // Speed multiplier and percent change controls.
323 S.StartMultiColumn(4, wxCENTER);
324 {
326 .Validator<FloatingPointValidator<double>>(
327 3, &mMultiplier,
328 NumValidatorStyle::THREE_TRAILING_ZEROES,
329 Percentage.min / 100.0, ((Percentage.max / 100.0) + 1) )
330 .AddTextBox(XXO("&Speed Multiplier:"), L"", 12);
331
333 .Validator<FloatingPointValidator<double>>(
334 3, &m_PercentChange,
335 NumValidatorStyle::THREE_TRAILING_ZEROES,
337 .AddTextBox(XXO("Percent C&hange:"), L"", 12);
338 }
339 S.EndMultiColumn();
340
341 // Percent change slider.
342 S.StartHorizontalLay(wxEXPAND);
343 {
345 .Name(XO("Percent Change"))
346 .Style(wxSL_HORIZONTAL)
347 .AddSlider( {}, 0, (int)kSliderMax, (int)Percentage.min);
348 }
349 S.EndHorizontalLay();
350
351 // Vinyl rpm controls.
352 S.StartMultiColumn(5, wxCENTER);
353 {
354 /* i18n-hint: "rpm" is an English abbreviation meaning "revolutions per minute".
355 "vinyl" refers to old-fashioned phonograph records */
356 S.AddUnits(XO("Standard Vinyl rpm:"));
357
359 /* i18n-hint: changing speed of audio "from" one value "to" another
360 "rpm" means "revolutions per minute" as on a vinyl record turntable
361 */
362 .Name(XO("From rpm"))
363 .MinSize( { 100, -1 } )
364 /* i18n-hint: changing speed of audio "from" one value "to" another */
365 .AddChoice(XXC("&from", "change speed"), kVinylStrings);
366
368 /* i18n-hint: changing speed of audio "from" one value "to" another
369 "rpm" means "revolutions per minute" as on a vinyl record turntable
370 */
371 .Name(XO("To rpm"))
372 .MinSize( { 100, -1 } )
373 /* i18n-hint: changing speed of audio "from" one value "to" another */
374 .AddChoice(XXC("&to", "change speed"), kVinylStrings);
375 }
376 S.EndMultiColumn();
377
378 // From/To time controls.
379 S.StartStatic(XO("Selection Length"), 0);
380 {
381 S.StartMultiColumn(2, wxALIGN_LEFT);
382 {
383 S.AddPrompt(XXO("C&urrent Length:"));
384
387 S.GetParent(), wxID_ANY,
389 mFormat,
392 .ReadOnly(true)
393 .MenuEnabled(false));
394
395 S.ToolTip(XO("Current length of selection."))
396 /* i18n-hint: changing speed of audio "from" one value "to" another */
397 .Name(XC("from", "change speed"))
398 .Position(wxALIGN_LEFT)
399 .AddWindow(mpFromLengthCtrl);
400
401 S.AddPrompt(XXO("&New Length:"));
402
405 S.GetParent(), ID_ToLength,
407 mFormat,
408 mToLength);
409
410 /* i18n-hint: changing speed of audio "from" one value "to" another */
411 S.Name(XC("to", "change speed"))
412 .Position(wxALIGN_LEFT)
413 .AddWindow(mpToLengthCtrl);
414 }
415 S.EndMultiColumn();
416 }
417 S.EndStatic();
418 }
419 S.EndVerticalLay();
420 return nullptr;
421}
@ ID_ToLength
Definition: ChangeSpeed.cpp:48
@ ID_FromVinyl
Definition: ChangeSpeed.cpp:46
@ ID_ToVinyl
Definition: ChangeSpeed.cpp:47
@ ID_Multiplier
Definition: ChangeSpeed.cpp:45
@ ID_PercentChange
Definition: ChangeSpeed.cpp:44
static const double kSliderMax
Definition: ChangeSpeed.cpp:80
static const TranslatableStrings kVinylStrings
Definition: ChangeSpeed.cpp:61
XXO("&Cut/Copy/Paste Toolbar")
#define XXC(s, c)
Definition: Internat.h:47
#define XC(s, c)
Definition: Internat.h:37
#define safenew
Definition: MemoryX.h:9
#define S(N)
Definition: ToChars.cpp:64
wxWeakRef< wxWindow > mUIParent
Definition: ChangeSpeed.h:91
const wxString & GET() const
Explicit conversion to wxString, meant to be ugly-looking and demanding of a comment why it's correct...
Definition: Identifier.h:66
bool GetConfig(const EffectDefinitionInterface &ident, ConfigurationType type, const RegistryPath &group, const RegistryPath &key, Value &var, const Value &defval)
const Type min
Minimum value.
const Type max
Maximum value.
Options & ReadOnly(bool enable)

References CurrentSettingsGroup(), Identifier::GET(), PluginSettings::GetConfig(), Effect::GetDefinition(), ID_FromVinyl, ID_Multiplier, ID_PercentChange, ID_ToLength, ID_ToVinyl, ComponentInterfaceSymbol::Internal(), kSliderMax, kVinylStrings, NumericConverterFormats::Lookup(), m_PercentChange, EffectParameter< Structure, Member, Type, Value >::max, mFormat, mFromLength, mFromVinyl, EffectParameter< Structure, Member, Type, Value >::min, mMultiplier, mpChoice_FromVinyl, mpChoice_ToVinyl, mpFromLengthCtrl, EffectBase::mProjectRate, mpSlider_PercentChange, mpTextCtrl_Multiplier, mpTextCtrl_PercentChange, mpToLengthCtrl, mToLength, mUIParent, NumericConverterType_TIME(), Percentage, PluginSettings::Private, NumericTextCtrl::Options::ReadOnly(), S, safenew, FormatterContext::SampleRateContext(), wxT(), XC, XO(), XXC, and XXO().

Here is the call graph for this function:

◆ Process()

bool EffectChangeSpeed::Process ( EffectInstance instance,
EffectSettings settings 
)
overridevirtual

Implements StatefulEffectBase.

Definition at line 210 of file ChangeSpeed.cpp.

211{
212 // Similar to EffectSoundTouch::Process()
213
214 // Iterate over each track.
215 // All needed because this effect needs to introduce
216 // silence in the sync-lock group tracks to keep sync
217 EffectOutputTracks outputs { *mTracks, GetType(), { { mT0, mT1 } }, true };
218 bool bGoodResult = true;
219
220 mCurTrackNum = 0;
221
222 mFactor = 100.0 / (100.0 + m_PercentChange);
223
224 outputs.Get().Any().VisitWhile(bGoodResult,
225 [&](LabelTrack &lt) {
227 if (!ProcessLabelTrack(&lt))
228 bGoodResult = false;
229 }
230 },
231 [&](auto &&fallthrough){ return [&](WaveTrack &outWaveTrack) {
232 if (!outWaveTrack.GetSelected())
233 return fallthrough();
234
235 //Get start and end times from track
236 mCurT0 = outWaveTrack.GetStartTime();
237 mCurT1 = outWaveTrack.GetEndTime();
238
239 //Set the current bounds to whichever left marker is
240 //greater and whichever right marker is less:
241 mCurT0 = std::max(mT0, mCurT0);
243
244 // Process only if the right marker is to the right of the left marker
245 if (mCurT1 > mCurT0) {
246 //Transform the marker timepoints to samples
247 auto start = outWaveTrack.TimeToLongSamples(mCurT0);
248 auto end = outWaveTrack.TimeToLongSamples(mCurT1);
249
250 const auto gaps = FindGaps(outWaveTrack, mCurT0, mCurT1);
251
252 auto pNewTrack = outWaveTrack.EmptyCopy();
253 auto iter = pNewTrack->Channels().begin();
254 for (const auto pChannel : outWaveTrack.Channels()) {
255 // ProcessOne() (implemented below) processes a single channel
256 if (ProcessOne(*pChannel, **iter++, start, end))
257 ++mCurTrackNum;
258 else {
259 pNewTrack.reset();
260 break;
261 }
262 }
263 if (!pNewTrack) {
264 bGoodResult = false;
265 return;
266 }
267 pNewTrack->Flush();
268
269 const double newLength = pNewTrack->GetEndTime();
270 const LinearTimeWarper warper{
271 mCurT0, mCurT0, mCurT1, mCurT0 + newLength };
272
273 outWaveTrack.ClearAndPaste(mCurT0, mCurT1,
274 *pNewTrack, true, true, &warper);
275
276 // Finally, recreate the gaps
277 for (const auto [st, et] : gaps)
278 if (st >= mCurT0 && et <= mCurT1 && st != et)
279 outWaveTrack.SplitDelete(warper.Warp(st), warper.Warp(et));
280 }
281 else
282 mCurTrackNum += outWaveTrack.NChannels();
283 }; },
284 [&](Track &t) {
286 t.SyncLockAdjust(mT1, mT0 + (mT1 - mT0) * mFactor);
287 }
288 );
289
290 if (bGoodResult)
291 outputs.Commit();
292
293 // Update selection.
294 mT1 = mT0 + (((mT1 - mT0) * 100.0) / (100.0 + m_PercentChange));
295
296 return bGoodResult;
297}
int min(int a, int b)
std::shared_ptr< TrackList > mTracks
Definition: EffectBase.h:107
EffectType GetType() const override
Type determines how it behaves.
Gaps FindGaps(const WaveTrack &track, const double curT0, const double curT1)
bool ProcessOne(const WaveChannel &track, WaveChannel &outputTrack, sampleCount start, sampleCount end)
bool ProcessLabelTrack(LabelTrack *t)
Use this object to copy the input tracks to tentative outputTracks.
A LabelTrack is a Track that holds labels (LabelStruct).
Definition: LabelTrack.h:95
Linear scaling, initialised by giving two points on the line.
Definition: TimeWarper.h:87
static bool IsSelectedOrSyncLockSelected(const Track &track)
Definition: SyncLock.cpp:104
static bool IsSyncLockSelected(const Track &track)
Definition: SyncLock.cpp:80
Abstract base class for an object holding data associated with points on a time axis.
Definition: Track.h:110
A Track that contains audio waveform data.
Definition: WaveTrack.h:203
const char * end(const char *str) noexcept
Definition: StringUtils.h:106

References details::end(), FindGaps(), GetType(), SyncLock::IsSelectedOrSyncLockSelected(), SyncLock::IsSyncLockSelected(), m_PercentChange, mCurT0, mCurT1, mCurTrackNum, mFactor, min(), EffectBase::mT0, EffectBase::mT1, EffectBase::mTracks, ProcessLabelTrack(), and ProcessOne().

Here is the call graph for this function:

◆ ProcessLabelTrack()

bool EffectChangeSpeed::ProcessLabelTrack ( LabelTrack t)
private

Definition at line 482 of file ChangeSpeed.cpp.

483{
484 RegionTimeWarper warper { mT0, mT1,
485 std::make_unique<LinearTimeWarper>(mT0, mT0,
486 mT1, mT0 + (mT1-mT0)*mFactor) };
487 lt->WarpLabels(warper);
488 return true;
489}
No change before the specified region; during the region, warp according to the given warper; after t...
Definition: TimeWarper.h:192

References mFactor, EffectBase::mT0, EffectBase::mT1, and LabelTrack::WarpLabels().

Referenced by Process().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ProcessOne()

bool EffectChangeSpeed::ProcessOne ( const WaveChannel track,
WaveChannel outputTrack,
sampleCount  start,
sampleCount  end 
)
private

Definition at line 493 of file ChangeSpeed.cpp.

496{
497 //Get the length of the selection (as double). len is
498 //used simple to calculate a progress meter, so it is easier
499 //to make it a double now than it is to do it later
500 auto len = (end - start).as_double();
501
502 // Initiate processing buffers, most likely shorter than
503 // the length of the selection being processed.
504 auto inBufferSize = track.GetMaxBlockSize();
505
506 Floats inBuffer{ inBufferSize };
507
508 // mFactor is at most 100-fold so this shouldn't overflow size_t
509 auto outBufferSize = size_t( mFactor * inBufferSize + 10 );
510 Floats outBuffer{ outBufferSize };
511
512 // Set up the resampling stuff for this track.
513 Resample resample(true, mFactor, mFactor); // constant rate resampling
514
515 //Go through the track one buffer at a time. samplePos counts which
516 //sample the current buffer starts at.
517 bool bResult = true;
518 auto samplePos = start;
519 while (samplePos < end) {
520 //Get a blockSize of samples (smaller than the size of the buffer)
521 auto blockSize = limitSampleBufferSize(
522 track.GetBestBlockSize(samplePos),
523 end - samplePos
524 );
525
526 //Get the samples from the track and put them in the buffer
527 track.GetFloats(inBuffer.get(), samplePos, blockSize);
528
529 const auto results = resample.Process(mFactor,
530 inBuffer.get(),
531 blockSize,
532 ((samplePos + blockSize) >= end),
533 outBuffer.get(),
534 outBufferSize);
535 const auto outgen = results.second;
536
537 if (outgen > 0)
538 outputTrack.Append((samplePtr)outBuffer.get(), floatSample,
539 outgen);
540
541 // Increment samplePos
542 samplePos += results.first;
543
544 // Update the Progress meter
545 if (TrackProgress(mCurTrackNum, (samplePos - start).as_double() / len)) {
546 bResult = false;
547 break;
548 }
549 }
550
551 return bResult;
552}
size_t limitSampleBufferSize(size_t bufferSize, sampleCount limit)
Definition: SampleCount.cpp:22
char * samplePtr
Definition: SampleFormat.h:57
bool TrackProgress(int whichTrack, double frac, const TranslatableString &={}) const
Definition: Effect.cpp:343
Interface to libsoxr.
Definition: Resample.h:27
bool Append(constSamplePtr buffer, sampleFormat format, size_t len)
Definition: WaveTrack.cpp:2216
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
Definition: WaveTrack.h:129
size_t GetBestBlockSize(sampleCount t) const
A hint for sizing of well aligned fetches.
Definition: WaveTrack.h:850
size_t GetMaxBlockSize() const
Definition: WaveTrack.h:858

References WaveChannel::Append(), details::end(), floatSample, WaveChannel::GetBestBlockSize(), WaveChannel::GetFloats(), WaveChannel::GetMaxBlockSize(), limitSampleBufferSize(), mCurTrackNum, mFactor, Resample::Process(), and Effect::TrackProgress().

Referenced by Process().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ TransferDataFromWindow()

bool EffectChangeSpeed::TransferDataFromWindow ( EffectSettings settings)
overridevirtual

Update the given settings from controls; default does nothing, returns true

Reimplemented from StatefulEffectUIServices.

Definition at line 459 of file ChangeSpeed.cpp.

460{
461 // mUIParent->TransferDataFromWindow() loses some precision, so save and restore it.
462 double exactPercent = m_PercentChange;
463 if (!mUIParent->Validate() || !mUIParent->TransferDataFromWindow())
464 {
465 return false;
466 }
467 m_PercentChange = exactPercent;
468
469 // TODO: just visit these effect settings the default way
471 CurrentSettingsGroup(), wxT("TimeFormat"), mFormat.GET());
473 CurrentSettingsGroup(), wxT("VinylChoice"), mFromVinyl);
474
475 return true;
476}

References CurrentSettingsGroup(), Identifier::GET(), Effect::GetDefinition(), m_PercentChange, mFormat, mFromVinyl, mUIParent, PluginSettings::Private, PluginSettings::SetConfig(), and wxT().

Here is the call graph for this function:

◆ TransferDataToWindow()

bool EffectChangeSpeed::TransferDataToWindow ( const EffectSettings settings)
overridevirtual

Update controls for the settings; default does nothing, returns true

Reimplemented from StatefulEffectUIServices.

Definition at line 423 of file ChangeSpeed.cpp.

424{
425 mbLoopDetect = true;
426
427 if (!mUIParent->TransferDataToWindow())
428 {
429 return false;
430 }
431
432 if (mFromVinyl == kVinyl_NA)
433 {
435 }
436
441
442 // Set from/to Vinyl controls - mFromVinyl must be set first.
443 mpChoice_FromVinyl->SetSelection(mFromVinyl);
444 // Then update to get correct mToVinyl.
445 Update_Vinyl();
446 // Then update ToVinyl control.
447 mpChoice_ToVinyl->SetSelection(mToVinyl);
448
449 // Set From Length control.
450 // Set the format first so we can get sample accuracy.
453
454 mbLoopDetect = false;
455
456 return true;
457}

References kVinyl_33AndAThird, kVinyl_NA, mbLoopDetect, mFormat, mFromLength, mFromVinyl, mpChoice_FromVinyl, mpChoice_ToVinyl, mpFromLengthCtrl, mToVinyl, mUIParent, NumericTextCtrl::SetFormatName(), NumericTextCtrl::SetValue(), Update_Slider_PercentChange(), Update_Text_Multiplier(), Update_Text_PercentChange(), Update_TimeCtrl_ToLength(), and Update_Vinyl().

Here is the call graph for this function:

◆ Update_Slider_PercentChange()

void EffectChangeSpeed::Update_Slider_PercentChange ( )
private

Definition at line 697 of file ChangeSpeed.cpp.

699{
700 auto unwarped = std::min<double>(m_PercentChange, Percentage.max);
701 if (unwarped > 0.0)
702 // Un-warp values above zero to actually go up to kSliderMax.
703 unwarped = pow(m_PercentChange, (1.0 / kSliderWarp));
704
705 // Caution: m_PercentChange could be infinite.
706 int unwarpedi = (int)(unwarped + 0.5);
707 unwarpedi = std::min<int>(unwarpedi, (int)kSliderMax);
708
709 mpSlider_PercentChange->SetValue(unwarpedi);
710}

References kSliderMax, kSliderWarp, m_PercentChange, EffectParameter< Structure, Member, Type, Value >::max, mpSlider_PercentChange, and Percentage.

Referenced by OnChoice_Vinyl(), OnText_Multiplier(), OnText_PercentChange(), OnTimeCtrl_ToLength(), and TransferDataToWindow().

Here is the caller graph for this function:

◆ Update_Text_Multiplier()

void EffectChangeSpeed::Update_Text_Multiplier ( )
private

Definition at line 690 of file ChangeSpeed.cpp.

692{
693 mMultiplier = 1 + (m_PercentChange) / 100.0;
694 mpTextCtrl_Multiplier->GetValidator()->TransferToWindow();
695}

References m_PercentChange, mMultiplier, and mpTextCtrl_Multiplier.

Referenced by OnChoice_Vinyl(), OnSlider_PercentChange(), OnText_PercentChange(), OnTimeCtrl_ToLength(), and TransferDataToWindow().

Here is the caller graph for this function:

◆ Update_Text_PercentChange()

void EffectChangeSpeed::Update_Text_PercentChange ( )
private

Definition at line 684 of file ChangeSpeed.cpp.

686{
687 mpTextCtrl_PercentChange->GetValidator()->TransferToWindow();
688}

References mpTextCtrl_PercentChange.

Referenced by OnChoice_Vinyl(), OnSlider_PercentChange(), OnText_Multiplier(), OnTimeCtrl_ToLength(), and TransferDataToWindow().

Here is the caller graph for this function:

◆ Update_TimeCtrl_ToLength()

void EffectChangeSpeed::Update_TimeCtrl_ToLength ( )
private

Definition at line 766 of file ChangeSpeed.cpp.

768{
769 mToLength = (mFromLength * 100.0) / (100.0 + m_PercentChange);
770
771 // Set the format first so we can get sample accuracy.
773 // Negative times do not make sense.
774 // 359999 = 99h:59m:59s which is a little less disturbing than overflow characters
775 // though it may still look a bit strange with some formats.
776 mToLength = std::clamp<double>(mToLength, 0.0, 359999.0);
778}

References m_PercentChange, mFormat, mFromLength, mpToLengthCtrl, mToLength, NumericTextCtrl::SetFormatName(), and NumericTextCtrl::SetValue().

Referenced by OnChoice_Vinyl(), OnSlider_PercentChange(), OnText_Multiplier(), OnText_PercentChange(), and TransferDataToWindow().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Update_Vinyl()

void EffectChangeSpeed::Update_Vinyl ( )
private

Definition at line 712 of file ChangeSpeed.cpp.

714{
715 // Match Vinyl rpm when within 0.01% of a standard ratio.
716 // Ratios calculated as: ((toRPM / fromRPM) - 1) * 100 * 100
717
718 // Caution: m_PercentChange could be infinite
719 int ratio = (int)((m_PercentChange * 100) + 0.5);
720
721 switch (ratio)
722 {
723 case 0: // toRPM is the same as fromRPM
724 if (mFromVinyl != kVinyl_NA) {
725 mpChoice_ToVinyl->SetSelection(mpChoice_FromVinyl->GetSelection());
726 } else {
727 // Use the last saved option.
729 CurrentSettingsGroup(), wxT("VinylChoice"), mFromVinyl, 0);
730 mpChoice_FromVinyl->SetSelection(mFromVinyl);
731 mpChoice_ToVinyl->SetSelection(mFromVinyl);
732 }
733 break;
734 case 3500:
736 mpChoice_ToVinyl->SetSelection(kVinyl_45);
737 break;
738 case 13400:
740 mpChoice_ToVinyl->SetSelection(kVinyl_78);
741 break;
742 case -2593:
743 mpChoice_FromVinyl->SetSelection(kVinyl_45);
745 break;
746 case 7333:
747 mpChoice_FromVinyl->SetSelection(kVinyl_45);
748 mpChoice_ToVinyl->SetSelection(kVinyl_78);
749 break;
750 case -5727:
751 mpChoice_FromVinyl->SetSelection(kVinyl_78);
753 break;
754 case -4231:
755 mpChoice_FromVinyl->SetSelection(kVinyl_78);
756 mpChoice_ToVinyl->SetSelection(kVinyl_45);
757 break;
758 default:
759 mpChoice_ToVinyl->SetSelection(kVinyl_NA);
760 }
761 // and update variables.
762 mFromVinyl = mpChoice_FromVinyl->GetSelection();
763 mToVinyl = mpChoice_ToVinyl->GetSelection();
764}

References CurrentSettingsGroup(), PluginSettings::GetConfig(), Effect::GetDefinition(), kVinyl_33AndAThird, kVinyl_45, kVinyl_78, kVinyl_NA, m_PercentChange, mFromVinyl, mpChoice_FromVinyl, mpChoice_ToVinyl, mToVinyl, PluginSettings::Private, and wxT().

Referenced by OnSlider_PercentChange(), OnText_Multiplier(), OnText_PercentChange(), OnTimeCtrl_ToLength(), and TransferDataToWindow().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ UpdateUI()

void EffectChangeSpeed::UpdateUI ( )
private

Definition at line 780 of file ChangeSpeed.cpp.

782{
785}
static bool EnableApply(wxWindow *parent, bool enable=true)
Enable or disable the Apply button of the dialog that contains parent.

References EffectEditor::EnableApply(), m_PercentChange, EffectParameter< Structure, Member, Type, Value >::max, EffectParameter< Structure, Member, Type, Value >::min, mUIParent, and Percentage.

Referenced by OnChoice_Vinyl(), OnSlider_PercentChange(), OnText_Multiplier(), OnText_PercentChange(), and OnTimeCtrl_ToLength().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ m_PercentChange

double EffectChangeSpeed::m_PercentChange
private

◆ mbLoopDetect

bool EffectChangeSpeed::mbLoopDetect
private

◆ mCurT0

double EffectChangeSpeed::mCurT0
private

Definition at line 95 of file ChangeSpeed.h.

Referenced by Process().

◆ mCurT1

double EffectChangeSpeed::mCurT1
private

Definition at line 96 of file ChangeSpeed.h.

Referenced by Process().

◆ mCurTrackNum

int EffectChangeSpeed::mCurTrackNum
private

Definition at line 94 of file ChangeSpeed.h.

Referenced by Process(), and ProcessOne().

◆ mFactor

double EffectChangeSpeed::mFactor
private

Definition at line 103 of file ChangeSpeed.h.

Referenced by Process(), ProcessLabelTrack(), and ProcessOne().

◆ mFormat

NumericFormatID EffectChangeSpeed::mFormat
private

◆ mFromLength

double EffectChangeSpeed::mFromLength
private

◆ mFromVinyl

int EffectChangeSpeed::mFromVinyl
private

◆ mMultiplier

double EffectChangeSpeed::mMultiplier
private

Definition at line 106 of file ChangeSpeed.h.

Referenced by OnText_Multiplier(), PopulateOrExchange(), and Update_Text_Multiplier().

◆ mpChoice_FromVinyl

wxChoice* EffectChangeSpeed::mpChoice_FromVinyl
private

◆ mpChoice_ToVinyl

wxChoice* EffectChangeSpeed::mpChoice_ToVinyl
private

◆ mpFromLengthCtrl

NumericTextCtrl* EffectChangeSpeed::mpFromLengthCtrl
private

Definition at line 116 of file ChangeSpeed.h.

Referenced by OnTimeCtrlUpdate(), PopulateOrExchange(), and TransferDataToWindow().

◆ mpSlider_PercentChange

wxSlider* EffectChangeSpeed::mpSlider_PercentChange
private

◆ mpTextCtrl_Multiplier

wxTextCtrl* EffectChangeSpeed::mpTextCtrl_Multiplier
private

Definition at line 112 of file ChangeSpeed.h.

Referenced by OnText_Multiplier(), PopulateOrExchange(), and Update_Text_Multiplier().

◆ mpTextCtrl_PercentChange

wxTextCtrl* EffectChangeSpeed::mpTextCtrl_PercentChange
private

◆ mpToLengthCtrl

NumericTextCtrl* EffectChangeSpeed::mpToLengthCtrl
private

◆ mRate

double EffectChangeSpeed::mRate
private

Definition at line 118 of file ChangeSpeed.h.

◆ mTimeCtrlFormat

int EffectChangeSpeed::mTimeCtrlFormat
private

Definition at line 105 of file ChangeSpeed.h.

◆ mToLength

double EffectChangeSpeed::mToLength
private

◆ mToVinyl

int EffectChangeSpeed::mToVinyl
private

Definition at line 121 of file ChangeSpeed.h.

Referenced by OnChoice_Vinyl(), TransferDataToWindow(), and Update_Vinyl().

◆ mUIParent

wxWeakRef<wxWindow> EffectChangeSpeed::mUIParent {}
private

◆ Percentage

constexpr EffectParameter EffectChangeSpeed::Percentage
staticconstexprprivate
Initial value:
L"Percentage", 0.0, -99.0, 4900.0, 1 }

Definition at line 128 of file ChangeSpeed.h.

Referenced by Parameters(), PopulateOrExchange(), Update_Slider_PercentChange(), and UpdateUI().

◆ Symbol

const ComponentInterfaceSymbol EffectChangeSpeed::Symbol { XO("Change Speed and Pitch") }
static

Definition at line 33 of file ChangeSpeed.h.

Referenced by GetSymbol().


The documentation for this class was generated from the following files: