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
 
EffectType GetType () const override
 Type determines how it behaves. More...
 
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 NumericFormatSymbol 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
 
NumericFormatSymbol 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
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
void SetLinearEffectFlag(bool linearEffectFlag)
Definition: EffectBase.cpp:214
const EffectParameterMethods & Parameters() const override
Definition: ChangeSpeed.cpp:71
NumericFormatSymbol mFormat
Definition: ChangeSpeed.h:123
virtual void Reset(Effect &effect) const =0
NUMERIC_FORMATS_API NumericFormatSymbol DefaultSelectionFormat()

References NumericConverterFormats::DefaultSelectionFormat(), 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:83
OptionalMessage LoadFactoryDefaults(EffectSettings &settings) const override
Definition: Effect.cpp:172

References NumericConverterFormats::DefaultSelectionFormat(), 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.SortedClipArray();
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
WaveClipPointers SortedClipArray()
Definition: WaveTrack.cpp:3975
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.

◆ 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:116
double mT0
Definition: EffectBase.h:115

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 610 of file ChangeSpeed.cpp.

611{
612 // Treat mpChoice_FromVinyl and mpChoice_ToVinyl as one control since we need
613 // both to calculate Percent Change.
614 mFromVinyl = mpChoice_FromVinyl->GetSelection();
615 mToVinyl = mpChoice_ToVinyl->GetSelection();
616 // Use this as the 'preferred' choice.
617 if (mFromVinyl != kVinyl_NA) {
619 CurrentSettingsGroup(), wxT("VinylChoice"), mFromVinyl);
620 }
621
622 // If mFromVinyl & mToVinyl are set, then there's a NEW percent change.
623 if ((mFromVinyl != kVinyl_NA) && (mToVinyl != kVinyl_NA))
624 {
625 double fromRPM;
626 double toRPM;
627 switch (mFromVinyl) {
628 default:
629 case kVinyl_33AndAThird: fromRPM = 33.0 + (1.0 / 3.0); break;
630 case kVinyl_45: fromRPM = 45.0; break;
631 case kVinyl_78: fromRPM = 78; break;
632 }
633 switch (mToVinyl) {
634 default:
635 case kVinyl_33AndAThird: toRPM = 33.0 + (1.0 / 3.0); break;
636 case kVinyl_45: toRPM = 45.0; break;
637 case kVinyl_78: toRPM = 78; break;
638 }
639 m_PercentChange = ((toRPM * 100.0) / fromRPM) - 100.0;
640 UpdateUI();
641
642 mbLoopDetect = true;
647 }
648 mbLoopDetect = false;
649}
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:189
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 591 of file ChangeSpeed.cpp.

592{
593 if (mbLoopDetect)
594 return;
595
596 m_PercentChange = (double)(mpSlider_PercentChange->GetValue());
597 // Warp positive values to actually go up faster & further than negatives.
598 if (m_PercentChange > 0.0)
600 UpdateUI();
601
602 mbLoopDetect = true;
605 Update_Vinyl();
607 mbLoopDetect = false;
608}
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 574 of file ChangeSpeed.cpp.

575{
576 if (mbLoopDetect)
577 return;
578
579 mpTextCtrl_Multiplier->GetValidator()->TransferFromWindow();
580 m_PercentChange = 100 * (mMultiplier - 1);
581 UpdateUI();
582
583 mbLoopDetect = true;
586 Update_Vinyl();
588 mbLoopDetect = false;
589}
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 558 of file ChangeSpeed.cpp.

559{
560 if (mbLoopDetect)
561 return;
562
563 mpTextCtrl_PercentChange->GetValidator()->TransferFromWindow();
564 UpdateUI();
565
566 mbLoopDetect = true;
569 Update_Vinyl();
571 mbLoopDetect = false;
572}
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 651 of file ChangeSpeed.cpp.

652{
653 if (mbLoopDetect)
654 return;
655
657 // Division by (double) 0.0 is not an error and we want to show "infinite" in
658 // text controls, so take care that we handle infinite values when they occur.
659 m_PercentChange = ((mFromLength * 100.0) / mToLength) - 100.0;
660 UpdateUI();
661
662 mbLoopDetect = true;
663
667 Update_Vinyl();
668
669 mbLoopDetect = false;
670}
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 672 of file ChangeSpeed.cpp.

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

References 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 301 of file ChangeSpeed.cpp.

304{
305 mUIParent = S.GetParent();
306
307 {
308 wxString formatId;
311 wxT("TimeFormat"), formatId, mFormat.Internal());
314 NumericConverterType_TIME(), formatId);
315 }
318 wxT("VinylChoice"), mFromVinyl, mFromVinyl);
319
320 S.SetBorder(5);
321
322 S.StartVerticalLay(0);
323 {
324 // Speed multiplier and percent change controls.
325 S.StartMultiColumn(4, wxCENTER);
326 {
328 .Validator<FloatingPointValidator<double>>(
329 3, &mMultiplier,
330 NumValidatorStyle::THREE_TRAILING_ZEROES,
331 Percentage.min / 100.0, ((Percentage.max / 100.0) + 1) )
332 .AddTextBox(XXO("&Speed Multiplier:"), L"", 12);
333
335 .Validator<FloatingPointValidator<double>>(
336 3, &m_PercentChange,
337 NumValidatorStyle::THREE_TRAILING_ZEROES,
339 .AddTextBox(XXO("Percent C&hange:"), L"", 12);
340 }
341 S.EndMultiColumn();
342
343 // Percent change slider.
344 S.StartHorizontalLay(wxEXPAND);
345 {
347 .Name(XO("Percent Change"))
348 .Style(wxSL_HORIZONTAL)
349 .AddSlider( {}, 0, (int)kSliderMax, (int)Percentage.min);
350 }
351 S.EndHorizontalLay();
352
353 // Vinyl rpm controls.
354 S.StartMultiColumn(5, wxCENTER);
355 {
356 /* i18n-hint: "rpm" is an English abbreviation meaning "revolutions per minute".
357 "vinyl" refers to old-fashioned phonograph records */
358 S.AddUnits(XO("Standard Vinyl rpm:"));
359
361 /* i18n-hint: changing speed of audio "from" one value "to" another
362 "rpm" means "revolutions per minute" as on a vinyl record turntable
363 */
364 .Name(XO("From rpm"))
365 .MinSize( { 100, -1 } )
366 /* i18n-hint: changing speed of audio "from" one value "to" another */
367 .AddChoice(XXC("&from", "change speed"), kVinylStrings);
368
370 /* i18n-hint: changing speed of audio "from" one value "to" another
371 "rpm" means "revolutions per minute" as on a vinyl record turntable
372 */
373 .Name(XO("To rpm"))
374 .MinSize( { 100, -1 } )
375 /* i18n-hint: changing speed of audio "from" one value "to" another */
376 .AddChoice(XXC("&to", "change speed"), kVinylStrings);
377 }
378 S.EndMultiColumn();
379
380 // From/To time controls.
381 S.StartStatic(XO("Selection Length"), 0);
382 {
383 S.StartMultiColumn(2, wxALIGN_LEFT);
384 {
385 S.AddPrompt(XXO("C&urrent Length:"));
386
389 S.GetParent(), wxID_ANY,
391 mFormat,
394 .ReadOnly(true)
395 .MenuEnabled(false));
396
397 S.ToolTip(XO("Current length of selection."))
398 /* i18n-hint: changing speed of audio "from" one value "to" another */
399 .Name(XC("from", "change speed"))
400 .Position(wxALIGN_LEFT)
401 .AddWindow(mpFromLengthCtrl);
402
403 S.AddPrompt(XXO("&New Length:"));
404
407 S.GetParent(), ID_ToLength,
409 mFormat,
410 mToLength);
411
412 /* i18n-hint: changing speed of audio "from" one value "to" another */
413 S.Name(XC("to", "change speed"))
414 .Position(wxALIGN_LEFT)
415 .AddWindow(mpToLengthCtrl);
416 }
417 S.EndMultiColumn();
418 }
419 S.EndStatic();
420 }
421 S.EndVerticalLay();
422 return nullptr;
423}
static const double kSliderMax
Definition: ChangeSpeed.cpp:80
static const TranslatableStrings kVinylStrings
Definition: ChangeSpeed.cpp:61
@ 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
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:10
#define S(N)
Definition: ToChars.cpp:64
const wxString & Internal() const
wxWeakRef< wxWindow > mUIParent
Definition: ChangeSpeed.h:91
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(), 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, {{ 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 newTracks = outWaveTrack.WideEmptyCopy();
253 auto iter =
254 (*newTracks->Any<WaveTrack>().begin())->Channels().begin();
255 for (const auto pChannel : outWaveTrack.Channels()) {
256 // ProcessOne() (implemented below) processes a single channel
257 if (ProcessOne(*pChannel, **iter++, start, end))
258 ++mCurTrackNum;
259 else {
260 newTracks.reset();
261 break;
262 }
263 }
264 if (!newTracks) {
265 bGoodResult = false;
266 return;
267 }
268 const auto pNewTrack = *newTracks->Any<WaveTrack>().begin();
269 pNewTrack->Flush();
270
271 const double newLength = pNewTrack->GetEndTime();
272 const LinearTimeWarper warper{
273 mCurT0, mCurT0, mCurT1, mCurT0 + newLength };
274
275 outWaveTrack.ClearAndPaste(mCurT0, mCurT1,
276 *newTracks, true, true, &warper);
277
278 // Finally, recreate the gaps
279 for (const auto [st, et] : gaps)
280 if (st >= mCurT0 && et <= mCurT1 && st != et)
281 outWaveTrack.SplitDelete(warper.Warp(st), warper.Warp(et));
282 }
283 else
284 mCurTrackNum += outWaveTrack.NChannels();
285 }; },
286 [&](Track &t) {
288 t.SyncLockAdjust(mT1, mT0 + (mT1 - mT0) * mFactor);
289 }
290 );
291
292 if (bGoodResult)
293 outputs.Commit();
294
295 // Update selection.
296 mT1 = mT0 + (((mT1 - mT0) * 100.0) / (100.0 + m_PercentChange));
297
298 return bGoodResult;
299}
int min(int a, int b)
std::shared_ptr< TrackList > mTracks
Definition: EffectBase.h:109
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:87
Linear scaling, initialised by giving two points on the line.
Definition: TimeWarper.h:87
static bool IsSelectedOrSyncLockSelected(const Track *pTrack)
Definition: SyncLock.cpp:112
static bool IsSyncLockSelected(const Track *pTrack)
Definition: SyncLock.cpp:82
Abstract base class for an object holding data associated with points on a time axis.
Definition: Track.h:123
A Track that contains audio waveform data.
Definition: WaveTrack.h:220
auto end(const Ptr< Type, BaseDeleter > &p)
Enables range-for.
Definition: PackedArray.h:159
auto begin(const Ptr< Type, BaseDeleter > &p)
Enables range-for.
Definition: PackedArray.h:150

References PackedArray::begin(), PackedArray::end(), FindGaps(), 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 484 of file ChangeSpeed.cpp.

485{
486 RegionTimeWarper warper { mT0, mT1,
487 std::make_unique<LinearTimeWarper>(mT0, mT0,
488 mT1, mT0 + (mT1-mT0)*mFactor) };
489 lt->WarpLabels(warper);
490 return true;
491}
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 495 of file ChangeSpeed.cpp.

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

References WaveChannel::Append(), PackedArray::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 461 of file ChangeSpeed.cpp.

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

References CurrentSettingsGroup(), Effect::GetDefinition(), ComponentInterfaceSymbol::Internal(), 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 425 of file ChangeSpeed.cpp.

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

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 699 of file ChangeSpeed.cpp.

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

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 692 of file ChangeSpeed.cpp.

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

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 686 of file ChangeSpeed.cpp.

688{
689 mpTextCtrl_PercentChange->GetValidator()->TransferToWindow();
690}

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 768 of file ChangeSpeed.cpp.

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

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 714 of file ChangeSpeed.cpp.

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

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 782 of file ChangeSpeed.cpp.

784{
787}
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

NumericFormatSymbol 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: