Audacity  2.2.2
Public Member Functions | Private Member Functions | Private Attributes | List of all members
EffectChangeSpeed Class Referencefinal

An Effect that affects both pitch & speed. More...

#include <ChangeSpeed.h>

Inheritance diagram for EffectChangeSpeed:
Effect EffectClientInterface EffectUIClientInterface EffectHostInterface EffectDefinitionInterface ConfigClientInterface IdentInterface ParamsInterface

Public Member Functions

 EffectChangeSpeed ()
 
virtual ~EffectChangeSpeed ()
 
IdentInterfaceSymbol GetSymbol () override
 
wxString GetDescription () override
 
wxString ManualPage () override
 
EffectType GetType () override
 
bool DefineParams (ShuttleParams &S) override
 
bool GetAutomationParameters (CommandParameters &parms) override
 
bool SetAutomationParameters (CommandParameters &parms) override
 
bool LoadFactoryDefaults () override
 
bool CheckWhetherSkipEffect () override
 
double CalcPreviewInputLength (double previewLength) override
 
bool Startup () override
 
bool Init () override
 
bool Process () override
 
void PopulateOrExchange (ShuttleGui &S) override
 
bool TransferDataFromWindow () override
 
bool TransferDataToWindow () override
 
- Public Member Functions inherited from Effect
 Effect ()
 
virtual ~Effect ()
 
wxString GetPath () override
 
IdentInterfaceSymbol GetSymbol () override
 
IdentInterfaceSymbol GetVendor () override
 
wxString GetVersion () override
 
wxString GetDescription () override
 
EffectType GetType () override
 
IdentInterfaceSymbol GetFamilyId () override
 
bool IsInteractive () override
 
bool IsDefault () override
 
bool IsLegacy () override
 
bool SupportsRealtime () override
 
bool SupportsAutomation () override
 
bool SetHost (EffectHostInterface *host) override
 
unsigned GetAudioInCount () override
 
unsigned GetAudioOutCount () override
 
int GetMidiInCount () override
 
int GetMidiOutCount () override
 
sampleCount GetLatency () override
 
size_t GetTailSize () override
 
void SetSampleRate (double rate) override
 
size_t SetBlockSize (size_t maxBlockSize) override
 
bool IsReady () override
 
bool ProcessInitialize (sampleCount totalLen, ChannelNames chanMap=NULL) override
 
bool ProcessFinalize () override
 
size_t ProcessBlock (float **inBlock, float **outBlock, size_t blockLen) override
 
bool RealtimeInitialize () override
 
bool RealtimeAddProcessor (unsigned numChannels, float sampleRate) override
 
bool RealtimeFinalize () override
 
bool RealtimeSuspend () override
 
bool RealtimeResume () override
 
bool RealtimeProcessStart () override
 
size_t RealtimeProcess (int group, float **inbuf, float **outbuf, size_t numSamples) override
 
bool RealtimeProcessEnd () override
 
bool ShowInterface (wxWindow *parent, bool forceModal=false) override
 
bool GetAutomationParameters (CommandParameters &parms) override
 
bool SetAutomationParameters (CommandParameters &parms) override
 
bool LoadUserPreset (const wxString &name) override
 
bool SaveUserPreset (const wxString &name) override
 
wxArrayString GetFactoryPresets () override
 
bool LoadFactoryPreset (int id) override
 
bool LoadFactoryDefaults () override
 
void SetHostUI (EffectUIHostInterface *host) override
 
bool PopulateUI (wxWindow *parent) override
 
bool IsGraphicalUI () override
 
bool ValidateUI () override
 
bool HideUI () override
 
bool CloseUI () override
 
bool CanExportPresets () override
 
void ExportPresets () override
 
void ImportPresets () override
 
bool HasOptions () override
 
void ShowOptions () override
 
double GetDefaultDuration () override
 
double GetDuration () override
 
NumericFormatId GetDurationFormat () override
 
virtual NumericFormatId GetSelectionFormat ()
 
void SetDuration (double duration) override
 
bool Apply () override
 
void Preview () override
 
wxDialog * CreateUI (wxWindow *parent, EffectUIClientInterface *client) override
 
wxString GetUserPresetsGroup (const wxString &name) override
 
wxString GetCurrentSettingsGroup () override
 
wxString GetFactoryDefaultsGroup () override
 
virtual wxString GetSavedStateGroup ()
 
bool HasSharedConfigGroup (const wxString &group) override
 
bool GetSharedConfigSubgroups (const wxString &group, wxArrayString &subgroups) override
 
bool GetSharedConfig (const wxString &group, const wxString &key, wxString &value, const wxString &defval=wxEmptyString) override
 
bool GetSharedConfig (const wxString &group, const wxString &key, int &value, int defval=0) override
 
bool GetSharedConfig (const wxString &group, const wxString &key, bool &value, bool defval=false) override
 
bool GetSharedConfig (const wxString &group, const wxString &key, float &value, float defval=0.0) override
 
bool GetSharedConfig (const wxString &group, const wxString &key, double &value, double defval=0.0) override
 
bool SetSharedConfig (const wxString &group, const wxString &key, const wxString &value) override
 
bool SetSharedConfig (const wxString &group, const wxString &key, const int &value) override
 
bool SetSharedConfig (const wxString &group, const wxString &key, const bool &value) override
 
bool SetSharedConfig (const wxString &group, const wxString &key, const float &value) override
 
bool SetSharedConfig (const wxString &group, const wxString &key, const double &value) override
 
bool RemoveSharedConfigSubgroup (const wxString &group) override
 
bool RemoveSharedConfig (const wxString &group, const wxString &key) override
 
bool HasPrivateConfigGroup (const wxString &group) override
 
bool GetPrivateConfigSubgroups (const wxString &group, wxArrayString &subgroups) override
 
bool GetPrivateConfig (const wxString &group, const wxString &key, wxString &value, const wxString &defval=wxEmptyString) override
 
bool GetPrivateConfig (const wxString &group, const wxString &key, int &value, int defval=0) override
 
bool GetPrivateConfig (const wxString &group, const wxString &key, bool &value, bool defval=false) override
 
bool GetPrivateConfig (const wxString &group, const wxString &key, float &value, float defval=0.0) override
 
bool GetPrivateConfig (const wxString &group, const wxString &key, double &value, double defval=0.0) override
 
bool SetPrivateConfig (const wxString &group, const wxString &key, const wxString &value) override
 
bool SetPrivateConfig (const wxString &group, const wxString &key, const int &value) override
 
bool SetPrivateConfig (const wxString &group, const wxString &key, const bool &value) override
 
bool SetPrivateConfig (const wxString &group, const wxString &key, const float &value) override
 
bool SetPrivateConfig (const wxString &group, const wxString &key, const double &value) override
 
bool RemovePrivateConfigSubgroup (const wxString &group) override
 
bool RemovePrivateConfig (const wxString &group, const wxString &key) override
 
virtual PluginID GetID ()
 
virtual bool Startup (EffectClientInterface *client)
 
virtual bool GetAutomationParameters (wxString &parms)
 
virtual bool SetAutomationParameters (const wxString &parms)
 
virtual wxArrayString GetUserPresets ()
 
virtual bool HasCurrentSettings ()
 
virtual bool HasFactoryDefaults ()
 
virtual wxString GetPreset (wxWindow *parent, const wxString &parms)
 
virtual wxString HelpPage ()
 
virtual bool IsBatchProcessing ()
 
virtual void SetBatchProcessing (bool start)
 
void SetPresetParameters (const wxArrayString *Names, const wxArrayString *Values)
 
bool DoEffect (wxWindow *parent, double projectRate, TrackList *list, TrackFactory *factory, SelectedRegion *selectedRegion, bool shouldPrompt=true)
 
bool Delegate (Effect &delegate, wxWindow *parent, bool shouldPrompt)
 
bool RealtimeAddProcessor (int group, unsigned chans, float rate)
 
size_t RealtimeProcess (int group, unsigned chans, float **inbuf, float **outbuf, size_t numSamples)
 
bool IsRealtimeActive ()
 
virtual bool IsHidden ()
 
int MessageBox (const wxString &message, long style=DefaultMessageBoxStyle, const wxString &titleStr=wxString{})
 
- Public Member Functions inherited from EffectClientInterface
virtual ~EffectClientInterface ()
 
- Public Member Functions inherited from EffectDefinitionInterface
virtual ~EffectDefinitionInterface ()
 
- Public Member Functions inherited from IdentInterface
virtual ~IdentInterface ()
 
const wxString & GetTranslatedName ()
 
- Public Member Functions inherited from ParamsInterface
virtual ~ParamsInterface ()
 
virtual bool DefineParams (ShuttleParams &WXUNUSED(S))
 
- Public Member Functions inherited from EffectUIClientInterface
virtual ~EffectUIClientInterface ()
 
- Public Member Functions inherited from EffectHostInterface
virtual ~EffectHostInterface ()
 
- Public Member Functions inherited from ConfigClientInterface
virtual ~ConfigClientInterface ()
 

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

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
 
NumericFormatId mFormat
 

Additional Inherited Members

- Public Types inherited from Effect
enum  : long { DefaultMessageBoxStyle = wxOK | wxCENTRE }
 
- Protected Member Functions inherited from Effect
virtual bool PromptUser (wxWindow *parent)
 
virtual bool ProcessPass ()
 
virtual bool InitPass1 ()
 
virtual bool InitPass2 ()
 
virtual int GetPass ()
 
virtual void End ()
 
virtual void Preview (bool dryOnly)
 
virtual bool EnableApply (bool enable=true)
 
virtual bool EnablePreview (bool enable=true)
 
virtual void EnableDebug (bool enable=true)
 
bool TotalProgress (double frac)
 
bool TrackProgress (int whichTrack, double frac, const wxString &=wxEmptyString)
 
bool TrackGroupProgress (int whichGroup, double frac, const wxString &=wxEmptyString)
 
int GetNumWaveTracks ()
 
int GetNumWaveGroups ()
 
void GetSamples (const WaveTrack *track, sampleCount *start, sampleCount *len)
 
void SetLinearEffectFlag (bool linearEffectFlag)
 
void SetPreviewFullSelectionFlag (bool previewDurationFlag)
 
bool IsPreviewing ()
 
void IncludeNotSelectedPreviewTracks (bool includeNotSelected)
 
void CopyInputTracks ()
 
void CopyInputTracks (int trackType)
 
std::shared_ptr
< AddedAnalysisTrack
AddAnalysisTrack (const wxString &name=wxString())
 
ModifiedAnalysisTrack ModifyAnalysisTrack (const LabelTrack *pOrigTrack, const wxString &name=wxString())
 
void ReplaceProcessedTracks (const bool bGoodResult)
 
TrackAddToOutputTracks (std::unique_ptr< Track > &&t)
 
TrackListinputTracks () const
 
- Protected Attributes inherited from Effect
ProgressDialogmProgress
 
double mProjectRate
 
double mSampleRate
 
SelectedRegionmpSelectedRegion {}
 
TrackFactorymFactory
 
std::shared_ptr< TrackListmOutputTracks
 
double mT0
 
double mT1
 
double mF0
 
double mF1
 
wxArrayString mPresetNames
 
wxArrayString mPresetValues
 
int mPass
 
wxDialog * mUIDialog
 
wxWindow * mUIParent
 
int mUIResultID
 
sampleCount mSampleCnt
 
int mOutputTracksType
 

Detailed Description

An Effect that affects both pitch & speed.

Definition at line 30 of file ChangeSpeed.h.

Constructor & Destructor Documentation

EffectChangeSpeed::EffectChangeSpeed ( )

Definition at line 87 of file ChangeSpeed.cpp.

References NumericConverter::DefaultSelectionFormat(), and kVinyl_33AndAThird.

88 {
89  // effect parameters
90  m_PercentChange = DEF_Percentage;
91 
94  mFromLength = 0.0;
95  mToLength = 0.0;
97  mbLoopDetect = false;
98 
99  SetLinearEffectFlag(true);
100 }
void SetLinearEffectFlag(bool linearEffectFlag)
Definition: Effect.cpp:1961
double m_PercentChange
Definition: ChangeSpeed.h:94
NumericFormatId mFormat
Definition: ChangeSpeed.h:118
static NumericFormatId DefaultSelectionFormat()
EffectChangeSpeed::~EffectChangeSpeed ( )
virtual

Definition at line 102 of file ChangeSpeed.cpp.

103 {
104 }

Member Function Documentation

double EffectChangeSpeed::CalcPreviewInputLength ( double  previewLength)
overridevirtual

Reimplemented from Effect.

Definition at line 168 of file ChangeSpeed.cpp.

References m_PercentChange.

169 {
170  return previewLength * (100.0 + m_PercentChange) / 100.0;
171 }
double m_PercentChange
Definition: ChangeSpeed.h:94
bool EffectChangeSpeed::CheckWhetherSkipEffect ( )
overridevirtual

Reimplemented from Effect.

Definition at line 163 of file ChangeSpeed.cpp.

References m_PercentChange.

164 {
165  return (m_PercentChange == 0.0);
166 }
double m_PercentChange
Definition: ChangeSpeed.h:94
bool EffectChangeSpeed::DefineParams ( ShuttleParams S)
override

Definition at line 132 of file ChangeSpeed.cpp.

References m_PercentChange.

132  {
133  S.SHUTTLE_PARAM( m_PercentChange, Percentage );
134  return true;
135 }
double m_PercentChange
Definition: ChangeSpeed.h:94
bool EffectChangeSpeed::GetAutomationParameters ( CommandParameters parms)
overridevirtual

Implements EffectClientInterface.

Definition at line 137 of file ChangeSpeed.cpp.

References m_PercentChange.

138 {
139  parms.Write(KEY_Percentage, m_PercentChange);
140 
141  return true;
142 }
double m_PercentChange
Definition: ChangeSpeed.h:94
wxString EffectChangeSpeed::GetDescription ( )
overridevirtual

Implements IdentInterface.

Definition at line 113 of file ChangeSpeed.cpp.

References _().

114 {
115  return _("Changes the speed of a track, also changing its pitch");
116 }
_("Move Track &Down")+wxT("\t")+(GetActiveProject() -> GetCommandManager() ->GetKeyFromName(wxT("TrackMoveDown")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveTopID, _("Move Track to &Top")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveTop")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveBottomID, _("Move Track to &Bottom")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveBottom")).Raw()), OnMoveTrack)#define SET_TRACK_NAME_PLUGIN_SYMBOLclass SetTrackNameCommand:public AudacityCommand
IdentInterfaceSymbol EffectChangeSpeed::GetSymbol ( )
overridevirtual

Implements IdentInterface.

Definition at line 108 of file ChangeSpeed.cpp.

References CHANGESPEED_PLUGIN_SYMBOL.

109 {
111 }
#define CHANGESPEED_PLUGIN_SYMBOL
Definition: ChangeSpeed.h:28
EffectType EffectChangeSpeed::GetType ( )
overridevirtual

Implements EffectDefinitionInterface.

Definition at line 126 of file ChangeSpeed.cpp.

References EffectTypeProcess.

127 {
128  return EffectTypeProcess;
129 }
bool EffectChangeSpeed::Init ( )
overridevirtual

Reimplemented from Effect.

Definition at line 214 of file ChangeSpeed.cpp.

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

215 {
216  // The selection might have changed since the last time EffectChangeSpeed
217  // was invoked, so recalculate the Length parameters.
218  mFromLength = mT1 - mT0;
219  return true;
220 }
double mT1
Definition: Effect.h:461
double mT0
Definition: Effect.h:460
bool EffectChangeSpeed::LoadFactoryDefaults ( )
overridevirtual
wxString EffectChangeSpeed::ManualPage ( )
overridevirtual

Reimplemented from Effect.

Definition at line 118 of file ChangeSpeed.cpp.

119 {
120  return wxT("Change_Speed");
121 }
void EffectChangeSpeed::OnChoice_Vinyl ( wxCommandEvent &  evt)
private

Definition at line 621 of file ChangeSpeed.cpp.

References Effect::GetCurrentSettingsGroup(), kVinyl_33AndAThird, kVinyl_45, kVinyl_78, kVinyl_NA, m_PercentChange, mbLoopDetect, mFromVinyl, mpChoice_FromVinyl, mpChoice_ToVinyl, mToVinyl, Effect::SetPrivateConfig(), Update_Slider_PercentChange(), Update_Text_Multiplier(), Update_Text_PercentChange(), Update_TimeCtrl_ToLength(), and UpdateUI().

622 {
623  // Treat mpChoice_FromVinyl and mpChoice_ToVinyl as one control since we need
624  // both to calculate Percent Change.
625  mFromVinyl = mpChoice_FromVinyl->GetSelection();
626  mToVinyl = mpChoice_ToVinyl->GetSelection();
627  // Use this as the 'preferred' choice.
628  if (mFromVinyl != kVinyl_NA) {
629  SetPrivateConfig(GetCurrentSettingsGroup(), wxT("VinylChoice"), mFromVinyl);
630  }
631 
632  // If mFromVinyl & mToVinyl are set, then there's a NEW percent change.
633  if ((mFromVinyl != kVinyl_NA) && (mToVinyl != kVinyl_NA))
634  {
635  double fromRPM;
636  double toRPM;
637  switch (mFromVinyl) {
638  default:
639  case kVinyl_33AndAThird: fromRPM = 33.0 + (1.0 / 3.0); break;
640  case kVinyl_45: fromRPM = 45.0; break;
641  case kVinyl_78: fromRPM = 78; break;
642  }
643  switch (mToVinyl) {
644  default:
645  case kVinyl_33AndAThird: toRPM = 33.0 + (1.0 / 3.0); break;
646  case kVinyl_45: toRPM = 45.0; break;
647  case kVinyl_78: toRPM = 78; break;
648  }
649  m_PercentChange = ((toRPM * 100.0) / fromRPM) - 100.0;
650  UpdateUI();
651 
652  mbLoopDetect = true;
657  }
658  mbLoopDetect = false;
659 }
void Update_Slider_PercentChange()
wxString GetCurrentSettingsGroup() override
Definition: Effect.cpp:801
void Update_TimeCtrl_ToLength()
double m_PercentChange
Definition: ChangeSpeed.h:94
wxChoice * mpChoice_FromVinyl
Definition: ChangeSpeed.h:109
bool SetPrivateConfig(const wxString &group, const wxString &key, const wxString &value) override
Definition: Effect.cpp:922
void Update_Text_PercentChange()
wxChoice * mpChoice_ToVinyl
Definition: ChangeSpeed.h:110
void Update_Text_Multiplier()
void EffectChangeSpeed::OnSlider_PercentChange ( wxCommandEvent &  evt)
private

Definition at line 602 of file ChangeSpeed.cpp.

References m_PercentChange, mbLoopDetect, mpSlider_PercentChange, Update_Text_Multiplier(), Update_Text_PercentChange(), Update_TimeCtrl_ToLength(), Update_Vinyl(), and UpdateUI().

603 {
604  if (mbLoopDetect)
605  return;
606 
607  m_PercentChange = (double)(mpSlider_PercentChange->GetValue());
608  // Warp positive values to actually go up faster & further than negatives.
609  if (m_PercentChange > 0.0)
611  UpdateUI();
612 
613  mbLoopDetect = true;
616  Update_Vinyl();
618  mbLoopDetect = false;
619 }
wxSlider * mpSlider_PercentChange
Definition: ChangeSpeed.h:108
void Update_TimeCtrl_ToLength()
double m_PercentChange
Definition: ChangeSpeed.h:94
void Update_Text_PercentChange()
static const double kSliderWarp
Definition: ChangeSpeed.cpp:71
void Update_Text_Multiplier()
void EffectChangeSpeed::OnText_Multiplier ( wxCommandEvent &  evt)
private

Definition at line 585 of file ChangeSpeed.cpp.

References m_PercentChange, mbLoopDetect, mMultiplier, mpTextCtrl_Multiplier, Update_Slider_PercentChange(), Update_Text_PercentChange(), Update_TimeCtrl_ToLength(), Update_Vinyl(), and UpdateUI().

586 {
587  if (mbLoopDetect)
588  return;
589 
590  mpTextCtrl_Multiplier->GetValidator()->TransferFromWindow();
591  m_PercentChange = 100 * (mMultiplier - 1);
592  UpdateUI();
593 
594  mbLoopDetect = true;
597  Update_Vinyl();
599  mbLoopDetect = false;
600 }
void Update_Slider_PercentChange()
wxTextCtrl * mpTextCtrl_Multiplier
Definition: ChangeSpeed.h:107
void Update_TimeCtrl_ToLength()
double m_PercentChange
Definition: ChangeSpeed.h:94
void Update_Text_PercentChange()
void EffectChangeSpeed::OnText_PercentChange ( wxCommandEvent &  evt)
private

Definition at line 569 of file ChangeSpeed.cpp.

References mbLoopDetect, mpTextCtrl_PercentChange, Update_Slider_PercentChange(), Update_Text_Multiplier(), Update_TimeCtrl_ToLength(), Update_Vinyl(), and UpdateUI().

570 {
571  if (mbLoopDetect)
572  return;
573 
574  mpTextCtrl_PercentChange->GetValidator()->TransferFromWindow();
575  UpdateUI();
576 
577  mbLoopDetect = true;
580  Update_Vinyl();
582  mbLoopDetect = false;
583 }
void Update_Slider_PercentChange()
void Update_TimeCtrl_ToLength()
wxTextCtrl * mpTextCtrl_PercentChange
Definition: ChangeSpeed.h:106
void Update_Text_Multiplier()
void EffectChangeSpeed::OnTimeCtrl_ToLength ( wxCommandEvent &  evt)
private

Definition at line 661 of file ChangeSpeed.cpp.

References NumericConverter::GetValue(), m_PercentChange, mbLoopDetect, mFromLength, mpToLengthCtrl, mToLength, Update_Slider_PercentChange(), Update_Text_Multiplier(), Update_Text_PercentChange(), Update_Vinyl(), and UpdateUI().

662 {
663  if (mbLoopDetect)
664  return;
665 
667  // Division by (double) 0.0 is not an error and we want to show "infinite" in
668  // text controls, so take care that we handle infinite values when they occur.
669  m_PercentChange = ((mFromLength * 100.0) / mToLength) - 100.0;
670  UpdateUI();
671 
672  mbLoopDetect = true;
673 
677  Update_Vinyl();
678 
679  mbLoopDetect = false;
680 }
void Update_Slider_PercentChange()
double m_PercentChange
Definition: ChangeSpeed.h:94
void Update_Text_PercentChange()
void Update_Text_Multiplier()
NumericTextCtrl * mpToLengthCtrl
Definition: ChangeSpeed.h:112
void EffectChangeSpeed::OnTimeCtrlUpdate ( wxCommandEvent &  evt)
private

Definition at line 682 of file ChangeSpeed.cpp.

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

683 {
685  NumericConverter::TIME, evt.GetString() );
686 
688  // Update From/To Length controls (precision has changed).
691 }
NumericTextCtrl * mpFromLengthCtrl
Definition: ChangeSpeed.h:111
static NumericFormatId LookupFormat(Type type, const wxString &id)
NumericFormatId mFormat
Definition: ChangeSpeed.h:118
void SetValue(double newValue)
void SetFormatName(const NumericFormatId &formatName)
NumericTextCtrl * mpToLengthCtrl
Definition: ChangeSpeed.h:112
void EffectChangeSpeed::PopulateOrExchange ( ShuttleGui S)
overridevirtual

Reimplemented from Effect.

Definition at line 296 of file ChangeSpeed.cpp.

References _(), ShuttleGuiBase::AddChoice(), ShuttleGuiBase::AddPrompt(), ShuttleGuiBase::AddSlider(), ShuttleGui::AddSpace(), ShuttleGuiBase::AddTextBox(), ShuttleGuiBase::AddTitle(), ShuttleGuiBase::AddUnits(), ShuttleGuiBase::AddWindow(), ShuttleGuiBase::EndHorizontalLay(), ShuttleGuiBase::EndMultiColumn(), ShuttleGuiBase::EndStatic(), ShuttleGuiBase::EndVerticalLay(), Effect::GetCurrentSettingsGroup(), ShuttleGuiBase::GetParent(), Effect::GetPrivateConfig(), ShuttleGui::Id(), ID_FromVinyl, ID_Multiplier, ID_PercentChange, ID_ToLength, ID_ToVinyl, IdentInterfaceSymbol::Internal(), kVinyl_NA, kVinylStrings, NumericConverter::LookupFormat(), m_PercentChange, NumericTextCtrl::Options::MenuEnabled(), mFormat, mFromLength, mFromVinyl, mMultiplier, mpChoice_FromVinyl, mpChoice_ToVinyl, mpFromLengthCtrl, Effect::mProjectRate, mpSlider_PercentChange, mpTextCtrl_Multiplier, mpTextCtrl_PercentChange, mpToLengthCtrl, mToLength, nVinyl, NumericTextCtrl::Options::ReadOnly(), safenew, ShuttleGuiBase::SetBorder(), ShuttleGuiBase::SetStyle(), ShuttleGuiBase::StartHorizontalLay(), ShuttleGuiBase::StartMultiColumn(), ShuttleGuiBase::StartStatic(), ShuttleGuiBase::StartVerticalLay(), and NumericConverter::TIME.

297 {
298  {
299  wxString formatId;
300  GetPrivateConfig(GetCurrentSettingsGroup(), wxT("TimeFormat"),
301  formatId, mFormat.Internal());
303  NumericConverter::TIME, formatId );
304  }
306 
307  S.SetBorder(5);
308 
309  S.StartVerticalLay(0);
310  {
311  S.AddSpace(0, 5);
312  S.AddTitle(_("Change Speed, affecting both Tempo and Pitch"));
313  S.AddSpace(0, 10);
314 
315  // Speed multiplier and percent change controls.
316  S.StartMultiColumn(4, wxCENTER);
317  {
318  FloatingPointValidator<double> vldMultiplier(3, &mMultiplier, NumValidatorStyle::THREE_TRAILING_ZEROES);
319  vldMultiplier.SetRange(MIN_Percentage / 100.0, ((MAX_Percentage / 100.0) + 1));
321  S.Id(ID_Multiplier).AddTextBox(_("Speed Multiplier:"), wxT(""), 12);
322  mpTextCtrl_Multiplier->SetValidator(vldMultiplier);
323 
324  FloatingPointValidator<double> vldPercentage(3, &m_PercentChange, NumValidatorStyle::THREE_TRAILING_ZEROES);
325  vldPercentage.SetRange(MIN_Percentage, MAX_Percentage);
327  S.Id(ID_PercentChange).AddTextBox(_("Percent Change:"), wxT(""), 12);
328  mpTextCtrl_PercentChange->SetValidator(vldPercentage);
329  }
330  S.EndMultiColumn();
331 
332  // Percent change slider.
333  S.StartHorizontalLay(wxEXPAND);
334  {
335  S.SetStyle(wxSL_HORIZONTAL);
337  S.Id(ID_PercentChange).AddSlider( {}, 0, (int)kSliderMax, (int)MIN_Percentage);
338  mpSlider_PercentChange->SetName(_("Percent Change"));
339  }
340  S.EndHorizontalLay();
341 
342  // Vinyl rpm controls.
343  S.StartMultiColumn(5, wxCENTER);
344  {
345  /* i18n-hint: "rpm" is an English abbreviation meaning "revolutions per minute". */
346  S.AddUnits(_("Standard Vinyl rpm:"));
347 
348  wxASSERT(nVinyl == WXSIZEOF(kVinylStrings));
349 
350  wxArrayString vinylChoices;
351  for (int i = 0; i < nVinyl; i++)
352  {
353  if (i == kVinyl_NA)
354  {
355  vinylChoices.Add(wxGetTranslation(kVinylStrings[i]));
356  }
357  else
358  {
359  vinylChoices.Add(kVinylStrings[i]);
360  }
361  }
362 
364  S.Id(ID_FromVinyl).AddChoice(_("from"), wxT(""), &vinylChoices);
365  mpChoice_FromVinyl->SetName(_("From rpm"));
366  mpChoice_FromVinyl->SetSizeHints(100, -1);
367 
369  S.Id(ID_ToVinyl).AddChoice(_("to"), wxT(""), &vinylChoices);
370  mpChoice_ToVinyl->SetName(_("To rpm"));
371  mpChoice_ToVinyl->SetSizeHints(100, -1);
372  }
373  S.EndMultiColumn();
374 
375  // From/To time controls.
376  S.StartStatic(_("Selection Length"), 0);
377  {
378  S.StartMultiColumn(2, wxALIGN_LEFT);
379  {
380  S.AddPrompt(_("Current Length:"));
381 
383  NumericTextCtrl(S.GetParent(), wxID_ANY,
385  mFormat,
386  mFromLength,
387  mProjectRate,
389  .ReadOnly(true)
390  .MenuEnabled(false));
391 
392  mpFromLengthCtrl->SetName(_("from"));
393  mpFromLengthCtrl->SetToolTip(_("Current length of selection."));
394  S.AddWindow(mpFromLengthCtrl, wxALIGN_LEFT);
395 
396  S.AddPrompt(_("New Length:"));
397 
401  mFormat,
402  mToLength,
403  mProjectRate);
404 
405  mpToLengthCtrl->SetName(_("to"));
406  S.AddWindow(mpToLengthCtrl, wxALIGN_LEFT);
407  }
408  S.EndMultiColumn();
409  }
410  S.EndStatic();
411  }
412  S.EndVerticalLay();
413 }
static const wxChar * kVinylStrings[nVinyl]
Definition: ChangeSpeed.cpp:53
static const double kSliderMax
Definition: ChangeSpeed.cpp:70
bool GetPrivateConfig(const wxString &group, const wxString &key, wxString &value, const wxString &defval=wxEmptyString) override
Definition: Effect.cpp:897
wxString GetCurrentSettingsGroup() override
Definition: Effect.cpp:801
wxWindow * AddWindow(wxWindow *pWindow, int Flags=wxALIGN_CENTRE|wxALL)
Definition: ShuttleGui.cpp:288
void EndMultiColumn()
wxTextCtrl * mpTextCtrl_Multiplier
Definition: ChangeSpeed.h:107
wxSlider * mpSlider_PercentChange
Definition: ChangeSpeed.h:108
double m_PercentChange
Definition: ChangeSpeed.h:94
wxChoice * mpChoice_FromVinyl
Definition: ChangeSpeed.h:109
#define safenew
Definition: Audacity.h:230
wxTextCtrl * mpTextCtrl_PercentChange
Definition: ChangeSpeed.h:106
void EndHorizontalLay()
void AddUnits(const wxString &Prompt)
Left aligned text string.
Definition: ShuttleGui.cpp:260
void AddPrompt(const wxString &Prompt)
Right aligned text string.
Definition: ShuttleGui.cpp:239
NumericTextCtrl * mpFromLengthCtrl
Definition: ChangeSpeed.h:111
void EndVerticalLay()
wxTextCtrl * AddTextBox(const wxString &Caption, const wxString &Value, const int nChars)
Definition: ShuttleGui.cpp:540
static NumericFormatId LookupFormat(Type type, const wxString &id)
wxWindow * GetParent()
Definition: ShuttleGui.h:294
void StartHorizontalLay(int PositionFlags=wxALIGN_CENTRE, int iProp=1)
void StartMultiColumn(int nCols, int PositionFlags=wxALIGN_LEFT)
Options & MenuEnabled(bool value)
wxChoice * AddChoice(const wxString &Prompt, const wxString &Selected, const wxArrayString *pChoices)
Definition: ShuttleGui.cpp:371
ShuttleGui & Id(int id)
void SetStyle(int Style)
Definition: ShuttleGui.h:287
void AddTitle(const wxString &Prompt)
Centred text string.
Definition: ShuttleGui.cpp:274
NumericFormatId mFormat
Definition: ChangeSpeed.h:118
wxChoice * mpChoice_ToVinyl
Definition: ChangeSpeed.h:110
double mProjectRate
Definition: Effect.h:453
_("Move Track &Down")+wxT("\t")+(GetActiveProject() -> GetCommandManager() ->GetKeyFromName(wxT("TrackMoveDown")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveTopID, _("Move Track to &Top")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveTop")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveBottomID, _("Move Track to &Bottom")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveBottom")).Raw()), OnMoveTrack)#define SET_TRACK_NAME_PLUGIN_SYMBOLclass SetTrackNameCommand:public AudacityCommand
Options & ReadOnly(bool value)
const wxString & Internal() const
wxStaticBox * StartStatic(const wxString &Str, int iProp=0)
Definition: ShuttleGui.cpp:763
wxSizerItem * AddSpace(int width, int height)
void SetBorder(int Border)
Definition: ShuttleGui.h:286
NumericTextCtrl * mpToLengthCtrl
Definition: ChangeSpeed.h:112
wxSlider * AddSlider(const wxString &Prompt, int pos, int Max, int Min=0)
Definition: ShuttleGui.cpp:497
void StartVerticalLay(int iProp=1)
bool EffectChangeSpeed::Process ( )
overridevirtual

Reimplemented from Effect.

Definition at line 222 of file ChangeSpeed.cpp.

References Track::All, Effect::CopyInputTracks(), WaveTrack::GetEndTime(), WaveTrack::GetStartTime(), Track::Label, m_PercentChange, mCurT0, mCurT1, mCurTrackNum, mFactor, mMaxNewLength, Effect::mOutputTracks, Effect::mT0, Effect::mT1, ProcessLabelTrack(), ProcessOne(), Effect::ReplaceProcessedTracks(), WaveTrack::TimeToLongSamples(), and Track::Wave.

223 {
224  // Similar to EffectSoundTouch::Process()
225 
226  // Iterate over each track.
227  // Track::All is needed because this effect needs to introduce
228  // silence in the sync-lock group tracks to keep sync
229  CopyInputTracks(Track::All); // Set up mOutputTracks.
230  bool bGoodResult = true;
231 
232  TrackListIterator iter(mOutputTracks.get());
233  Track* t;
234  mCurTrackNum = 0;
235  mMaxNewLength = 0.0;
236 
237  mFactor = 100.0 / (100.0 + m_PercentChange);
238 
239  t = iter.First();
240  while (t != NULL)
241  {
242  if (t->GetKind() == Track::Label) {
243  if (t->GetSelected() || t->IsSyncLockSelected())
244  {
245  if (!ProcessLabelTrack(static_cast<LabelTrack*>(t))) {
246  bGoodResult = false;
247  break;
248  }
249  }
250  }
251  else if (t->GetKind() == Track::Wave && t->GetSelected())
252  {
253  WaveTrack *pOutWaveTrack = (WaveTrack*)t;
254  //Get start and end times from track
255  mCurT0 = pOutWaveTrack->GetStartTime();
256  mCurT1 = pOutWaveTrack->GetEndTime();
257 
258  //Set the current bounds to whichever left marker is
259  //greater and whichever right marker is less:
260  mCurT0 = wxMax(mT0, mCurT0);
261  mCurT1 = wxMin(mT1, mCurT1);
262 
263  // Process only if the right marker is to the right of the left marker
264  if (mCurT1 > mCurT0) {
265  //Transform the marker timepoints to samples
266  auto start = pOutWaveTrack->TimeToLongSamples(mCurT0);
267  auto end = pOutWaveTrack->TimeToLongSamples(mCurT1);
268 
269  //ProcessOne() (implemented below) processes a single track
270  if (!ProcessOne(pOutWaveTrack, start, end))
271  {
272  bGoodResult = false;
273  break;
274  }
275  }
276  mCurTrackNum++;
277  }
278  else if (t->IsSyncLockSelected())
279  {
280  t->SyncLockAdjust(mT1, mT0 + (mT1 - mT0) * mFactor);
281  }
282 
283  //Iterate to the next track
284  t=iter.Next();
285  }
286 
287  if (bGoodResult)
288  ReplaceProcessedTracks(bGoodResult);
289 
290  // Update selection.
291  mT1 = mT0 + (((mT1 - mT0) * 100.0) / (100.0 + m_PercentChange));
292 
293  return bGoodResult;
294 }
double mT1
Definition: Effect.h:461
void CopyInputTracks()
Definition: Effect.cpp:2036
void ReplaceProcessedTracks(const bool bGoodResult)
Definition: Effect.cpp:2162
double m_PercentChange
Definition: ChangeSpeed.h:94
bool ProcessOne(WaveTrack *t, sampleCount start, sampleCount end)
double GetEndTime() const override
Get the time at which the last clip in the track ends, plus recorded stuff.
Definition: WaveTrack.cpp:1873
double GetStartTime() const override
Get the time at which the first clip in the track starts.
Definition: WaveTrack.cpp:1853
A Track that contains audio waveform data.
Definition: WaveTrack.h:60
Fundamental data object of Audacity, placed in the TrackPanel. Classes derived form it include the Wa...
Definition: Track.h:102
An iterator for a TrackList.
Definition: Track.h:402
double mMaxNewLength
Definition: ChangeSpeed.h:89
sampleCount TimeToLongSamples(double t0) const
Convert correctly between an (absolute) time in seconds and a number of samples.
Definition: WaveTrack.cpp:1843
bool ProcessLabelTrack(LabelTrack *t)
std::shared_ptr< TrackList > mOutputTracks
Definition: Effect.h:459
double mT0
Definition: Effect.h:460
bool EffectChangeSpeed::ProcessLabelTrack ( LabelTrack t)
private

Definition at line 471 of file ChangeSpeed.cpp.

References mFactor, Effect::mT0, Effect::mT1, and LabelTrack::WarpLabels().

Referenced by Process().

472 {
473  RegionTimeWarper warper { mT0, mT1,
474  std::make_unique<LinearTimeWarper>(mT0, mT0,
475  mT1, mT0 + (mT1-mT0)*mFactor) };
476  lt->WarpLabels(warper);
477  return true;
478 }
double mT1
Definition: Effect.h:461
No change before the specified region; during the region, warp according to the given warper; after t...
Definition: TimeWarper.h:192
double mT0
Definition: Effect.h:460
bool EffectChangeSpeed::ProcessOne ( WaveTrack t,
sampleCount  start,
sampleCount  end 
)
private

Definition at line 482 of file ChangeSpeed.cpp.

References WaveTrack::ClearAndPaste(), floatSample, WaveTrack::Get(), WaveTrack::GetBestBlockSize(), WaveTrack::GetMaxBlockSize(), WaveTrack::GetRate(), WaveTrack::GetSampleFormat(), limitSampleBufferSize(), mCurT0, mCurT1, mCurTrackNum, mFactor, Effect::mFactory, mMaxNewLength, TrackFactory::NewWaveTrack(), Resample::Process(), and Effect::TrackProgress().

Referenced by Process().

484 {
485  if (track == NULL)
486  return false;
487 
488  // initialization, per examples of Mixer::Mixer and
489  // EffectSoundTouch::ProcessOne
490 
491  auto outputTrack = mFactory->NewWaveTrack(track->GetSampleFormat(),
492  track->GetRate());
493 
494  //Get the length of the selection (as double). len is
495  //used simple to calculate a progress meter, so it is easier
496  //to make it a double now than it is to do it later
497  auto len = (end - start).as_double();
498 
499  // Initiate processing buffers, most likely shorter than
500  // the length of the selection being processed.
501  auto inBufferSize = track->GetMaxBlockSize();
502 
503  Floats inBuffer{ inBufferSize };
504 
505  // mFactor is at most 100-fold so this shouldn't overflow size_t
506  auto outBufferSize = size_t( mFactor * inBufferSize + 10 );
507  Floats outBuffer{ outBufferSize };
508 
509  // Set up the resampling stuff for this track.
510  Resample resample(true, mFactor, mFactor); // constant rate resampling
511 
512  //Go through the track one buffer at a time. samplePos counts which
513  //sample the current buffer starts at.
514  bool bResult = true;
515  auto samplePos = start;
516  while (samplePos < end) {
517  //Get a blockSize of samples (smaller than the size of the buffer)
518  auto blockSize = limitSampleBufferSize(
519  track->GetBestBlockSize(samplePos),
520  end - samplePos
521  );
522 
523  //Get the samples from the track and put them in the buffer
524  track->Get((samplePtr) inBuffer.get(), floatSample, samplePos, blockSize);
525 
526  const auto results = resample.Process(mFactor,
527  inBuffer.get(),
528  blockSize,
529  ((samplePos + blockSize) >= end),
530  outBuffer.get(),
531  outBufferSize);
532  const auto outgen = results.second;
533 
534  if (outgen > 0)
535  outputTrack->Append((samplePtr)outBuffer.get(), floatSample,
536  outgen);
537 
538  // Increment samplePos
539  samplePos += results.first;
540 
541  // Update the Progress meter
542  if (TrackProgress(mCurTrackNum, (samplePos - start).as_double() / len)) {
543  bResult = false;
544  break;
545  }
546  }
547 
548  // Flush the output WaveTrack (since it's buffered, too)
549  outputTrack->Flush();
550 
551  // Take the output track and insert it in place of the original
552  // sample data
553  double newLength = outputTrack->GetEndTime();
554  if (bResult)
555  {
556  LinearTimeWarper warper { mCurT0, mCurT0, mCurT1, mCurT0 + newLength };
557  track->ClearAndPaste(
558  mCurT0, mCurT1, outputTrack.get(), true, false, &warper);
559  }
560 
561  if (newLength > mMaxNewLength)
562  mMaxNewLength = newLength;
563 
564  return bResult;
565 }
bool TrackProgress(int whichTrack, double frac, const wxString &=wxEmptyString)
Definition: Effect.cpp:1985
size_t limitSampleBufferSize(size_t bufferSize, sampleCount limit)
Definition: Types.h:178
Linear scaling, initialised by giving two points on the line.
Definition: TimeWarper.h:86
char * samplePtr
Definition: Types.h:203
std::unique_ptr< WaveTrack > NewWaveTrack(sampleFormat format=(sampleFormat) 0, double rate=0)
Definition: WaveTrack.cpp:78
TrackFactory * mFactory
Definition: Effect.h:457
Interface to libsoxr.
Definition: Resample.h:32
double mMaxNewLength
Definition: ChangeSpeed.h:89
bool EffectChangeSpeed::SetAutomationParameters ( CommandParameters parms)
overridevirtual

Implements EffectClientInterface.

Definition at line 144 of file ChangeSpeed.cpp.

References m_PercentChange, and ReadAndVerifyDouble.

145 {
146  ReadAndVerifyDouble(Percentage);
147 
148  m_PercentChange = Percentage;
149 
150  return true;
151 }
double m_PercentChange
Definition: ChangeSpeed.h:94
#define ReadAndVerifyDouble(name)
Definition: Effect.h:798
bool EffectChangeSpeed::Startup ( )
overridevirtual

Reimplemented from Effect.

Definition at line 173 of file ChangeSpeed.cpp.

References format, Effect::GetCurrentSettingsGroup(), gPrefs, IdentInterfaceSymbol::Internal(), kVinyl_33AndAThird, kVinyl_NA, NumericConverter::LookupFormat(), m_PercentChange, mFormat, mFromVinyl, Effect::SaveUserPreset(), Effect::SetPrivateConfig(), and NumericConverter::TIME.

174 {
175  wxString base = wxT("/Effects/ChangeSpeed/");
176 
177  // Migrate settings from 2.1.0 or before
178 
179  // Already migrated, so bail
180  if (gPrefs->Exists(base + wxT("Migrated")))
181  {
182  return true;
183  }
184 
185  // Load the old "current" settings
186  if (gPrefs->Exists(base))
187  {
188  // Retrieve last used control values
189  gPrefs->Read(base + wxT("PercentChange"), &m_PercentChange, 0);
190 
191  wxString format;
192  gPrefs->Read(base + wxT("TimeFormat"), &format, wxString{});
194 
195  gPrefs->Read(base + wxT("VinylChoice"), &mFromVinyl, 0);
196  if (mFromVinyl == kVinyl_NA)
197  {
199  }
200 
201  SetPrivateConfig(GetCurrentSettingsGroup(), wxT("TimeFormat"), mFormat.Internal());
202  SetPrivateConfig(GetCurrentSettingsGroup(), wxT("VinylChoice"), mFromVinyl);
203 
205 
206  // Do not migrate again
207  gPrefs->Write(base + wxT("Migrated"), true);
208  gPrefs->Flush();
209  }
210 
211  return true;
212 }
AudacityPrefs * gPrefs
Definition: Prefs.cpp:73
bool SaveUserPreset(const wxString &name) override
Definition: Effect.cpp:600
wxString GetCurrentSettingsGroup() override
Definition: Effect.cpp:801
double m_PercentChange
Definition: ChangeSpeed.h:94
bool SetPrivateConfig(const wxString &group, const wxString &key, const wxString &value) override
Definition: Effect.cpp:922
int format
Definition: ExportPCM.cpp:56
static NumericFormatId LookupFormat(Type type, const wxString &id)
NumericFormatId mFormat
Definition: ChangeSpeed.h:118
const wxString & Internal() const
bool EffectChangeSpeed::TransferDataFromWindow ( )
overridevirtual

Reimplemented from Effect.

Definition at line 451 of file ChangeSpeed.cpp.

References Effect::GetCurrentSettingsGroup(), IdentInterfaceSymbol::Internal(), m_PercentChange, mFormat, mFromVinyl, Effect::mUIParent, and Effect::SetPrivateConfig().

452 {
453  // mUIParent->TransferDataFromWindow() loses some precision, so save and restore it.
454  double exactPercent = m_PercentChange;
455  if (!mUIParent->Validate() || !mUIParent->TransferDataFromWindow())
456  {
457  return false;
458  }
459  m_PercentChange = exactPercent;
460 
461  SetPrivateConfig(GetCurrentSettingsGroup(), wxT("TimeFormat"), mFormat.Internal());
462  SetPrivateConfig(GetCurrentSettingsGroup(), wxT("VinylChoice"), mFromVinyl);
463 
464  return true;
465 }
wxString GetCurrentSettingsGroup() override
Definition: Effect.cpp:801
double m_PercentChange
Definition: ChangeSpeed.h:94
bool SetPrivateConfig(const wxString &group, const wxString &key, const wxString &value) override
Definition: Effect.cpp:922
NumericFormatId mFormat
Definition: ChangeSpeed.h:118
wxWindow * mUIParent
Definition: Effect.h:472
const wxString & Internal() const
bool EffectChangeSpeed::TransferDataToWindow ( )
overridevirtual

Reimplemented from Effect.

Definition at line 415 of file ChangeSpeed.cpp.

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

416 {
417  mbLoopDetect = true;
418 
419  if (!mUIParent->TransferDataToWindow())
420  {
421  return false;
422  }
423 
424  if (mFromVinyl == kVinyl_NA)
425  {
427  }
428 
433 
434  // Set from/to Vinyl controls - mFromVinyl must be set first.
435  mpChoice_FromVinyl->SetSelection(mFromVinyl);
436  // Then update to get correct mToVinyl.
437  Update_Vinyl();
438  // Then update ToVinyl control.
439  mpChoice_ToVinyl->SetSelection(mToVinyl);
440 
441  // Set From Length control.
442  // Set the format first so we can get sample accuracy.
445 
446  mbLoopDetect = false;
447 
448  return true;
449 }
void Update_Slider_PercentChange()
void Update_TimeCtrl_ToLength()
wxChoice * mpChoice_FromVinyl
Definition: ChangeSpeed.h:109
void Update_Text_PercentChange()
NumericTextCtrl * mpFromLengthCtrl
Definition: ChangeSpeed.h:111
NumericFormatId mFormat
Definition: ChangeSpeed.h:118
void SetValue(double newValue)
wxChoice * mpChoice_ToVinyl
Definition: ChangeSpeed.h:110
wxWindow * mUIParent
Definition: Effect.h:472
void SetFormatName(const NumericFormatId &formatName)
void Update_Text_Multiplier()
void EffectChangeSpeed::Update_Slider_PercentChange ( )
private

Definition at line 708 of file ChangeSpeed.cpp.

References m_PercentChange, and mpSlider_PercentChange.

Referenced by OnChoice_Vinyl(), OnText_Multiplier(), OnText_PercentChange(), OnTimeCtrl_ToLength(), and TransferDataToWindow().

710 {
711  auto unwarped = std::min<double>(m_PercentChange, MAX_Percentage);
712  if (unwarped > 0.0)
713  // Un-warp values above zero to actually go up to kSliderMax.
714  unwarped = pow(m_PercentChange, (1.0 / kSliderWarp));
715 
716  // Caution: m_PercentChange could be infinite.
717  int unwarpedi = (int)(unwarped + 0.5);
718  unwarpedi = std::min<int>(unwarpedi, (int)kSliderMax);
719 
720  mpSlider_PercentChange->SetValue(unwarpedi);
721 }
static const double kSliderMax
Definition: ChangeSpeed.cpp:70
wxSlider * mpSlider_PercentChange
Definition: ChangeSpeed.h:108
double m_PercentChange
Definition: ChangeSpeed.h:94
static const double kSliderWarp
Definition: ChangeSpeed.cpp:71
void EffectChangeSpeed::Update_Text_Multiplier ( )
private

Definition at line 701 of file ChangeSpeed.cpp.

References m_PercentChange, mMultiplier, and mpTextCtrl_Multiplier.

Referenced by OnChoice_Vinyl(), OnSlider_PercentChange(), OnText_PercentChange(), OnTimeCtrl_ToLength(), and TransferDataToWindow().

703 {
704  mMultiplier = 1 + (m_PercentChange) / 100.0;
705  mpTextCtrl_Multiplier->GetValidator()->TransferToWindow();
706 }
wxTextCtrl * mpTextCtrl_Multiplier
Definition: ChangeSpeed.h:107
double m_PercentChange
Definition: ChangeSpeed.h:94
void EffectChangeSpeed::Update_Text_PercentChange ( )
private

Definition at line 695 of file ChangeSpeed.cpp.

References mpTextCtrl_PercentChange.

Referenced by OnChoice_Vinyl(), OnSlider_PercentChange(), OnText_Multiplier(), OnTimeCtrl_ToLength(), and TransferDataToWindow().

697 {
698  mpTextCtrl_PercentChange->GetValidator()->TransferToWindow();
699 }
wxTextCtrl * mpTextCtrl_PercentChange
Definition: ChangeSpeed.h:106
void EffectChangeSpeed::Update_TimeCtrl_ToLength ( )
private

Definition at line 776 of file ChangeSpeed.cpp.

References m_PercentChange, mFormat, mFromLength, mpToLengthCtrl, mToLength, NumericTextCtrl::SetFormatName(), NumericTextCtrl::SetValue(), and TrapDouble().

Referenced by OnChoice_Vinyl(), OnSlider_PercentChange(), OnText_Multiplier(), OnText_PercentChange(), and TransferDataToWindow().

778 {
779  mToLength = (mFromLength * 100.0) / (100.0 + m_PercentChange);
780 
781  // Set the format first so we can get sample accuracy.
783  // Negative times do not make sense.
784  // 359999 = 99h:59m:59s which is a little less disturbing than overflow characters
785  // though it may still look a bit strange with some formats.
786  mToLength = TrapDouble(mToLength, 0.0, 359999.0);
788 }
double m_PercentChange
Definition: ChangeSpeed.h:94
NumericFormatId mFormat
Definition: ChangeSpeed.h:118
void SetValue(double newValue)
double TrapDouble(double x, double min, double max)
Definition: Effect.h:729
void SetFormatName(const NumericFormatId &formatName)
NumericTextCtrl * mpToLengthCtrl
Definition: ChangeSpeed.h:112
void EffectChangeSpeed::Update_Vinyl ( )
private

Definition at line 723 of file ChangeSpeed.cpp.

References Effect::GetCurrentSettingsGroup(), Effect::GetPrivateConfig(), kVinyl_33AndAThird, kVinyl_45, kVinyl_78, kVinyl_NA, m_PercentChange, mFromVinyl, mpChoice_FromVinyl, mpChoice_ToVinyl, and mToVinyl.

Referenced by OnSlider_PercentChange(), OnText_Multiplier(), OnText_PercentChange(), OnTimeCtrl_ToLength(), and TransferDataToWindow().

725 {
726  // Match Vinyl rpm when within 0.01% of a standard ratio.
727  // Ratios calculated as: ((toRPM / fromRPM) - 1) * 100 * 100
728 
729  // Caution: m_PercentChange could be infinite
730  int ratio = (int)((m_PercentChange * 100) + 0.5);
731 
732  switch (ratio)
733  {
734  case 0: // toRPM is the same as fromRPM
735  if (mFromVinyl != kVinyl_NA) {
736  mpChoice_ToVinyl->SetSelection(mpChoice_FromVinyl->GetSelection());
737  } else {
738  // Use the last saved option.
739  GetPrivateConfig(GetCurrentSettingsGroup(), wxT("VinylChoice"), mFromVinyl, 0);
740  mpChoice_FromVinyl->SetSelection(mFromVinyl);
741  mpChoice_ToVinyl->SetSelection(mFromVinyl);
742  }
743  break;
744  case 3500:
745  mpChoice_FromVinyl->SetSelection(kVinyl_33AndAThird);
746  mpChoice_ToVinyl->SetSelection(kVinyl_45);
747  break;
748  case 13400:
749  mpChoice_FromVinyl->SetSelection(kVinyl_33AndAThird);
750  mpChoice_ToVinyl->SetSelection(kVinyl_78);
751  break;
752  case -2593:
753  mpChoice_FromVinyl->SetSelection(kVinyl_45);
754  mpChoice_ToVinyl->SetSelection(kVinyl_33AndAThird);
755  break;
756  case 7333:
757  mpChoice_FromVinyl->SetSelection(kVinyl_45);
758  mpChoice_ToVinyl->SetSelection(kVinyl_78);
759  break;
760  case -5727:
761  mpChoice_FromVinyl->SetSelection(kVinyl_78);
762  mpChoice_ToVinyl->SetSelection(kVinyl_33AndAThird);
763  break;
764  case -4231:
765  mpChoice_FromVinyl->SetSelection(kVinyl_78);
766  mpChoice_ToVinyl->SetSelection(kVinyl_45);
767  break;
768  default:
769  mpChoice_ToVinyl->SetSelection(kVinyl_NA);
770  }
771  // and update variables.
772  mFromVinyl = mpChoice_FromVinyl->GetSelection();
773  mToVinyl = mpChoice_ToVinyl->GetSelection();
774 }
bool GetPrivateConfig(const wxString &group, const wxString &key, wxString &value, const wxString &defval=wxEmptyString) override
Definition: Effect.cpp:897
wxString GetCurrentSettingsGroup() override
Definition: Effect.cpp:801
double m_PercentChange
Definition: ChangeSpeed.h:94
wxChoice * mpChoice_FromVinyl
Definition: ChangeSpeed.h:109
wxChoice * mpChoice_ToVinyl
Definition: ChangeSpeed.h:110
void EffectChangeSpeed::UpdateUI ( )
private

Definition at line 790 of file ChangeSpeed.cpp.

References Effect::EnableApply(), and m_PercentChange.

Referenced by OnChoice_Vinyl(), OnSlider_PercentChange(), OnText_Multiplier(), OnText_PercentChange(), and OnTimeCtrl_ToLength().

792 {
793  EnableApply(m_PercentChange >= MIN_Percentage && m_PercentChange <= MAX_Percentage);
794 }
double m_PercentChange
Definition: ChangeSpeed.h:94
virtual bool EnableApply(bool enable=true)
Definition: Effect.cpp:1886

Member Data Documentation

double EffectChangeSpeed::m_PercentChange
private
bool EffectChangeSpeed::mbLoopDetect
private
double EffectChangeSpeed::mCurT0
private

Definition at line 90 of file ChangeSpeed.h.

Referenced by Process(), and ProcessOne().

double EffectChangeSpeed::mCurT1
private

Definition at line 91 of file ChangeSpeed.h.

Referenced by Process(), and ProcessOne().

int EffectChangeSpeed::mCurTrackNum
private

Definition at line 88 of file ChangeSpeed.h.

Referenced by Process(), and ProcessOne().

double EffectChangeSpeed::mFactor
private

Definition at line 98 of file ChangeSpeed.h.

Referenced by Process(), ProcessLabelTrack(), and ProcessOne().

NumericFormatId EffectChangeSpeed::mFormat
private
double EffectChangeSpeed::mFromLength
private
int EffectChangeSpeed::mFromVinyl
private
double EffectChangeSpeed::mMaxNewLength
private

Definition at line 89 of file ChangeSpeed.h.

Referenced by Process(), and ProcessOne().

double EffectChangeSpeed::mMultiplier
private

Definition at line 101 of file ChangeSpeed.h.

Referenced by OnText_Multiplier(), PopulateOrExchange(), and Update_Text_Multiplier().

wxChoice* EffectChangeSpeed::mpChoice_FromVinyl
private
wxChoice* EffectChangeSpeed::mpChoice_ToVinyl
private
NumericTextCtrl* EffectChangeSpeed::mpFromLengthCtrl
private

Definition at line 111 of file ChangeSpeed.h.

Referenced by OnTimeCtrlUpdate(), PopulateOrExchange(), and TransferDataToWindow().

wxSlider* EffectChangeSpeed::mpSlider_PercentChange
private
wxTextCtrl* EffectChangeSpeed::mpTextCtrl_Multiplier
private

Definition at line 107 of file ChangeSpeed.h.

Referenced by OnText_Multiplier(), PopulateOrExchange(), and Update_Text_Multiplier().

wxTextCtrl* EffectChangeSpeed::mpTextCtrl_PercentChange
private
NumericTextCtrl* EffectChangeSpeed::mpToLengthCtrl
private
double EffectChangeSpeed::mRate
private

Definition at line 113 of file ChangeSpeed.h.

int EffectChangeSpeed::mTimeCtrlFormat
private

Definition at line 100 of file ChangeSpeed.h.

double EffectChangeSpeed::mToLength
private
int EffectChangeSpeed::mToVinyl
private

Definition at line 116 of file ChangeSpeed.h.

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


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