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
 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, const EffectOutputs *pOutputs) 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, 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
 
- 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
 
int ShowClientInterface (wxWindow &parent, wxDialog &dialog, EffectUIValidator *pValidator, bool forceModal) override
 
EffectUIClientInterfaceGetEffectUIClientInterface () override
 Returns the EffectUIClientInterface instance for this effect. More...
 
std::unique_ptr< EffectUIValidatorPopulateUI (ShuttleGui &S, EffectInstance &instance, EffectSettingsAccess &access, const EffectOutputs *pOutputs) 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
 
OptionalMessage 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
 
OptionalMessage 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
 
void SetTracks (TrackList *pTracks)
 
- Public Member Functions inherited from EffectUIClientInterface
virtual ~EffectUIClientInterface ()
 
virtual int ShowClientInterface (wxWindow &parent, wxDialog &dialog, EffectUIValidator *pValidator, bool forceModal=false)=0
 
virtual bool IsGraphicalUI ()=0
 
virtual std::unique_ptr< EffectUIValidatorPopulateUI (ShuttleGui &S, EffectInstance &instance, EffectSettingsAccess &access, const EffectOutputs *pOutputs)=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 OptionalMessage ImportPresets (EffectSettings &settings)=0
 
virtual bool HasOptions ()=0
 
virtual void ShowOptions ()=0
 
virtual bool ValidateUI (EffectSettings &settings)=0
 
virtual bool CloseUI ()=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 EffectUIClientInterfaceGetEffectUIClientInterface ()=0
 Returns the EffectUIClientInterface instance for this effect. More...
 
virtual void Preview (EffectSettingsAccess &access, bool dryOnly)=0
 
virtual bool SaveSettingsAsString (const EffectSettings &settings, wxString &parms) const =0
 
virtual OptionalMessage LoadSettingsFromString (const wxString &parms, EffectSettings &settings) const =0
 
virtual bool IsBatchProcessing () const =0
 
virtual void SetBatchProcessing ()=0
 
virtual void UnsetBatchProcessing ()=0
 
virtual bool DoEffect (EffectSettings &settings, 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...
 
- 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
 

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 StatefulEffectBase
using MessagePackage = EffectInstance::MessagePackage
 
- 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, const EffectOutputs *pOutputs)
 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
 
- 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 }
 
- 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:222
const EffectParameterMethods & Parameters() const override
Definition: ChangeSpeed.cpp:68
NumericFormatSymbol mFormat
Definition: ChangeSpeed.h:113
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:89

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

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 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:109
double mT0
Definition: EffectBase.h:108

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:26
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 612 of file ChangeSpeed.cpp.

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

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

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

577{
578 if (mbLoopDetect)
579 return;
580
581 mpTextCtrl_Multiplier->GetValidator()->TransferFromWindow();
582 m_PercentChange = 100 * (mMultiplier - 1);
583 UpdateUI();
584
585 mbLoopDetect = true;
588 Update_Vinyl();
590 mbLoopDetect = false;
591}
wxTextCtrl * mpTextCtrl_Multiplier
Definition: ChangeSpeed.h:102

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

561{
562 if (mbLoopDetect)
563 return;
564
565 mpTextCtrl_PercentChange->GetValidator()->TransferFromWindow();
566 UpdateUI();
567
568 mbLoopDetect = true;
571 Update_Vinyl();
573 mbLoopDetect = false;
574}
wxTextCtrl * mpTextCtrl_PercentChange
Definition: ChangeSpeed.h:101

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

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

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

675{
677 NumericConverter::TIME, evt.GetString() );
678
680 // Update From/To Length controls (precision has changed).
683}
NumericTextCtrl * mpFromLengthCtrl
Definition: ChangeSpeed.h:106
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:118

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,
const EffectOutputs pOutputs 
)
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 241 of file ChangeSpeed.cpp.

244{
245 {
246 wxString formatId;
249 wxT("TimeFormat"), formatId, mFormat.Internal());
251 NumericConverter::TIME, formatId );
252 }
255 wxT("VinylChoice"), mFromVinyl, mFromVinyl);
256
257 S.SetBorder(5);
258
259 S.StartVerticalLay(0);
260 {
261 S.AddSpace(0, 5);
262 S.AddTitle(XO("Change Speed, affecting both Tempo and Pitch"));
263 S.AddSpace(0, 10);
264
265 // Speed multiplier and percent change controls.
266 S.StartMultiColumn(4, wxCENTER);
267 {
269 .Validator<FloatingPointValidator<double>>(
270 3, &mMultiplier,
271 NumValidatorStyle::THREE_TRAILING_ZEROES,
272 Percentage.min / 100.0, ((Percentage.max / 100.0) + 1) )
273 .AddTextBox(XXO("&Speed Multiplier:"), L"", 12);
274
276 .Validator<FloatingPointValidator<double>>(
277 3, &m_PercentChange,
278 NumValidatorStyle::THREE_TRAILING_ZEROES,
280 .AddTextBox(XXO("Percent C&hange:"), L"", 12);
281 }
282 S.EndMultiColumn();
283
284 // Percent change slider.
285 S.StartHorizontalLay(wxEXPAND);
286 {
288 .Name(XO("Percent Change"))
289 .Style(wxSL_HORIZONTAL)
290 .AddSlider( {}, 0, (int)kSliderMax, (int)Percentage.min);
291 }
292 S.EndHorizontalLay();
293
294 // Vinyl rpm controls.
295 S.StartMultiColumn(5, wxCENTER);
296 {
297 /* i18n-hint: "rpm" is an English abbreviation meaning "revolutions per minute".
298 "vinyl" refers to old-fashioned phonograph records */
299 S.AddUnits(XO("Standard Vinyl rpm:"));
300
302 /* i18n-hint: changing speed of audio "from" one value "to" another
303 "rpm" means "revolutions per minute" as on a vinyl record turntable
304 */
305 .Name(XO("From rpm"))
306 .MinSize( { 100, -1 } )
307 /* i18n-hint: changing speed of audio "from" one value "to" another */
308 .AddChoice(XXC("&from", "change speed"), kVinylStrings);
309
311 /* i18n-hint: changing speed of audio "from" one value "to" another
312 "rpm" means "revolutions per minute" as on a vinyl record turntable
313 */
314 .Name(XO("To rpm"))
315 .MinSize( { 100, -1 } )
316 /* i18n-hint: changing speed of audio "from" one value "to" another */
317 .AddChoice(XXC("&to", "change speed"), kVinylStrings);
318 }
319 S.EndMultiColumn();
320
321 // From/To time controls.
322 S.StartStatic(XO("Selection Length"), 0);
323 {
324 S.StartMultiColumn(2, wxALIGN_LEFT);
325 {
326 S.AddPrompt(XXO("C&urrent Length:"));
327
329 NumericTextCtrl(S.GetParent(), wxID_ANY,
331 mFormat,
335 .ReadOnly(true)
336 .MenuEnabled(false));
337
338 S.ToolTip(XO("Current length of selection."))
339 /* i18n-hint: changing speed of audio "from" one value "to" another */
340 .Name(XC("from", "change speed"))
341 .Position(wxALIGN_LEFT)
342 .AddWindow(mpFromLengthCtrl);
343
344 S.AddPrompt(XXO("&New Length:"));
345
347 NumericTextCtrl(S.GetParent(), ID_ToLength,
349 mFormat,
350 mToLength,
352
353 /* i18n-hint: changing speed of audio "from" one value "to" another */
354 S.Name(XC("to", "change speed"))
355 .Position(wxALIGN_LEFT)
356 .AddWindow(mpToLengthCtrl);
357 }
358 S.EndMultiColumn();
359 }
360 S.EndStatic();
361 }
362 S.EndVerticalLay();
363 return nullptr;
364}
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:101
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, wxT(), 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 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:107
void ReplaceProcessedTracks(const bool bGoodResult)
Definition: EffectBase.cpp:240
bool ProcessOne(WaveTrack *t, sampleCount start, sampleCount end)
double mMaxNewLength
Definition: ChangeSpeed.h:84
bool ProcessLabelTrack(LabelTrack *t)
void CopyInputTracks(bool allSyncLockSelected=false)
Definition: Effect.cpp:733
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:2005
double GetEndTime() const override
Get the time at which the last clip in the track ends, plus recorded stuff.
Definition: WaveTrack.cpp:2025
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 425 of file ChangeSpeed.cpp.

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

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

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

References CurrentSettingsGroup(), Effect::GetDefinition(), ComponentInterfaceSymbol::Internal(), m_PercentChange, mFormat, mFromVinyl, Effect::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.

Implements EffectPlugin.

Definition at line 366 of file ChangeSpeed.cpp.

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

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

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

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

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

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

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

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

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

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

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

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

785{
787}
bool EnableApply(bool enable=true)
Definition: Effect.cpp:612

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

Referenced by Process(), and ProcessOne().

◆ mCurT1

double EffectChangeSpeed::mCurT1
private

Definition at line 86 of file ChangeSpeed.h.

Referenced by Process(), and ProcessOne().

◆ mCurTrackNum

int EffectChangeSpeed::mCurTrackNum
private

Definition at line 83 of file ChangeSpeed.h.

Referenced by Process(), and ProcessOne().

◆ mFactor

double EffectChangeSpeed::mFactor
private

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

Referenced by Process(), and ProcessOne().

◆ mMultiplier

double EffectChangeSpeed::mMultiplier
private

Definition at line 96 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 106 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 102 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 108 of file ChangeSpeed.h.

◆ mTimeCtrlFormat

int EffectChangeSpeed::mTimeCtrlFormat
private

Definition at line 95 of file ChangeSpeed.h.

◆ mToLength

double EffectChangeSpeed::mToLength
private

◆ mToVinyl

int EffectChangeSpeed::mToVinyl
private

Definition at line 111 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 118 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: