Audacity 3.2.0
Public Member Functions | Private Member Functions | Private Attributes | List of all members
EffectChangeSpeed Class Reference

#include <ChangeSpeed.h>

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

Public Member Functions

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

Private Member Functions

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 ()
 

Private Attributes

wxWeakRef< wxWindow > mUIParent {}
 
wxTextCtrl * mpTextCtrl_PercentChange
 
wxTextCtrl * mpTextCtrl_Multiplier
 
wxSlider * mpSlider_PercentChange
 
wxChoice * mpChoice_FromVinyl
 
wxChoice * mpChoice_ToVinyl
 
NumericTextCtrlmpFromLengthCtrl
 
NumericTextCtrlmpToLengthCtrl
 

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 }
 
- Static Public Member Functions inherited from ChangeSpeedBase
static ChangeSpeedBaseFetchParameters (ChangeSpeedBase &e, EffectSettings &)
 
- Static Public Member Functions inherited from Effect
static EffectFetchParameters (Effect &e, EffectSettings &)
 
- Static Public Member Functions inherited from EffectBase
static std::optional< InstancePointerFindInstance (EffectPlugin &plugin)
 
static InstanceFinder DefaultInstanceFinder (EffectPlugin &plugin)
 
- Static Public Member Functions inherited from EffectDefinitionInterface
static Identifier GetSquashedName (const Identifier &ident)
 A utility that strips spaces and CamelCases a name. More...
 
- Static Public Member Functions inherited from EffectUIServices
static int DoMessageBox (const EffectPlugin &plugin, const TranslatableString &message, long style=DefaultMessageBoxStyle, const TranslatableString &titleStr={})
 
- Public Attributes inherited from EffectBase
std::shared_ptr< TrackListmTracks {}
 
int mNumTracks {}
 
BasicUI::ProgressDialogmProgress {}
 
double mProjectRate {}
 
WaveTrackFactorymFactory {}
 
double mT0 {}
 
double mT1 {}
 
bool mIsPreview { false }
 
- Static Public Attributes inherited from ChangeSpeedBase
static const ComponentInterfaceSymbol Symbol
 
- 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>")
 
- Protected Member Functions inherited from ChangeSpeedBase
const EffectParameterMethodsParameters () const override
 
- Protected Member Functions inherited from Effect
bool CheckWhetherSkipEffect (const EffectSettings &settings) const override
 Default implementation returns false. More...
 
double CalcPreviewInputLength (const EffectSettings &settings, double previewLength) const override
 Default implementation returns previewLength More...
 
bool TotalProgress (double frac, const TranslatableString &={}) const
 
bool TrackProgress (int whichTrack, double frac, const TranslatableString &={}) const
 
bool TrackGroupProgress (int whichGroup, double frac, const TranslatableString &={}) const
 
int GetNumWaveTracks () const
 
int GetNumWaveGroups () const
 
void GetBounds (const WaveTrack &track, sampleCount *start, sampleCount *len)
 
- Protected Member Functions inherited from EffectBase
virtual bool CheckWhetherSkipEffect (const EffectSettings &settings) const =0
 After Init(), tell whether Process() should be skipped. More...
 
void SetLinearEffectFlag (bool linearEffectFlag)
 
void SetPreviewFullSelectionFlag (bool previewDurationFlag)
 
bool IsPreviewing () const
 
const TrackListinputTracks () const
 
const AudacityProjectFindProject () const
 
- Protected Attributes inherited from ChangeSpeedBase
int mCurTrackNum
 
double mCurT0
 
double mCurT1
 
double m_PercentChange
 
int mFromVinyl
 
double mFactor
 
double mFromLength
 
int mTimeCtrlFormat
 
double mMultiplier
 
bool mbLoopDetect
 
double mRate
 
int mToVinyl
 
double mToLength
 
NumericFormatID mFormat
 
- Protected Attributes inherited from EffectBase
double mF0 {}
 
double mF1 {}
 
wxArrayString mPresetNames
 
unsigned mUIFlags { 0 }
 
- Static Protected Attributes inherited from ChangeSpeedBase
static constexpr EffectParameter Percentage
 

Detailed Description

Definition at line 27 of file ChangeSpeed.h.

Member Function Documentation

◆ OnChoice_Vinyl()

void EffectChangeSpeed::OnChoice_Vinyl ( wxCommandEvent &  evt)
private

Definition at line 297 of file ChangeSpeed.cpp.

298{
299 // Treat mpChoice_FromVinyl and mpChoice_ToVinyl as one control since we need
300 // both to calculate Percent Change.
301 mFromVinyl = mpChoice_FromVinyl->GetSelection();
302 mToVinyl = mpChoice_ToVinyl->GetSelection();
303 // Use this as the 'preferred' choice.
304 if (mFromVinyl != kVinyl_NA) {
306 CurrentSettingsGroup(), wxT("VinylChoice"), mFromVinyl);
307 }
308
309 // If mFromVinyl & mToVinyl are set, then there's a NEW percent change.
310 if ((mFromVinyl != kVinyl_NA) && (mToVinyl != kVinyl_NA))
311 {
312 double fromRPM;
313 double toRPM;
314 switch (mFromVinyl) {
315 default:
316 case kVinyl_33AndAThird: fromRPM = 33.0 + (1.0 / 3.0); break;
317 case kVinyl_45: fromRPM = 45.0; break;
318 case kVinyl_78: fromRPM = 78; break;
319 }
320 switch (mToVinyl) {
321 default:
322 case kVinyl_33AndAThird: toRPM = 33.0 + (1.0 / 3.0); break;
323 case kVinyl_45: toRPM = 45.0; break;
324 case kVinyl_78: toRPM = 78; break;
325 }
326 m_PercentChange = ((toRPM * 100.0) / fromRPM) - 100.0;
327 UpdateUI();
328
329 mbLoopDetect = true;
334 }
335 mbLoopDetect = false;
336}
wxT("CloseDown"))
@ kVinyl_78
@ kVinyl_45
@ kVinyl_33AndAThird
@ kVinyl_NA
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:66
void Update_Text_PercentChange()
wxChoice * mpChoice_FromVinyl
Definition: ChangeSpeed.h:65
void Update_Text_Multiplier()
const EffectSettingsManager & GetDefinition() const override
Definition: Effect.cpp:182
bool SetConfig(const EffectDefinitionInterface &ident, ConfigurationType type, const RegistryPath &group, const RegistryPath &key, const Value &value)

References CurrentSettingsGroup(), Effect::GetDefinition(), kVinyl_33AndAThird, kVinyl_45, kVinyl_78, kVinyl_NA, ChangeSpeedBase::m_PercentChange, ChangeSpeedBase::mbLoopDetect, ChangeSpeedBase::mFromVinyl, mpChoice_FromVinyl, mpChoice_ToVinyl, ChangeSpeedBase::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 278 of file ChangeSpeed.cpp.

279{
280 if (mbLoopDetect)
281 return;
282
283 m_PercentChange = (double)(mpSlider_PercentChange->GetValue());
284 // Warp positive values to actually go up faster & further than negatives.
285 if (m_PercentChange > 0.0)
287 UpdateUI();
288
289 mbLoopDetect = true;
292 Update_Vinyl();
294 mbLoopDetect = false;
295}
static const double kSliderWarp
Definition: ChangeSpeed.cpp:50
wxSlider * mpSlider_PercentChange
Definition: ChangeSpeed.h:64

References kSliderWarp, ChangeSpeedBase::m_PercentChange, ChangeSpeedBase::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 261 of file ChangeSpeed.cpp.

262{
263 if (mbLoopDetect)
264 return;
265
266 mpTextCtrl_Multiplier->GetValidator()->TransferFromWindow();
267 m_PercentChange = 100 * (mMultiplier - 1);
268 UpdateUI();
269
270 mbLoopDetect = true;
273 Update_Vinyl();
275 mbLoopDetect = false;
276}
wxTextCtrl * mpTextCtrl_Multiplier
Definition: ChangeSpeed.h:63

References ChangeSpeedBase::m_PercentChange, ChangeSpeedBase::mbLoopDetect, ChangeSpeedBase::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 245 of file ChangeSpeed.cpp.

246{
247 if (mbLoopDetect)
248 return;
249
250 mpTextCtrl_PercentChange->GetValidator()->TransferFromWindow();
251 UpdateUI();
252
253 mbLoopDetect = true;
256 Update_Vinyl();
258 mbLoopDetect = false;
259}
wxTextCtrl * mpTextCtrl_PercentChange
Definition: ChangeSpeed.h:62

References ChangeSpeedBase::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 338 of file ChangeSpeed.cpp.

339{
340 if (mbLoopDetect)
341 return;
342
344 // Division by (double) 0.0 is not an error and we want to show "infinite" in
345 // text controls, so take care that we handle infinite values when they occur.
346 m_PercentChange = ((mFromLength * 100.0) / mToLength) - 100.0;
347 UpdateUI();
348
349 mbLoopDetect = true;
350
354 Update_Vinyl();
355
356 mbLoopDetect = false;
357}
NumericTextCtrl * mpToLengthCtrl
Definition: ChangeSpeed.h:68

References NumericConverter::GetValue(), ChangeSpeedBase::m_PercentChange, ChangeSpeedBase::mbLoopDetect, ChangeSpeedBase::mFromLength, mpToLengthCtrl, ChangeSpeedBase::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 359 of file ChangeSpeed.cpp.

360{
363 NumericConverterType_TIME(), evt.GetString()).Internal();
364
366 // Update From/To Length controls (precision has changed).
369}
const NumericConverterType & NumericConverterType_TIME()
NumericFormatID mFormat
const wxString & Internal() const
double mProjectRate
Definition: EffectBase.h:119
NumericTextCtrl * mpFromLengthCtrl
Definition: ChangeSpeed.h:67
static FormatterContext SampleRateContext(double sampleRate)
bool SetFormatName(const NumericFormatID &formatName)
void SetValue(double newValue)
NUMERIC_FORMATS_API NumericFormatSymbol Lookup(const FormatterContext &context, const NumericConverterType &type, const NumericFormatID &formatIdentifier)
Looks up the format, returns Default for the type if the format is not registered.

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

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

67{
68 mUIParent = S.GetParent();
69
70 {
71 wxString formatId;
74 wxT("TimeFormat"), formatId, mFormat.GET());
78 }
81 wxT("VinylChoice"), mFromVinyl, mFromVinyl);
82
83 S.SetBorder(5);
84
85 S.StartVerticalLay(0);
86 {
87 // Speed multiplier and percent change controls.
88 S.StartMultiColumn(4, wxCENTER);
89 {
91 .Validator<FloatingPointValidator<double>>(
92 3, &mMultiplier,
93 NumValidatorStyle::THREE_TRAILING_ZEROES,
94 Percentage.min / 100.0, ((Percentage.max / 100.0) + 1) )
95 .AddTextBox(XXO("&Speed Multiplier:"), L"", 12);
96
98 .Validator<FloatingPointValidator<double>>(
100 NumValidatorStyle::THREE_TRAILING_ZEROES,
102 .AddTextBox(XXO("Percent C&hange:"), L"", 12);
103 }
104 S.EndMultiColumn();
105
106 // Percent change slider.
107 S.StartHorizontalLay(wxEXPAND);
108 {
110 .Name(XO("Percent Change"))
111 .Style(wxSL_HORIZONTAL)
112 .AddSlider( {}, 0, (int)kSliderMax, (int)Percentage.min);
113 }
114 S.EndHorizontalLay();
115
116 // Vinyl rpm controls.
117 S.StartMultiColumn(5, wxCENTER);
118 {
119 /* i18n-hint: "rpm" is an English abbreviation meaning "revolutions per minute".
120 "vinyl" refers to old-fashioned phonograph records */
121 S.AddUnits(XO("Standard Vinyl rpm:"));
122
124 /* i18n-hint: changing speed of audio "from" one value "to" another
125 "rpm" means "revolutions per minute" as on a vinyl record turntable
126 */
127 .Name(XO("From rpm"))
128 .MinSize( { 100, -1 } )
129 /* i18n-hint: changing speed of audio "from" one value "to" another */
130 .AddChoice(XXC("&from", "change speed"), kVinylStrings);
131
133 /* i18n-hint: changing speed of audio "from" one value "to" another
134 "rpm" means "revolutions per minute" as on a vinyl record turntable
135 */
136 .Name(XO("To rpm"))
137 .MinSize( { 100, -1 } )
138 /* i18n-hint: changing speed of audio "from" one value "to" another */
139 .AddChoice(XXC("&to", "change speed"), kVinylStrings);
140 }
141 S.EndMultiColumn();
142
143 // From/To time controls.
144 S.StartStatic(XO("Selection Length"), 0);
145 {
146 S.StartMultiColumn(2, wxALIGN_LEFT);
147 {
148 S.AddPrompt(XXO("C&urrent Length:"));
149
152 S.GetParent(), wxID_ANY,
154 mFormat,
157 .ReadOnly(true)
158 .MenuEnabled(false));
159
160 S.ToolTip(XO("Current length of selection."))
161 /* i18n-hint: changing speed of audio "from" one value "to" another */
162 .Name(XC("from", "change speed"))
163 .Position(wxALIGN_LEFT)
164 .AddWindow(mpFromLengthCtrl);
165
166 S.AddPrompt(XXO("&New Length:"));
167
170 S.GetParent(), ID_ToLength,
172 mFormat,
173 mToLength);
174
175 /* i18n-hint: changing speed of audio "from" one value "to" another */
176 S.Name(XC("to", "change speed"))
177 .Position(wxALIGN_LEFT)
178 .AddWindow(mpToLengthCtrl);
179 }
180 S.EndMultiColumn();
181 }
182 S.EndStatic();
183 }
184 S.EndVerticalLay();
185 return nullptr;
186}
@ ID_ToLength
Definition: ChangeSpeed.cpp:37
@ ID_FromVinyl
Definition: ChangeSpeed.cpp:35
@ ID_ToVinyl
Definition: ChangeSpeed.cpp:36
@ ID_Multiplier
Definition: ChangeSpeed.cpp:34
@ ID_PercentChange
Definition: ChangeSpeed.cpp:33
static const double kSliderMax
Definition: ChangeSpeed.cpp:49
static const TranslatableStrings kVinylStrings
Definition: ChangeSpeed.cpp:40
XO("Cut/Copy/Paste")
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
static constexpr EffectParameter Percentage
wxWeakRef< wxWindow > mUIParent
Definition: ChangeSpeed.h:59
const wxString & GET() const
Explicit conversion to wxString, meant to be ugly-looking and demanding of a comment why it's correct...
Definition: Identifier.h:66
bool GetConfig(const EffectDefinitionInterface &ident, ConfigurationType type, const RegistryPath &group, const RegistryPath &key, Value &var, const Value &defval)
const Type min
Minimum value.
const Type max
Maximum value.
Options & ReadOnly(bool enable)

References CurrentSettingsGroup(), PluginSettings::GetConfig(), ID_FromVinyl, ID_Multiplier, ID_PercentChange, ID_ToLength, ID_ToVinyl, ComponentInterfaceSymbol::Internal(), kSliderMax, kVinylStrings, NumericConverterFormats::Lookup(), NumericConverterType_TIME(), PluginSettings::Private, NumericTextCtrl::Options::ReadOnly(), S, safenew, FormatterContext::SampleRateContext(), wxT(), XC, XO(), XXC, and XXO().

Here is the call 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 224 of file ChangeSpeed.cpp.

225{
226 // mUIParent->TransferDataFromWindow() loses some precision, so save and restore it.
227 double exactPercent = m_PercentChange;
228 if (!mUIParent->Validate() || !mUIParent->TransferDataFromWindow())
229 {
230 return false;
231 }
232 m_PercentChange = exactPercent;
233
234 // TODO: just visit these effect settings the default way
236 CurrentSettingsGroup(), wxT("TimeFormat"), mFormat.GET());
238 CurrentSettingsGroup(), wxT("VinylChoice"), mFromVinyl);
239
240 return true;
241}

References CurrentSettingsGroup(), Identifier::GET(), Effect::GetDefinition(), ChangeSpeedBase::m_PercentChange, ChangeSpeedBase::mFormat, ChangeSpeedBase::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 188 of file ChangeSpeed.cpp.

189{
190 mbLoopDetect = true;
191
192 if (!mUIParent->TransferDataToWindow())
193 {
194 return false;
195 }
196
197 if (mFromVinyl == kVinyl_NA)
198 {
200 }
201
206
207 // Set from/to Vinyl controls - mFromVinyl must be set first.
208 mpChoice_FromVinyl->SetSelection(mFromVinyl);
209 // Then update to get correct mToVinyl.
210 Update_Vinyl();
211 // Then update ToVinyl control.
212 mpChoice_ToVinyl->SetSelection(mToVinyl);
213
214 // Set From Length control.
215 // Set the format first so we can get sample accuracy.
218
219 mbLoopDetect = false;
220
221 return true;
222}

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

388{
389 auto unwarped = std::min<double>(m_PercentChange, Percentage.max);
390 if (unwarped > 0.0)
391 // Un-warp values above zero to actually go up to kSliderMax.
392 unwarped = pow(m_PercentChange, (1.0 / kSliderWarp));
393
394 // Caution: m_PercentChange could be infinite.
395 int unwarpedi = (int)(unwarped + 0.5);
396 unwarpedi = std::min<int>(unwarpedi, (int)kSliderMax);
397
398 mpSlider_PercentChange->SetValue(unwarpedi);
399}

References kSliderMax, kSliderWarp, ChangeSpeedBase::m_PercentChange, EffectParameter< Structure, Member, Type, Value >::max, mpSlider_PercentChange, and ChangeSpeedBase::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 379 of file ChangeSpeed.cpp.

381{
382 mMultiplier = 1 + (m_PercentChange) / 100.0;
383 mpTextCtrl_Multiplier->GetValidator()->TransferToWindow();
384}

References ChangeSpeedBase::m_PercentChange, ChangeSpeedBase::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 373 of file ChangeSpeed.cpp.

375{
376 mpTextCtrl_PercentChange->GetValidator()->TransferToWindow();
377}

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

457{
458 mToLength = (mFromLength * 100.0) / (100.0 + m_PercentChange);
459
460 // Set the format first so we can get sample accuracy.
462 // Negative times do not make sense.
463 // 359999 = 99h:59m:59s which is a little less disturbing than overflow characters
464 // though it may still look a bit strange with some formats.
465 mToLength = std::clamp<double>(mToLength, 0.0, 359999.0);
467}

References ChangeSpeedBase::m_PercentChange, ChangeSpeedBase::mFormat, ChangeSpeedBase::mFromLength, mpToLengthCtrl, ChangeSpeedBase::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 401 of file ChangeSpeed.cpp.

403{
404 // Match Vinyl rpm when within 0.01% of a standard ratio.
405 // Ratios calculated as: ((toRPM / fromRPM) - 1) * 100 * 100
406
407 // Caution: m_PercentChange could be infinite
408 int ratio = (int)((m_PercentChange * 100) + 0.5);
409
410 switch (ratio)
411 {
412 case 0: // toRPM is the same as fromRPM
413 if (mFromVinyl != kVinyl_NA) {
414 mpChoice_ToVinyl->SetSelection(mpChoice_FromVinyl->GetSelection());
415 } else {
416 // Use the last saved option.
418 CurrentSettingsGroup(), wxT("VinylChoice"), mFromVinyl, 0);
419 mpChoice_FromVinyl->SetSelection(mFromVinyl);
420 mpChoice_ToVinyl->SetSelection(mFromVinyl);
421 }
422 break;
423 case 3500:
425 mpChoice_ToVinyl->SetSelection(kVinyl_45);
426 break;
427 case 13400:
429 mpChoice_ToVinyl->SetSelection(kVinyl_78);
430 break;
431 case -2593:
432 mpChoice_FromVinyl->SetSelection(kVinyl_45);
434 break;
435 case 7333:
436 mpChoice_FromVinyl->SetSelection(kVinyl_45);
437 mpChoice_ToVinyl->SetSelection(kVinyl_78);
438 break;
439 case -5727:
440 mpChoice_FromVinyl->SetSelection(kVinyl_78);
442 break;
443 case -4231:
444 mpChoice_FromVinyl->SetSelection(kVinyl_78);
445 mpChoice_ToVinyl->SetSelection(kVinyl_45);
446 break;
447 default:
448 mpChoice_ToVinyl->SetSelection(kVinyl_NA);
449 }
450 // and update variables.
451 mFromVinyl = mpChoice_FromVinyl->GetSelection();
452 mToVinyl = mpChoice_ToVinyl->GetSelection();
453}

References CurrentSettingsGroup(), PluginSettings::GetConfig(), Effect::GetDefinition(), kVinyl_33AndAThird, kVinyl_45, kVinyl_78, kVinyl_NA, ChangeSpeedBase::m_PercentChange, ChangeSpeedBase::mFromVinyl, mpChoice_FromVinyl, mpChoice_ToVinyl, ChangeSpeedBase::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 469 of file ChangeSpeed.cpp.

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

References EffectEditor::EnableApply(), ChangeSpeedBase::m_PercentChange, EffectParameter< Structure, Member, Type, Value >::max, EffectParameter< Structure, Member, Type, Value >::min, mUIParent, and ChangeSpeedBase::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

◆ mpChoice_FromVinyl

wxChoice* EffectChangeSpeed::mpChoice_FromVinyl
private

Definition at line 65 of file ChangeSpeed.h.

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

◆ mpChoice_ToVinyl

wxChoice* EffectChangeSpeed::mpChoice_ToVinyl
private

Definition at line 66 of file ChangeSpeed.h.

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

◆ mpFromLengthCtrl

NumericTextCtrl* EffectChangeSpeed::mpFromLengthCtrl
private

Definition at line 67 of file ChangeSpeed.h.

Referenced by OnTimeCtrlUpdate(), and TransferDataToWindow().

◆ mpSlider_PercentChange

wxSlider* EffectChangeSpeed::mpSlider_PercentChange
private

Definition at line 64 of file ChangeSpeed.h.

Referenced by OnSlider_PercentChange(), and Update_Slider_PercentChange().

◆ mpTextCtrl_Multiplier

wxTextCtrl* EffectChangeSpeed::mpTextCtrl_Multiplier
private

Definition at line 63 of file ChangeSpeed.h.

Referenced by OnText_Multiplier(), and Update_Text_Multiplier().

◆ mpTextCtrl_PercentChange

wxTextCtrl* EffectChangeSpeed::mpTextCtrl_PercentChange
private

Definition at line 62 of file ChangeSpeed.h.

Referenced by OnText_PercentChange(), and Update_Text_PercentChange().

◆ mpToLengthCtrl

NumericTextCtrl* EffectChangeSpeed::mpToLengthCtrl
private

Definition at line 68 of file ChangeSpeed.h.

Referenced by OnTimeCtrl_ToLength(), OnTimeCtrlUpdate(), and Update_TimeCtrl_ToLength().

◆ mUIParent

wxWeakRef<wxWindow> EffectChangeSpeed::mUIParent {}
private

Definition at line 59 of file ChangeSpeed.h.

Referenced by TransferDataFromWindow(), TransferDataToWindow(), and UpdateUI().


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