Audacity 3.2.0
Public Member Functions | Static Public Member Functions | Static Public Attributes | 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...
 
bool LoadFactoryDefaults (EffectSettings &settings) const override
 Change settings back to "factory default". More...
 
bool 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
 Call once to set up state for whole list of tracks to be processed. More...
 
bool Process (EffectInstance &instance, EffectSettings &settings) override
 Actually do the effect here. More...
 
std::unique_ptr< EffectUIValidatorPopulateOrExchange (ShuttleGui &S, EffectInstance &instance, EffectSettingsAccess &access) override
 Add controls to effect panel; always succeeds. More...
 
bool TransferDataToWindow (const EffectSettings &settings) override
 Update controls for the settings. More...
 
bool TransferDataFromWindow (EffectSettings &settings) override
 Update the given settings from controls. More...
 
- Public Member Functions inherited from StatefulEffect
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 ()
 Call once to set up state for whole list of tracks to be processed. More...
 
virtual bool Process (EffectInstance &instance, EffectSettings &settings)=0
 Actually do the effect here. More...
 
virtual bool RealtimeInitialize (EffectSettings &settings, double sampleRate)
 
virtual bool RealtimeAddProcessor (EffectSettings &settings, unsigned numChannels, float sampleRate)
 
virtual bool RealtimeSuspend ()
 
virtual bool RealtimeResume ()
 
virtual bool RealtimeProcessStart (EffectSettings &settings)
 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
 
- 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...
 
bool LoadUserPreset (const RegistryPath &name, EffectSettings &settings) const override
 Change settings to a user-named preset. More...
 
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...
 
bool LoadFactoryPreset (int id, EffectSettings &settings) const override
 Change settings to the preset whose name is GetFactoryPresets()[id] More...
 
bool LoadFactoryDefaults (EffectSettings &settings) const override
 Change settings back to "factory default". More...
 
unsigned GetAudioInCount () const override
 How many input buffers to allocate at once. More...
 
unsigned GetAudioOutCount () const override
 How many output buffers to allocate at once. More...
 
virtual const EffectParameterMethodsParameters () const
 
int ShowClientInterface (wxWindow &parent, wxDialog &dialog, bool forceModal=false) override
 
std::unique_ptr< EffectUIValidatorPopulateUI (ShuttleGui &S, EffectInstance &instance, EffectSettingsAccess &access) override
 Adds controls to a panel that is given as the parent window of S More...
 
bool IsGraphicalUI () override
 
bool ValidateUI (EffectSettings &) override
 
bool CloseUI () override
 
bool CanExportPresets () override
 
void ExportPresets (const EffectSettings &settings) const override
 
void ImportPresets (EffectSettings &settings) override
 
bool HasOptions () override
 
void ShowOptions () override
 
const EffectSettingsManagerGetDefinition () const override
 
virtual NumericFormatSymbol GetSelectionFormat ()
 
int ShowHostInterface (wxWindow &parent, const EffectDialogFactory &factory, std::shared_ptr< EffectInstance > &pInstance, EffectSettingsAccess &access, bool forceModal=false) override
 Usually applies factory to self and given access. More...
 
bool SaveSettingsAsString (const EffectSettings &settings, wxString &parms) const override
 
bool LoadSettingsFromString (const wxString &parms, EffectSettings &settings) const override
 
bool IsBatchProcessing () const override
 
void SetBatchProcessing () override
 
void UnsetBatchProcessing () override
 
bool TransferDataToWindow (const EffectSettings &settings) override
 Update controls for the settings. More...
 
bool TransferDataFromWindow (EffectSettings &settings) override
 Update the given settings from controls. More...
 
unsigned TestUIFlags (unsigned mask)
 
bool Delegate (Effect &delegate, EffectSettings &settings)
 Re-invoke DoEffect on another Effect object that implements the work. More...
 
int MessageBox (const TranslatableString &message, long style=DefaultMessageBoxStyle, const TranslatableString &titleStr={}) const
 
bool EnableApply (bool enable=true)
 
wxWindow * GetUIParent ()
 
- Public Member Functions inherited from EffectBase
 EffectBase ()
 
 ~EffectBase () override
 
- Public Member Functions inherited from EffectUIClientInterface
virtual ~EffectUIClientInterface ()
 
virtual int ShowClientInterface (wxWindow &parent, wxDialog &dialog, bool forceModal=false)=0
 
virtual bool IsGraphicalUI ()=0
 
virtual std::unique_ptr< EffectUIValidatorPopulateUI (ShuttleGui &S, EffectInstance &instance, EffectSettingsAccess &access)=0
 Adds controls to a panel that is given as the parent window of S More...
 
virtual bool CanExportPresets ()=0
 
virtual void ExportPresets (const EffectSettings &settings) const =0
 
virtual void ImportPresets (EffectSettings &settings)=0
 
virtual bool HasOptions ()=0
 
virtual void ShowOptions ()=0
 
- Public Member Functions inherited from EffectPlugin
EffectPluginoperator= (EffectPlugin &)=delete
 
virtual ~EffectPlugin ()
 
virtual const EffectSettingsManagerGetDefinition () const =0
 
virtual int ShowHostInterface (wxWindow &parent, const EffectDialogFactory &factory, std::shared_ptr< EffectInstance > &pInstance, EffectSettingsAccess &access, bool forceModal=false)=0
 Usually applies factory to self and given access. More...
 
virtual void Preview (EffectSettingsAccess &access, bool dryOnly)=0
 
virtual bool SaveSettingsAsString (const EffectSettings &settings, wxString &parms) const =0
 
virtual bool 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, double projectRate, TrackList *list, WaveTrackFactory *factory, NotifyingSelectedRegion &selectedRegion, unsigned flags, wxWindow *pParent=nullptr, const EffectDialogFactory &dialogFactory={}, const EffectSettingsAccessPtr &pAccess=nullptr)=0
 Unfortunately complicated dual-use function. More...
 
virtual bool TransferDataToWindow (const EffectSettings &settings)=0
 Update controls for the settings. More...
 
virtual bool TransferDataFromWindow (EffectSettings &settings)=0
 Update the given settings from controls. More...
 
- 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...
 
virtual unsigned GetAudioInCount () const =0
 How many input buffers to allocate at once. More...
 
virtual unsigned GetAudioOutCount () const =0
 How many output buffers to allocate at once. More...
 
virtual int GetMidiInCount () const
 Function that has not yet found a use. More...
 
virtual int GetMidiOutCount () const
 Function that has not yet found a use. 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...
 
- 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
 

Static Public Member Functions

static EffectChangeSpeedFetchParameters (EffectChangeSpeed &e, EffectSettings &)
 
- Static Public Member Functions inherited from Effect
static EffectFetchParameters (Effect &e, EffectSettings &)
 
static void IncEffectCounter ()
 
- 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 Attributes

static const ComponentInterfaceSymbol Symbol { XO("Change Speed") }
 
- 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 Member Functions

bool ProcessOne (WaveTrack *t, 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

int mCurTrackNum
 
double mMaxNewLength
 
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 Effect
enum  : long { DefaultMessageBoxStyle = wxOK | wxCENTRE }
 
- Public Types inherited from EffectPlugin
using EffectSettingsAccessPtr = std::shared_ptr< EffectSettingsAccess >
 
- Public Types inherited from EffectDefinitionInterface
enum class  RealtimeSince : unsigned { Never , Since_3_2 , Always }
 In which versions of Audacity was an effect realtime capable? More...
 
- Protected Member Functions inherited from Effect
bool EnablePreview (bool enable=true)
 
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...
 
virtual std::unique_ptr< EffectUIValidatorPopulateOrExchange (ShuttleGui &S, EffectInstance &instance, EffectSettingsAccess &access)
 Add controls to effect panel; always succeeds. 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, const WaveTrack *pRight, sampleCount *start, sampleCount *len)
 
void CopyInputTracks (bool allSyncLockSelected=false)
 
std::shared_ptr< AddedAnalysisTrackAddAnalysisTrack (const wxString &name=wxString())
 
ModifiedAnalysisTrack ModifyAnalysisTrack (const LabelTrack *pOrigTrack, const wxString &name=wxString())
 
TrackAddToOutputTracks (const std::shared_ptr< Track > &t)
 
- Protected Member Functions inherited from EffectBase
void Preview (EffectSettingsAccess &access, bool dryOnly) override
 
bool DoEffect (EffectSettings &settings, double projectRate, TrackList *list, WaveTrackFactory *factory, NotifyingSelectedRegion &selectedRegion, unsigned flags, wxWindow *pParent, const EffectDialogFactory &dialogFactory, const EffectSettingsAccessPtr &pAccess) override
 Unfortunately complicated dual-use function. More...
 
virtual bool CheckWhetherSkipEffect (const EffectSettings &settings) const =0
 After Init(), tell whether Process() should be skipped. More...
 
virtual double CalcPreviewInputLength (const EffectSettings &settings, double previewLength) const =0
 
void SetLinearEffectFlag (bool linearEffectFlag)
 
void SetPreviewFullSelectionFlag (bool previewDurationFlag)
 
bool IsPreviewing () const
 
void IncludeNotSelectedPreviewTracks (bool includeNotSelected)
 
void ReplaceProcessedTracks (const bool bGoodResult)
 
const TrackListinputTracks () const
 
const AudacityProjectFindProject () const
 
virtual bool ValidateUI (EffectSettings &settings)=0
 
virtual bool CloseUI ()=0
 
- Protected Attributes inherited from Effect
wxWeakRef< wxDialog > mHostUIDialog
 This smart pointer tracks the lifetime of the dialog. More...
 
wxWindow * mUIParent {}
 
- Protected Attributes inherited from EffectBase
BasicUI::ProgressDialogmProgress {}
 
double mProjectRate {}
 
WaveTrackFactorymFactory {}
 
std::shared_ptr< TrackListmOutputTracks
 
double mT0 {}
 
double mT1 {}
 
wxArrayString mPresetNames
 
unsigned mUIFlags { 0 }
 
- Protected Attributes inherited from EffectUIClientInterface
friend EffectUIValidator
 
friend DefaultEffectUIValidator
 
- Static Protected Attributes inherited from EffectBase
static int nEffectsDone = 0
 

Detailed Description

An Effect that affects both pitch & speed.

Definition at line 25 of file ChangeSpeed.h.

Constructor & Destructor Documentation

◆ EffectChangeSpeed()

EffectChangeSpeed::EffectChangeSpeed ( )

Definition at line 99 of file ChangeSpeed.cpp.

100{
101 Parameters().Reset(*this);
102
105 mFromLength = 0.0;
106 mToLength = 0.0;
108 mbLoopDetect = false;
109
111}
@ kVinyl_33AndAThird
Definition: ChangeSpeed.cpp:52
void SetLinearEffectFlag(bool linearEffectFlag)
Definition: EffectBase.cpp:218
const EffectParameterMethods & Parameters() const override
Definition: ChangeSpeed.cpp:68
NumericFormatSymbol mFormat
Definition: ChangeSpeed.h:112
virtual void Reset(Effect &effect) const =0
static NumericFormatSymbol DefaultSelectionFormat()

References NumericConverter::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 113 of file ChangeSpeed.cpp.

114{
115}

Member Function Documentation

◆ CalcPreviewInputLength()

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

Implements EffectBase.

Definition at line 163 of file ChangeSpeed.cpp.

165{
166 return previewLength * (100.0 + m_PercentChange) / 100.0;
167}
double m_PercentChange
Definition: ChangeSpeed.h:88

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

159{
160 return (m_PercentChange == 0.0);
161}

References m_PercentChange.

◆ DoLoadFactoryDefaults()

bool EffectChangeSpeed::DoLoadFactoryDefaults ( EffectSettings settings)

Definition at line 148 of file ChangeSpeed.cpp.

149{
152
154}
static Settings & settings()
Definition: TrackInfo.cpp:87
bool LoadFactoryDefaults(EffectSettings &settings) const override
Change settings back to "factory default".
Definition: Effect.cpp:280

References NumericConverter::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 29 of file ChangeSpeed.h.

29{ return &e; }

◆ GetDescription()

TranslatableString EffectChangeSpeed::GetDescription ( ) const
overridevirtual

Implements ComponentInterface.

Definition at line 124 of file ChangeSpeed.cpp.

125{
126 return XO("Changes the speed of a track, also changing its pitch");
127}
#define XO(s)
Definition: Internat.h:31

References XO.

◆ GetSymbol()

ComponentInterfaceSymbol EffectChangeSpeed::GetSymbol ( ) const
overridevirtual

Implements ComponentInterface.

Definition at line 119 of file ChangeSpeed.cpp.

120{
121 return Symbol;
122}
static const ComponentInterfaceSymbol Symbol
Definition: ChangeSpeed.h:30

References Symbol.

◆ GetType()

EffectType EffectChangeSpeed::GetType ( ) const
overridevirtual

Type determines how it behaves.

Implements EffectDefinitionInterface.

Definition at line 137 of file ChangeSpeed.cpp.

138{
139 return EffectTypeProcess;
140}
@ EffectTypeProcess

References EffectTypeProcess.

◆ Init()

bool EffectChangeSpeed::Init ( )
overridevirtual

Call once to set up state for whole list of tracks to be processed.

Returns
success Default implementation does nothing, returns true Default implementation does nothing, returns true

Reimplemented from StatefulEffectBase.

Definition at line 169 of file ChangeSpeed.cpp.

170{
171 // The selection might have changed since the last time EffectChangeSpeed
172 // was invoked, so recalculate the Length parameters.
173 mFromLength = mT1 - mT0;
174 return true;
175}
double mT1
Definition: EffectBase.h:107
double mT0
Definition: EffectBase.h:106

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

◆ LoadFactoryDefaults()

bool EffectChangeSpeed::LoadFactoryDefaults ( EffectSettings settings) const
overridevirtual

Change settings back to "factory default".

Implements EffectSettingsManager.

Definition at line 142 of file ChangeSpeed.cpp.

143{
144 // To do: externalize state so const_cast isn't needed
145 return const_cast<EffectChangeSpeed&>(*this).DoLoadFactoryDefaults(settings);
146}
An Effect that affects both pitch & speed.
Definition: ChangeSpeed.h:26
bool 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 129 of file ChangeSpeed.cpp.

130{
131 return L"Change_Speed";
132}

◆ OnChoice_Vinyl()

void EffectChangeSpeed::OnChoice_Vinyl ( wxCommandEvent &  evt)
private

Definition at line 601 of file ChangeSpeed.cpp.

602{
603 // Treat mpChoice_FromVinyl and mpChoice_ToVinyl as one control since we need
604 // both to calculate Percent Change.
605 mFromVinyl = mpChoice_FromVinyl->GetSelection();
606 mToVinyl = mpChoice_ToVinyl->GetSelection();
607 // Use this as the 'preferred' choice.
608 if (mFromVinyl != kVinyl_NA) {
610 CurrentSettingsGroup(), wxT("VinylChoice"), mFromVinyl);
611 }
612
613 // If mFromVinyl & mToVinyl are set, then there's a NEW percent change.
614 if ((mFromVinyl != kVinyl_NA) && (mToVinyl != kVinyl_NA))
615 {
616 double fromRPM;
617 double toRPM;
618 switch (mFromVinyl) {
619 default:
620 case kVinyl_33AndAThird: fromRPM = 33.0 + (1.0 / 3.0); break;
621 case kVinyl_45: fromRPM = 45.0; break;
622 case kVinyl_78: fromRPM = 78; break;
623 }
624 switch (mToVinyl) {
625 default:
626 case kVinyl_33AndAThird: toRPM = 33.0 + (1.0 / 3.0); break;
627 case kVinyl_45: toRPM = 45.0; break;
628 case kVinyl_78: toRPM = 78; break;
629 }
630 m_PercentChange = ((toRPM * 100.0) / fromRPM) - 100.0;
631 UpdateUI();
632
633 mbLoopDetect = true;
638 }
639 mbLoopDetect = false;
640}
@ kVinyl_78
Definition: ChangeSpeed.cpp:54
@ kVinyl_45
Definition: ChangeSpeed.cpp:53
@ kVinyl_NA
Definition: ChangeSpeed.cpp:55
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:104
void Update_Text_PercentChange()
wxChoice * mpChoice_FromVinyl
Definition: ChangeSpeed.h:103
void Update_Text_Multiplier()
const EffectSettingsManager & GetDefinition() const override
Definition: Effect.cpp:453
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(), and UpdateUI().

Here is the call graph for this function:

◆ OnSlider_PercentChange()

void EffectChangeSpeed::OnSlider_PercentChange ( wxCommandEvent &  evt)
private

Definition at line 582 of file ChangeSpeed.cpp.

583{
584 if (mbLoopDetect)
585 return;
586
587 m_PercentChange = (double)(mpSlider_PercentChange->GetValue());
588 // Warp positive values to actually go up faster & further than negatives.
589 if (m_PercentChange > 0.0)
591 UpdateUI();
592
593 mbLoopDetect = true;
596 Update_Vinyl();
598 mbLoopDetect = false;
599}
static const double kSliderWarp
Definition: ChangeSpeed.cpp:78
wxSlider * mpSlider_PercentChange
Definition: ChangeSpeed.h:102

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

566{
567 if (mbLoopDetect)
568 return;
569
570 mpTextCtrl_Multiplier->GetValidator()->TransferFromWindow();
571 m_PercentChange = 100 * (mMultiplier - 1);
572 UpdateUI();
573
574 mbLoopDetect = true;
577 Update_Vinyl();
579 mbLoopDetect = false;
580}
wxTextCtrl * mpTextCtrl_Multiplier
Definition: ChangeSpeed.h:101

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

550{
551 if (mbLoopDetect)
552 return;
553
554 mpTextCtrl_PercentChange->GetValidator()->TransferFromWindow();
555 UpdateUI();
556
557 mbLoopDetect = true;
560 Update_Vinyl();
562 mbLoopDetect = false;
563}
wxTextCtrl * mpTextCtrl_PercentChange
Definition: ChangeSpeed.h:100

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

643{
644 if (mbLoopDetect)
645 return;
646
648 // Division by (double) 0.0 is not an error and we want to show "infinite" in
649 // text controls, so take care that we handle infinite values when they occur.
650 m_PercentChange = ((mFromLength * 100.0) / mToLength) - 100.0;
651 UpdateUI();
652
653 mbLoopDetect = true;
654
658 Update_Vinyl();
659
660 mbLoopDetect = false;
661}
NumericTextCtrl * mpToLengthCtrl
Definition: ChangeSpeed.h:106

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

664{
666 NumericConverter::TIME, evt.GetString() );
667
669 // Update From/To Length controls (precision has changed).
672}
NumericTextCtrl * mpFromLengthCtrl
Definition: ChangeSpeed.h:105
static NumericFormatSymbol LookupFormat(Type type, const wxString &id)
bool SetFormatName(const NumericFormatSymbol &formatName)
void SetValue(double newValue)

References NumericConverter::LookupFormat(), mFormat, mFromLength, mpFromLengthCtrl, mpToLengthCtrl, mToLength, NumericTextCtrl::SetFormatName(), NumericTextCtrl::SetValue(), and NumericConverter::TIME.

Here is the call graph for this function:

◆ Parameters()

const EffectParameterMethods & EffectChangeSpeed::Parameters ( ) const
overrideprivatevirtual

Reimplemented from Effect.

Definition at line 68 of file ChangeSpeed.cpp.

69{
72 > parameters;
73 return parameters;
74}
Generates EffectParameterMethods overrides from variadic template arguments.
static constexpr EffectParameter Percentage
Definition: ChangeSpeed.h:117

References EffectChangeSpeed(), and Percentage.

Here is the call graph for this function:

◆ PopulateOrExchange()

std::unique_ptr< EffectUIValidator > EffectChangeSpeed::PopulateOrExchange ( ShuttleGui S,
EffectInstance instance,
EffectSettingsAccess access 
)
overridevirtual

Add controls to effect panel; always succeeds.

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

Reimplemented from Effect.

Definition at line 240 of file ChangeSpeed.cpp.

242{
243 {
244 wxString formatId;
247 wxT("TimeFormat"), formatId, mFormat.Internal());
249 NumericConverter::TIME, formatId );
250 }
253 wxT("VinylChoice"), mFromVinyl, mFromVinyl);
254
255 S.SetBorder(5);
256
257 S.StartVerticalLay(0);
258 {
259 S.AddSpace(0, 5);
260 S.AddTitle(XO("Change Speed, affecting both Tempo and Pitch"));
261 S.AddSpace(0, 10);
262
263 // Speed multiplier and percent change controls.
264 S.StartMultiColumn(4, wxCENTER);
265 {
267 .Validator<FloatingPointValidator<double>>(
268 3, &mMultiplier,
269 NumValidatorStyle::THREE_TRAILING_ZEROES,
270 Percentage.min / 100.0, ((Percentage.max / 100.0) + 1) )
271 .AddTextBox(XXO("&Speed Multiplier:"), L"", 12);
272
274 .Validator<FloatingPointValidator<double>>(
275 3, &m_PercentChange,
276 NumValidatorStyle::THREE_TRAILING_ZEROES,
278 .AddTextBox(XXO("Percent C&hange:"), L"", 12);
279 }
280 S.EndMultiColumn();
281
282 // Percent change slider.
283 S.StartHorizontalLay(wxEXPAND);
284 {
286 .Name(XO("Percent Change"))
287 .Style(wxSL_HORIZONTAL)
288 .AddSlider( {}, 0, (int)kSliderMax, (int)Percentage.min);
289 }
290 S.EndHorizontalLay();
291
292 // Vinyl rpm controls.
293 S.StartMultiColumn(5, wxCENTER);
294 {
295 /* i18n-hint: "rpm" is an English abbreviation meaning "revolutions per minute".
296 "vinyl" refers to old-fashioned phonograph records */
297 S.AddUnits(XO("Standard Vinyl rpm:"));
298
300 /* i18n-hint: changing speed of audio "from" one value "to" another
301 "rpm" means "revolutions per minute" as on a vinyl record turntable
302 */
303 .Name(XO("From rpm"))
304 .MinSize( { 100, -1 } )
305 /* i18n-hint: changing speed of audio "from" one value "to" another */
306 .AddChoice(XXC("&from", "change speed"), kVinylStrings);
307
309 /* i18n-hint: changing speed of audio "from" one value "to" another
310 "rpm" means "revolutions per minute" as on a vinyl record turntable
311 */
312 .Name(XO("To rpm"))
313 .MinSize( { 100, -1 } )
314 /* i18n-hint: changing speed of audio "from" one value "to" another */
315 .AddChoice(XXC("&to", "change speed"), kVinylStrings);
316 }
317 S.EndMultiColumn();
318
319 // From/To time controls.
320 S.StartStatic(XO("Selection Length"), 0);
321 {
322 S.StartMultiColumn(2, wxALIGN_LEFT);
323 {
324 S.AddPrompt(XXO("C&urrent Length:"));
325
327 NumericTextCtrl(S.GetParent(), wxID_ANY,
329 mFormat,
333 .ReadOnly(true)
334 .MenuEnabled(false));
335
336 S.ToolTip(XO("Current length of selection."))
337 /* i18n-hint: changing speed of audio "from" one value "to" another */
338 .Name(XC("from", "change speed"))
339 .Position(wxALIGN_LEFT)
340 .AddWindow(mpFromLengthCtrl);
341
342 S.AddPrompt(XXO("&New Length:"));
343
345 NumericTextCtrl(S.GetParent(), ID_ToLength,
347 mFormat,
348 mToLength,
350
351 /* i18n-hint: changing speed of audio "from" one value "to" another */
352 S.Name(XC("to", "change speed"))
353 .Position(wxALIGN_LEFT)
354 .AddWindow(mpToLengthCtrl);
355 }
356 S.EndMultiColumn();
357 }
358 S.EndStatic();
359 }
360 S.EndVerticalLay();
361 return nullptr;
362}
static const double kSliderMax
Definition: ChangeSpeed.cpp:77
static const TranslatableStrings kVinylStrings
Definition: ChangeSpeed.cpp:58
@ ID_ToLength
Definition: ChangeSpeed.cpp:45
@ ID_FromVinyl
Definition: ChangeSpeed.cpp:43
@ ID_ToVinyl
Definition: ChangeSpeed.cpp:44
@ ID_Multiplier
Definition: ChangeSpeed.cpp:42
@ ID_PercentChange
Definition: ChangeSpeed.cpp:41
#define XXC(s, c)
Definition: Internat.h:47
#define XXO(s)
Definition: Internat.h:44
#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
double mProjectRate
Definition: EffectBase.h:99
bool GetConfig(const EffectDefinitionInterface &ident, ConfigurationType type, const RegistryPath &group, const RegistryPath &key, Value &var, const Value &defval)
const Type min
Minimum value.
Definition: Shuttle.h:30
const Type max
Maximum value.
Definition: Shuttle.h:31
Options & MenuEnabled(bool enable)
Options & ReadOnly(bool enable)

References CurrentSettingsGroup(), PluginSettings::GetConfig(), Effect::GetDefinition(), ID_FromVinyl, ID_Multiplier, ID_PercentChange, ID_ToLength, ID_ToVinyl, ComponentInterfaceSymbol::Internal(), kSliderMax, kVinylStrings, NumericConverter::LookupFormat(), m_PercentChange, EffectParameter< Structure, Member, Type, Value >::max, NumericTextCtrl::Options::MenuEnabled(), 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, Percentage, PluginSettings::Private, NumericTextCtrl::Options::ReadOnly(), S, safenew, NumericConverter::TIME, XC, XO, XXC, and XXO.

Here is the call graph for this function:

◆ Process()

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

Actually do the effect here.

Returns
success

Implements StatefulEffectBase.

Definition at line 177 of file ChangeSpeed.cpp.

178{
179 // Similar to EffectSoundTouch::Process()
180
181 // Iterate over each track.
182 // All needed because this effect needs to introduce
183 // silence in the sync-lock group tracks to keep sync
184 CopyInputTracks(true); // Set up mOutputTracks.
185 bool bGoodResult = true;
186
187 mCurTrackNum = 0;
188 mMaxNewLength = 0.0;
189
190 mFactor = 100.0 / (100.0 + m_PercentChange);
191
192 mOutputTracks->Any().VisitWhile( bGoodResult,
193 [&](LabelTrack *lt) {
195 {
196 if (!ProcessLabelTrack(lt))
197 bGoodResult = false;
198 }
199 },
200 [&](WaveTrack *pOutWaveTrack, const Track::Fallthrough &fallthrough) {
201 if (!pOutWaveTrack->GetSelected())
202 return fallthrough();
203
204 //Get start and end times from track
205 mCurT0 = pOutWaveTrack->GetStartTime();
206 mCurT1 = pOutWaveTrack->GetEndTime();
207
208 //Set the current bounds to whichever left marker is
209 //greater and whichever right marker is less:
210 mCurT0 = wxMax(mT0, mCurT0);
211 mCurT1 = wxMin(mT1, mCurT1);
212
213 // Process only if the right marker is to the right of the left marker
214 if (mCurT1 > mCurT0) {
215 //Transform the marker timepoints to samples
216 auto start = pOutWaveTrack->TimeToLongSamples(mCurT0);
217 auto end = pOutWaveTrack->TimeToLongSamples(mCurT1);
218
219 //ProcessOne() (implemented below) processes a single track
220 if (!ProcessOne(pOutWaveTrack, start, end))
221 bGoodResult = false;
222 }
223 mCurTrackNum++;
224 },
225 [&](Track *t) {
227 t->SyncLockAdjust(mT1, mT0 + (mT1 - mT0) * mFactor);
228 }
229 );
230
231 if (bGoodResult)
232 ReplaceProcessedTracks(bGoodResult);
233
234 // Update selection.
235 mT1 = mT0 + (((mT1 - mT0) * 100.0) / (100.0 + m_PercentChange));
236
237 return bGoodResult;
238}
std::shared_ptr< TrackList > mOutputTracks
Definition: EffectBase.h:105
void ReplaceProcessedTracks(const bool bGoodResult)
Definition: EffectBase.cpp:236
bool ProcessOne(WaveTrack *t, sampleCount start, sampleCount end)
double mMaxNewLength
Definition: ChangeSpeed.h:83
bool ProcessLabelTrack(LabelTrack *t)
void CopyInputTracks(bool allSyncLockSelected=false)
Definition: Effect.cpp:741
A LabelTrack is a Track that holds labels (LabelStruct).
Definition: LabelTrack.h:89
sampleCount TimeToLongSamples(double t0) const
Convert correctly between an (absolute) time in seconds and a number of samples.
Definition: SampleTrack.cpp:42
static bool IsSelectedOrSyncLockSelected(const Track *pTrack)
Definition: SyncLock.cpp:73
static bool IsSyncLockSelected(const Track *pTrack)
Definition: SyncLock.cpp:43
Abstract base class for an object holding data associated with points on a time axis.
Definition: Track.h:225
bool GetSelected() const
Definition: Track.h:469
Continuation<> Fallthrough
Type of arguments passed as optional second parameter to TypeSwitch<void>() cases.
Definition: Track.h:541
A Track that contains audio waveform data.
Definition: WaveTrack.h:57
double GetStartTime() const override
Get the time at which the first clip in the track starts.
Definition: WaveTrack.cpp:1995
double GetEndTime() const override
Get the time at which the last clip in the track ends, plus recorded stuff.
Definition: WaveTrack.cpp:2015
auto end(const Ptr< Type, BaseDeleter > &p)
Enables range-for.
Definition: PackedArray.h:159

References Effect::CopyInputTracks(), PackedArray::end(), WaveTrack::GetEndTime(), Track::GetSelected(), WaveTrack::GetStartTime(), SyncLock::IsSelectedOrSyncLockSelected(), SyncLock::IsSyncLockSelected(), m_PercentChange, mCurT0, mCurT1, mCurTrackNum, mFactor, mMaxNewLength, EffectBase::mOutputTracks, EffectBase::mT0, EffectBase::mT1, ProcessLabelTrack(), ProcessOne(), EffectBase::ReplaceProcessedTracks(), and SampleTrack::TimeToLongSamples().

Here is the call graph for this function:

◆ ProcessLabelTrack()

bool EffectChangeSpeed::ProcessLabelTrack ( LabelTrack t)
private

Definition at line 414 of file ChangeSpeed.cpp.

415{
416 RegionTimeWarper warper { mT0, mT1,
417 std::make_unique<LinearTimeWarper>(mT0, mT0,
418 mT1, mT0 + (mT1-mT0)*mFactor) };
419 lt->WarpLabels(warper);
420 return true;
421}
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 ( WaveTrack t,
sampleCount  start,
sampleCount  end 
)
private

Definition at line 425 of file ChangeSpeed.cpp.

427{
428 if (track == NULL)
429 return false;
430
431 // initialization, per examples of Mixer::Mixer and
432 // EffectSoundTouch::ProcessOne
433
434
435 auto outputTrack = track->EmptyCopy();
436
437 //Get the length of the selection (as double). len is
438 //used simple to calculate a progress meter, so it is easier
439 //to make it a double now than it is to do it later
440 auto len = (end - start).as_double();
441
442 // Initiate processing buffers, most likely shorter than
443 // the length of the selection being processed.
444 auto inBufferSize = track->GetMaxBlockSize();
445
446 Floats inBuffer{ inBufferSize };
447
448 // mFactor is at most 100-fold so this shouldn't overflow size_t
449 auto outBufferSize = size_t( mFactor * inBufferSize + 10 );
450 Floats outBuffer{ outBufferSize };
451
452 // Set up the resampling stuff for this track.
453 Resample resample(true, mFactor, mFactor); // constant rate resampling
454
455 //Go through the track one buffer at a time. samplePos counts which
456 //sample the current buffer starts at.
457 bool bResult = true;
458 auto samplePos = start;
459 while (samplePos < end) {
460 //Get a blockSize of samples (smaller than the size of the buffer)
461 auto blockSize = limitSampleBufferSize(
462 track->GetBestBlockSize(samplePos),
463 end - samplePos
464 );
465
466 //Get the samples from the track and put them in the buffer
467 track->GetFloats(inBuffer.get(), samplePos, blockSize);
468
469 const auto results = resample.Process(mFactor,
470 inBuffer.get(),
471 blockSize,
472 ((samplePos + blockSize) >= end),
473 outBuffer.get(),
474 outBufferSize);
475 const auto outgen = results.second;
476
477 if (outgen > 0)
478 outputTrack->Append((samplePtr)outBuffer.get(), floatSample,
479 outgen);
480
481 // Increment samplePos
482 samplePos += results.first;
483
484 // Update the Progress meter
485 if (TrackProgress(mCurTrackNum, (samplePos - start).as_double() / len)) {
486 bResult = false;
487 break;
488 }
489 }
490
491 // Flush the output WaveTrack (since it's buffered, too)
492 outputTrack->Flush();
493
494 // Take the output track and insert it in place of the original
495 // sample data
496 double newLength = outputTrack->GetEndTime();
497 if (bResult)
498 {
499 // Silenced samples will be inserted in gaps between clips, so capture where these
500 // gaps are for later deletion
501 std::vector<std::pair<double, double>> gaps;
502 double last = mCurT0;
503 auto clips = track->SortedClipArray();
504 auto front = clips.front();
505 auto back = clips.back();
506 for (auto &clip : clips) {
507 auto st = clip->GetPlayStartTime();
508 auto et = clip->GetPlayEndTime();
509
510 if (st >= mCurT0 || et < mCurT1) {
511 if (mCurT0 < st && clip == front) {
512 gaps.push_back(std::make_pair(mCurT0, st));
513 }
514 else if (last < st && mCurT0 <= last ) {
515 gaps.push_back(std::make_pair(last, st));
516 }
517
518 if (et < mCurT1 && clip == back) {
519 gaps.push_back(std::make_pair(et, mCurT1));
520 }
521 }
522 last = et;
523 }
524
525 LinearTimeWarper warper { mCurT0, mCurT0, mCurT1, mCurT0 + newLength };
526
527 // Take the output track and insert it in place of the original sample data
528 track->ClearAndPaste(mCurT0, mCurT1, outputTrack.get(), true, true, &warper);
529
530 // Finally, recreate the gaps
531 for (auto gap : gaps) {
532 auto st = track->LongSamplesToTime(track->TimeToLongSamples(gap.first));
533 auto et = track->LongSamplesToTime(track->TimeToLongSamples(gap.second));
534 if (st >= mCurT0 && et <= mCurT1 && st != et)
535 {
536 track->SplitDelete(warper.Warp(st), warper.Warp(et));
537 }
538 }
539 }
540
541 if (newLength > mMaxNewLength)
542 mMaxNewLength = newLength;
543
544 return bResult;
545}
static const int gap
Definition: MeterPanel.cpp:259
size_t limitSampleBufferSize(size_t bufferSize, sampleCount limit)
Definition: SampleCount.cpp:23
@ floatSample
Definition: SampleFormat.h:34
char * samplePtr
Definition: SampleFormat.h:49
bool TrackProgress(int whichTrack, double frac, const TranslatableString &={}) const
Definition: Effect.cpp:693
Linear scaling, initialised by giving two points on the line.
Definition: TimeWarper.h:87
Interface to libsoxr.
Definition: Resample.h:27

References WaveTrack::ClearAndPaste(), WaveTrack::EmptyCopy(), PackedArray::end(), floatSample, gap, WaveTrack::GetBestBlockSize(), SampleTrack::GetFloats(), WaveTrack::GetMaxBlockSize(), limitSampleBufferSize(), SampleTrack::LongSamplesToTime(), mCurT0, mCurT1, mCurTrackNum, mFactor, mMaxNewLength, Resample::Process(), WaveTrack::SortedClipArray(), WaveTrack::SplitDelete(), SampleTrack::TimeToLongSamples(), 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.

Implements EffectPlugin.

Definition at line 395 of file ChangeSpeed.cpp.

396{
397 // mUIParent->TransferDataFromWindow() loses some precision, so save and restore it.
398 double exactPercent = m_PercentChange;
399 m_PercentChange = exactPercent;
400
401 // TODO: just visit these effect settings the default way
403 CurrentSettingsGroup(), wxT("TimeFormat"), mFormat.Internal());
405 CurrentSettingsGroup(), wxT("VinylChoice"), mFromVinyl);
406
407 return true;
408}

References CurrentSettingsGroup(), Effect::GetDefinition(), ComponentInterfaceSymbol::Internal(), m_PercentChange, mFormat, mFromVinyl, PluginSettings::Private, and PluginSettings::SetConfig().

Here is the call graph for this function:

◆ TransferDataToWindow()

bool EffectChangeSpeed::TransferDataToWindow ( const EffectSettings settings)
overridevirtual

Update controls for the settings.

Implements EffectPlugin.

Definition at line 364 of file ChangeSpeed.cpp.

365{
366 mbLoopDetect = true;
367
368 if (mFromVinyl == kVinyl_NA)
369 {
371 }
372
377
378 // Set from/to Vinyl controls - mFromVinyl must be set first.
379 mpChoice_FromVinyl->SetSelection(mFromVinyl);
380 // Then update to get correct mToVinyl.
381 Update_Vinyl();
382 // Then update ToVinyl control.
383 mpChoice_ToVinyl->SetSelection(mToVinyl);
384
385 // Set From Length control.
386 // Set the format first so we can get sample accuracy.
389
390 mbLoopDetect = false;
391
392 return true;
393}

References kVinyl_33AndAThird, kVinyl_NA, mbLoopDetect, mFormat, mFromLength, mFromVinyl, mpChoice_FromVinyl, mpChoice_ToVinyl, mpFromLengthCtrl, mToVinyl, 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 689 of file ChangeSpeed.cpp.

691{
692 auto unwarped = std::min<double>(m_PercentChange, Percentage.max);
693 if (unwarped > 0.0)
694 // Un-warp values above zero to actually go up to kSliderMax.
695 unwarped = pow(m_PercentChange, (1.0 / kSliderWarp));
696
697 // Caution: m_PercentChange could be infinite.
698 int unwarpedi = (int)(unwarped + 0.5);
699 unwarpedi = std::min<int>(unwarpedi, (int)kSliderMax);
700
701 mpSlider_PercentChange->SetValue(unwarpedi);
702}

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

684{
685 mMultiplier = 1 + (m_PercentChange) / 100.0;
686 mpTextCtrl_Multiplier->GetValidator()->TransferToWindow();
687}

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

678{
679 mpTextCtrl_PercentChange->GetValidator()->TransferToWindow();
680}

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

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

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

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

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

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

774{
776}
bool EnableApply(bool enable=true)
Definition: Effect.cpp:613

References Effect::EnableApply(), m_PercentChange, EffectParameter< Structure, Member, Type, Value >::max, EffectParameter< Structure, Member, Type, Value >::min, 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 84 of file ChangeSpeed.h.

Referenced by Process(), and ProcessOne().

◆ mCurT1

double EffectChangeSpeed::mCurT1
private

Definition at line 85 of file ChangeSpeed.h.

Referenced by Process(), and ProcessOne().

◆ mCurTrackNum

int EffectChangeSpeed::mCurTrackNum
private

Definition at line 82 of file ChangeSpeed.h.

Referenced by Process(), and ProcessOne().

◆ mFactor

double EffectChangeSpeed::mFactor
private

Definition at line 92 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

◆ mMaxNewLength

double EffectChangeSpeed::mMaxNewLength
private

Definition at line 83 of file ChangeSpeed.h.

Referenced by Process(), and ProcessOne().

◆ mMultiplier

double EffectChangeSpeed::mMultiplier
private

Definition at line 95 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 105 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 101 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 107 of file ChangeSpeed.h.

◆ mTimeCtrlFormat

int EffectChangeSpeed::mTimeCtrlFormat
private

Definition at line 94 of file ChangeSpeed.h.

◆ mToLength

double EffectChangeSpeed::mToLength
private

◆ mToVinyl

int EffectChangeSpeed::mToVinyl
private

Definition at line 110 of file ChangeSpeed.h.

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

◆ Percentage

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

Definition at line 117 of file ChangeSpeed.h.

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

◆ Symbol

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

Definition at line 30 of file ChangeSpeed.h.

Referenced by GetSymbol().


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