Audacity 3.2.0
ChangeTempo.h
Go to the documentation of this file.
1/**********************************************************************
2
3 Audacity: A Digital Audio Editor
4
5 ChangeTempo.h
6
7 Vaughan Johnson, Dominic Mazzoni
8
9 Change Tempo effect provides speeding up or
10 slowing down tempo without changing pitch.
11
12**********************************************************************/
13
14
15#if USE_SOUNDTOUCH
16
17#ifndef __AUDACITY_EFFECT_CHANGETEMPO__
18#define __AUDACITY_EFFECT_CHANGETEMPO__
19
20#if USE_SBSMS
21#include "SBSMSEffect.h"
22#endif
23
24#include "SoundTouchEffect.h"
25#include "ShuttleAutomation.h"
26#include <wx/weakref.h>
27
28class wxSlider;
29class wxCheckBox;
30class wxTextCtrl;
31class ShuttleGui;
32
33class EffectChangeTempo final : public EffectSoundTouch
34{
35public:
36 static inline EffectChangeTempo *
37 FetchParameters(EffectChangeTempo &e, EffectSettings &) { return &e; }
38 static const ComponentInterfaceSymbol Symbol;
39
41 virtual ~EffectChangeTempo();
42
43 // ComponentInterface implementation
44
45 ComponentInterfaceSymbol GetSymbol() const override;
46 TranslatableString GetDescription() const override;
47 ManualPageID ManualPage() const override;
48
49 // EffectDefinitionInterface implementation
50
51 EffectType GetType() const override;
52 bool SupportsAutomation() const override;
53
54 // Effect implementation
55
56 bool Init() override;
57 bool CheckWhetherSkipEffect(const EffectSettings &settings) const override;
58 bool Process(EffectInstance &instance, EffectSettings &settings) override;
59 double CalcPreviewInputLength(
60 const EffectSettings &settings, double previewLength) const override;
61 std::unique_ptr<EffectEditor> PopulateOrExchange(
62 ShuttleGui & S, EffectInstance &instance,
63 EffectSettingsAccess &access, const EffectOutputs *pOutputs) override;
64 bool TransferDataToWindow(const EffectSettings &settings) override;
65 bool TransferDataFromWindow(EffectSettings &settings) override;
66
67private:
68 // EffectChangeTempo implementation
69
70 // handlers
71 void OnText_PercentChange(wxCommandEvent & evt);
72 void OnSlider_PercentChange(wxCommandEvent & evt);
73 void OnText_FromBPM(wxCommandEvent & evt);
74 void OnText_ToBPM(wxCommandEvent & evt);
75 void OnText_ToLength(wxCommandEvent & evt);
76
77 // helper fns
78 void Update_Text_PercentChange(); // Update control per current m_PercentChange.
79 void Update_Slider_PercentChange(); // Update control per current m_PercentChange.
80 void Update_Text_ToBPM(); // Use m_FromBPM & m_PercentChange to set NEW m_ToBPM & control.
81 void Update_Text_ToLength(); // Use m_FromLength & m_PercentChange to set NEW m_ToLength & control.
82
83private:
84 wxWeakRef<wxWindow> mUIParent{};
85
86 bool mUseSBSMS;
87 double m_PercentChange; // percent change to apply to tempo
88 // -100% is meaningless, but sky's the upper limit
89 double m_FromBPM; // user-set beats-per-minute. Zero means not yet set.
90 double m_ToBPM; // Zero value means not yet set.
91 double m_FromLength; // starting length of selection
92 double m_ToLength; // target length of selection
93
94 bool m_bLoopDetect;
95
96 // controls
97 wxTextCtrl * m_pTextCtrl_PercentChange;
98 wxSlider * m_pSlider_PercentChange;
99 wxTextCtrl * m_pTextCtrl_FromBPM;
100 wxTextCtrl * m_pTextCtrl_ToBPM;
101 wxTextCtrl * m_pTextCtrl_FromLength;
102 wxTextCtrl * m_pTextCtrl_ToLength;
103
104#if USE_SBSMS
105 wxCheckBox * mUseSBSMSCheckBox;
106#endif
107
108 const EffectParameterMethods& Parameters() const override;
109 DECLARE_EVENT_TABLE()
110
111static constexpr EffectParameter Percentage{ &EffectChangeTempo::m_PercentChange,
112 L"Percentage", 0.0, -95.0, 3000.0, 1 };
113static constexpr EffectParameter UseSBSMS{ &EffectChangeTempo::mUseSBSMS,
114 L"SBSMS", false, false, true, 1 };
115};
116
117#endif // __AUDACITY_EFFECT_CHANGETEMPO__
118
119#endif // USE_SOUNDTOUCH
EffectType
#define S(N)
Definition: ToChars.cpp:64
static Settings & settings()
Definition: TrackInfo.cpp:69
ComponentInterfaceSymbol pairs a persistent string identifier used internally with an optional,...
An EffectSoundTouch provides speeding up or slowing down tempo without changing pitch.
Performs effect computation.
Hold values to send to effect output meters.
Interface for manipulations of an Effect's settings.
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI.
Definition: ShuttleGui.h:640
Holds a msgid for the translation catalog; may also bind format arguments.
Externalized state of a plug-in.