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...
 
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)
 Re-invoke DoEffect on another Effect object that implements the work. More...
 
- Public Member Functions inherited from EffectBase
 EffectBase ()
 
 ~EffectBase () override
 
void SetTracks (TrackList *pTracks)
 
bool DoEffect (EffectSettings &settings, const InstanceFinder &finder, double projectRate, TrackList *list, WaveTrackFactory *factory, NotifyingSelectedRegion &selectedRegion, unsigned flags, const EffectSettingsAccessPtr &pAccess) override
 
- 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 void Preview (EffectSettingsAccess &access, std::function< void()> updateUI, bool dryOnly)=0
 Calculate temporary tracks of limited length with effect applied and play. More...
 
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 (EffectPlugin &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 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 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") }
 
- 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

wxWeakRef< wxWindow > mUIParent {}
 
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 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
TrackListmTracks {}
 
- 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, const WaveTrack *pRight, sampleCount *start, sampleCount *len)
 
void CopyInputTracks (bool allSyncLockSelected=false)
 
TrackAddToOutputTracks (const std::shared_ptr< Track > &t)
 
- Protected Member Functions inherited from EffectBase
virtual std::any BeginPreview (const EffectSettings &settings)
 Called when Preview() starts, to allow temporary effect state changes. More...
 
void Preview (EffectSettingsAccess &access, std::function< void()> updateUI, bool dryOnly) final
 Calculate temporary tracks of limited length with effect applied and play. 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
 
- Protected Attributes inherited from EffectBase
BasicUI::ProgressDialogmProgress {}
 
double mProjectRate {}
 
WaveTrackFactorymFactory {}
 
std::shared_ptr< TrackListmOutputTracks
 
double mT0 {}
 
double mT1 {}
 
wxArrayString mPresetNames
 
unsigned mUIFlags { 0 }
 
- Static Protected Attributes inherited from EffectBase
static int nEffectsDone = 0
 

Detailed Description

An Effect that affects both pitch & speed.

Definition at line 27 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:214
const EffectParameterMethods & Parameters() const override
Definition: ChangeSpeed.cpp:68
NumericFormatSymbol mFormat
Definition: ChangeSpeed.h:117
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 164 of file ChangeSpeed.cpp.

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

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

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

References m_PercentChange.

◆ DoLoadFactoryDefaults()

OptionalMessage EffectChangeSpeed::DoLoadFactoryDefaults ( EffectSettings settings)

Definition at line 149 of file ChangeSpeed.cpp.

150{
153
155}
static Settings & settings()
Definition: TrackInfo.cpp:87
OptionalMessage LoadFactoryDefaults(EffectSettings &settings) const override
Definition: Effect.cpp:173

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 31 of file ChangeSpeed.h.

31{ 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}
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 119 of file ChangeSpeed.cpp.

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

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

Default implementation does nothing, returns true

Reimplemented from StatefulEffectBase.

Definition at line 170 of file ChangeSpeed.cpp.

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

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 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:28
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 129 of file ChangeSpeed.cpp.

130{
131 return L"Change_Speed";
132}

◆ OnChoice_Vinyl()

void EffectChangeSpeed::OnChoice_Vinyl ( wxCommandEvent &  evt)
private

Definition at line 614 of file ChangeSpeed.cpp.

615{
616 // Treat mpChoice_FromVinyl and mpChoice_ToVinyl as one control since we need
617 // both to calculate Percent Change.
618 mFromVinyl = mpChoice_FromVinyl->GetSelection();
619 mToVinyl = mpChoice_ToVinyl->GetSelection();
620 // Use this as the 'preferred' choice.
621 if (mFromVinyl != kVinyl_NA) {
623 CurrentSettingsGroup(), wxT("VinylChoice"), mFromVinyl);
624 }
625
626 // If mFromVinyl & mToVinyl are set, then there's a NEW percent change.
627 if ((mFromVinyl != kVinyl_NA) && (mToVinyl != kVinyl_NA))
628 {
629 double fromRPM;
630 double toRPM;
631 switch (mFromVinyl) {
632 default:
633 case kVinyl_33AndAThird: fromRPM = 33.0 + (1.0 / 3.0); break;
634 case kVinyl_45: fromRPM = 45.0; break;
635 case kVinyl_78: fromRPM = 78; break;
636 }
637 switch (mToVinyl) {
638 default:
639 case kVinyl_33AndAThird: toRPM = 33.0 + (1.0 / 3.0); break;
640 case kVinyl_45: toRPM = 45.0; break;
641 case kVinyl_78: toRPM = 78; break;
642 }
643 m_PercentChange = ((toRPM * 100.0) / fromRPM) - 100.0;
644 UpdateUI();
645
646 mbLoopDetect = true;
651 }
652 mbLoopDetect = false;
653}
wxT("CloseDown"))
@ 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:109
void Update_Text_PercentChange()
wxChoice * mpChoice_FromVinyl
Definition: ChangeSpeed.h:108
void Update_Text_Multiplier()
const EffectSettingsManager & GetDefinition() const override
Definition: Effect.cpp:190
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 595 of file ChangeSpeed.cpp.

596{
597 if (mbLoopDetect)
598 return;
599
600 m_PercentChange = (double)(mpSlider_PercentChange->GetValue());
601 // Warp positive values to actually go up faster & further than negatives.
602 if (m_PercentChange > 0.0)
604 UpdateUI();
605
606 mbLoopDetect = true;
609 Update_Vinyl();
611 mbLoopDetect = false;
612}
static const double kSliderWarp
Definition: ChangeSpeed.cpp:78
wxSlider * mpSlider_PercentChange
Definition: ChangeSpeed.h:107

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

579{
580 if (mbLoopDetect)
581 return;
582
583 mpTextCtrl_Multiplier->GetValidator()->TransferFromWindow();
584 m_PercentChange = 100 * (mMultiplier - 1);
585 UpdateUI();
586
587 mbLoopDetect = true;
590 Update_Vinyl();
592 mbLoopDetect = false;
593}
wxTextCtrl * mpTextCtrl_Multiplier
Definition: ChangeSpeed.h:106

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

563{
564 if (mbLoopDetect)
565 return;
566
567 mpTextCtrl_PercentChange->GetValidator()->TransferFromWindow();
568 UpdateUI();
569
570 mbLoopDetect = true;
573 Update_Vinyl();
575 mbLoopDetect = false;
576}
wxTextCtrl * mpTextCtrl_PercentChange
Definition: ChangeSpeed.h:105

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

656{
657 if (mbLoopDetect)
658 return;
659
661 // Division by (double) 0.0 is not an error and we want to show "infinite" in
662 // text controls, so take care that we handle infinite values when they occur.
663 m_PercentChange = ((mFromLength * 100.0) / mToLength) - 100.0;
664 UpdateUI();
665
666 mbLoopDetect = true;
667
671 Update_Vinyl();
672
673 mbLoopDetect = false;
674}
NumericTextCtrl * mpToLengthCtrl
Definition: ChangeSpeed.h:111

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

677{
679 NumericConverter::TIME, evt.GetString() );
680
682 // Update From/To Length controls (precision has changed).
685}
NumericTextCtrl * mpFromLengthCtrl
Definition: ChangeSpeed.h:110
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:122

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

244{
245 mUIParent = S.GetParent();
246
247 {
248 wxString formatId;
251 wxT("TimeFormat"), formatId, mFormat.Internal());
253 NumericConverter::TIME, formatId );
254 }
257 wxT("VinylChoice"), mFromVinyl, mFromVinyl);
258
259 S.SetBorder(5);
260
261 S.StartVerticalLay(0);
262 {
263 S.AddSpace(0, 5);
264 S.AddTitle(XO("Change Speed, affecting both Tempo and Pitch"));
265 S.AddSpace(0, 10);
266
267 // Speed multiplier and percent change controls.
268 S.StartMultiColumn(4, wxCENTER);
269 {
271 .Validator<FloatingPointValidator<double>>(
272 3, &mMultiplier,
273 NumValidatorStyle::THREE_TRAILING_ZEROES,
274 Percentage.min / 100.0, ((Percentage.max / 100.0) + 1) )
275 .AddTextBox(XXO("&Speed Multiplier:"), L"", 12);
276
278 .Validator<FloatingPointValidator<double>>(
279 3, &m_PercentChange,
280 NumValidatorStyle::THREE_TRAILING_ZEROES,
282 .AddTextBox(XXO("Percent C&hange:"), L"", 12);
283 }
284 S.EndMultiColumn();
285
286 // Percent change slider.
287 S.StartHorizontalLay(wxEXPAND);
288 {
290 .Name(XO("Percent Change"))
291 .Style(wxSL_HORIZONTAL)
292 .AddSlider( {}, 0, (int)kSliderMax, (int)Percentage.min);
293 }
294 S.EndHorizontalLay();
295
296 // Vinyl rpm controls.
297 S.StartMultiColumn(5, wxCENTER);
298 {
299 /* i18n-hint: "rpm" is an English abbreviation meaning "revolutions per minute".
300 "vinyl" refers to old-fashioned phonograph records */
301 S.AddUnits(XO("Standard Vinyl rpm:"));
302
304 /* i18n-hint: changing speed of audio "from" one value "to" another
305 "rpm" means "revolutions per minute" as on a vinyl record turntable
306 */
307 .Name(XO("From rpm"))
308 .MinSize( { 100, -1 } )
309 /* i18n-hint: changing speed of audio "from" one value "to" another */
310 .AddChoice(XXC("&from", "change speed"), kVinylStrings);
311
313 /* i18n-hint: changing speed of audio "from" one value "to" another
314 "rpm" means "revolutions per minute" as on a vinyl record turntable
315 */
316 .Name(XO("To rpm"))
317 .MinSize( { 100, -1 } )
318 /* i18n-hint: changing speed of audio "from" one value "to" another */
319 .AddChoice(XXC("&to", "change speed"), kVinylStrings);
320 }
321 S.EndMultiColumn();
322
323 // From/To time controls.
324 S.StartStatic(XO("Selection Length"), 0);
325 {
326 S.StartMultiColumn(2, wxALIGN_LEFT);
327 {
328 S.AddPrompt(XXO("C&urrent Length:"));
329
331 NumericTextCtrl(S.GetParent(), wxID_ANY,
333 mFormat,
337 .ReadOnly(true)
338 .MenuEnabled(false));
339
340 S.ToolTip(XO("Current length of selection."))
341 /* i18n-hint: changing speed of audio "from" one value "to" another */
342 .Name(XC("from", "change speed"))
343 .Position(wxALIGN_LEFT)
344 .AddWindow(mpFromLengthCtrl);
345
346 S.AddPrompt(XXO("&New Length:"));
347
349 NumericTextCtrl(S.GetParent(), ID_ToLength,
351 mFormat,
352 mToLength,
354
355 /* i18n-hint: changing speed of audio "from" one value "to" another */
356 S.Name(XC("to", "change speed"))
357 .Position(wxALIGN_LEFT)
358 .AddWindow(mpToLengthCtrl);
359 }
360 S.EndMultiColumn();
361 }
362 S.EndStatic();
363 }
364 S.EndVerticalLay();
365 return nullptr;
366}
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
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
double mProjectRate
Definition: EffectBase.h:105
wxWeakRef< wxWindow > mUIParent
Definition: ChangeSpeed.h:84
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 & 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, mUIParent, Percentage, PluginSettings::Private, NumericTextCtrl::Options::ReadOnly(), S, safenew, NumericConverter::TIME, 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 178 of file ChangeSpeed.cpp.

179{
180 // Similar to EffectSoundTouch::Process()
181
182 // Iterate over each track.
183 // All needed because this effect needs to introduce
184 // silence in the sync-lock group tracks to keep sync
185 CopyInputTracks(true); // Set up mOutputTracks.
186 bool bGoodResult = true;
187
188 mCurTrackNum = 0;
189 mMaxNewLength = 0.0;
190
191 mFactor = 100.0 / (100.0 + m_PercentChange);
192
193 mOutputTracks->Any().VisitWhile( bGoodResult,
194 [&](LabelTrack *lt) {
196 {
197 if (!ProcessLabelTrack(lt))
198 bGoodResult = false;
199 }
200 },
201 [&](WaveTrack *pOutWaveTrack, const Track::Fallthrough &fallthrough) {
202 if (!pOutWaveTrack->GetSelected())
203 return fallthrough();
204
205 //Get start and end times from track
206 mCurT0 = pOutWaveTrack->GetStartTime();
207 mCurT1 = pOutWaveTrack->GetEndTime();
208
209 //Set the current bounds to whichever left marker is
210 //greater and whichever right marker is less:
211 mCurT0 = wxMax(mT0, mCurT0);
212 mCurT1 = wxMin(mT1, mCurT1);
213
214 // Process only if the right marker is to the right of the left marker
215 if (mCurT1 > mCurT0) {
216 //Transform the marker timepoints to samples
217 auto start = pOutWaveTrack->TimeToLongSamples(mCurT0);
218 auto end = pOutWaveTrack->TimeToLongSamples(mCurT1);
219
220 //ProcessOne() (implemented below) processes a single track
221 if (!ProcessOne(pOutWaveTrack, start, end))
222 bGoodResult = false;
223 }
224 mCurTrackNum++;
225 },
226 [&](Track *t) {
228 t->SyncLockAdjust(mT1, mT0 + (mT1 - mT0) * mFactor);
229 }
230 );
231
232 if (bGoodResult)
233 ReplaceProcessedTracks(bGoodResult);
234
235 // Update selection.
236 mT1 = mT0 + (((mT1 - mT0) * 100.0) / (100.0 + m_PercentChange));
237
238 return bGoodResult;
239}
std::shared_ptr< TrackList > mOutputTracks
Definition: EffectBase.h:111
void ReplaceProcessedTracks(const bool bGoodResult)
Definition: EffectBase.cpp:232
bool ProcessOne(WaveTrack *t, sampleCount start, sampleCount end)
double mMaxNewLength
Definition: ChangeSpeed.h:88
bool ProcessLabelTrack(LabelTrack *t)
void CopyInputTracks(bool allSyncLockSelected=false)
Definition: Effect.cpp:396
A LabelTrack is a Track that holds labels (LabelStruct).
Definition: LabelTrack.h:87
sampleCount TimeToLongSamples(double t0) const
Convert correctly between an (absolute) time in seconds and a number of samples.
Definition: SampleTrack.cpp:43
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:226
bool GetSelected() const
Definition: Track.h:470
Continuation<> Fallthrough
Type of arguments passed as optional second parameter to TypeSwitch<void>() cases.
Definition: Track.h:542
A Track that contains audio waveform data.
Definition: WaveTrack.h:51
double GetStartTime() const override
Get the time at which the first clip in the track starts.
Definition: WaveTrack.cpp:1802
double GetEndTime() const override
Get the time at which the last clip in the track ends, plus recorded stuff.
Definition: WaveTrack.cpp:1822
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 427 of file ChangeSpeed.cpp.

428{
429 RegionTimeWarper warper { mT0, mT1,
430 std::make_unique<LinearTimeWarper>(mT0, mT0,
431 mT1, mT0 + (mT1-mT0)*mFactor) };
432 lt->WarpLabels(warper);
433 return true;
434}
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 438 of file ChangeSpeed.cpp.

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

Reimplemented from StatefulEffectUIServices.

Definition at line 404 of file ChangeSpeed.cpp.

405{
406 // mUIParent->TransferDataFromWindow() loses some precision, so save and restore it.
407 double exactPercent = m_PercentChange;
408 if (!mUIParent->Validate() || !mUIParent->TransferDataFromWindow())
409 {
410 return false;
411 }
412 m_PercentChange = exactPercent;
413
414 // TODO: just visit these effect settings the default way
416 CurrentSettingsGroup(), wxT("TimeFormat"), mFormat.Internal());
418 CurrentSettingsGroup(), wxT("VinylChoice"), mFromVinyl);
419
420 return true;
421}

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

369{
370 mbLoopDetect = true;
371
372 if (!mUIParent->TransferDataToWindow())
373 {
374 return false;
375 }
376
377 if (mFromVinyl == kVinyl_NA)
378 {
380 }
381
386
387 // Set from/to Vinyl controls - mFromVinyl must be set first.
388 mpChoice_FromVinyl->SetSelection(mFromVinyl);
389 // Then update to get correct mToVinyl.
390 Update_Vinyl();
391 // Then update ToVinyl control.
392 mpChoice_ToVinyl->SetSelection(mToVinyl);
393
394 // Set From Length control.
395 // Set the format first so we can get sample accuracy.
398
399 mbLoopDetect = false;
400
401 return true;
402}

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

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

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

697{
698 mMultiplier = 1 + (m_PercentChange) / 100.0;
699 mpTextCtrl_Multiplier->GetValidator()->TransferToWindow();
700}

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

691{
692 mpTextCtrl_PercentChange->GetValidator()->TransferToWindow();
693}

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

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

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

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

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

787{
790}
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 89 of file ChangeSpeed.h.

Referenced by Process(), and ProcessOne().

◆ mCurT1

double EffectChangeSpeed::mCurT1
private

Definition at line 90 of file ChangeSpeed.h.

Referenced by Process(), and ProcessOne().

◆ mCurTrackNum

int EffectChangeSpeed::mCurTrackNum
private

Definition at line 87 of file ChangeSpeed.h.

Referenced by Process(), and ProcessOne().

◆ mFactor

double EffectChangeSpeed::mFactor
private

Definition at line 97 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 88 of file ChangeSpeed.h.

Referenced by Process(), and ProcessOne().

◆ mMultiplier

double EffectChangeSpeed::mMultiplier
private

Definition at line 100 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 110 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 106 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 112 of file ChangeSpeed.h.

◆ mTimeCtrlFormat

int EffectChangeSpeed::mTimeCtrlFormat
private

Definition at line 99 of file ChangeSpeed.h.

◆ mToLength

double EffectChangeSpeed::mToLength
private

◆ mToVinyl

int EffectChangeSpeed::mToVinyl
private

Definition at line 115 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 122 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 32 of file ChangeSpeed.h.

Referenced by GetSymbol().


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