Audacity 3.2.0
ChangeSpeedBase.h
Go to the documentation of this file.
1#pragma once
2
3#include "SettingsVisitor.h"
4#include "StatefulEffect.h"
5
6class LabelTrack;
7class WaveChannel;
8
9// the standard vinyl rpm choices
10// If the percent change is not one of these ratios, the choice control gets
11// "n/a".
13{
18};
19
20class BUILTIN_EFFECTS_API ChangeSpeedBase : public StatefulEffect
21{
22public:
23 static inline ChangeSpeedBase*
25 {
26 return &e;
27 }
29
31 virtual ~ChangeSpeedBase();
32
33 // ComponentInterface implementation
34
35 ComponentInterfaceSymbol GetSymbol() const override;
36 TranslatableString GetDescription() const override;
37 ManualPageID ManualPage() const override;
38
39 // EffectDefinitionInterface implementation
40
41 EffectType GetType() const override;
43 OptionalMessage DoLoadFactoryDefaults(EffectSettings& settings);
44
45 bool CheckWhetherSkipEffect(const EffectSettings& settings) const override;
47 const EffectSettings& settings, double previewLength) const override;
48 bool Init() override;
49 bool Process(EffectInstance& instance, EffectSettings& settings) override;
50
51private:
52 // ChangeSpeedBase implementation
53
54 using Gap = std::pair<double, double>;
55 using Gaps = std::vector<Gap>;
56 Gaps
57 FindGaps(const WaveTrack& track, const double curT0, const double curT1);
58
59 bool ProcessOne(
60 const WaveChannel& track, WaveChannel& outputTrack, sampleCount start,
62 bool ProcessLabelTrack(LabelTrack* t);
63
64protected:
65 // track related
67 double mCurT0;
68 double mCurT1;
69
70 // control values
71 double
72 m_PercentChange; // percent change to apply to tempo
73 // -100% is meaningless, but sky's the upper limit.
74 // Slider is (-100, 200], but textCtrls can set higher.
75 int mFromVinyl; // from standard vinyl speed (RPM) enum
76 double mFactor; // scale factor calculated from percent change
77 double mFromLength; // current selection length
78 int mTimeCtrlFormat; // time control format index number
80
82
83 double mRate;
84
85 // private effect parameters
86 int mToVinyl; // to standard vinyl speed (rpm)
87 double mToLength; // target length of selection
88 NumericFormatID mFormat; // time control format
89
90 const EffectParameterMethods& Parameters() const override;
91
92 static constexpr EffectParameter Percentage {
93 &ChangeSpeedBase::m_PercentChange, L"Percentage", 0.0, -99.0, 4900.0, 1
94 };
95};
kVinyl
@ kVinyl_78
@ kVinyl_45
@ kVinyl_33AndAThird
@ kVinyl_NA
EffectType
std::optional< std::unique_ptr< EffectSettingsAccess::Message > > OptionalMessage
static Settings & settings()
Definition: TrackInfo.cpp:51
An Effect that affects both pitch & speed.
NumericFormatID mFormat
static const ComponentInterfaceSymbol Symbol
std::vector< Gap > Gaps
std::pair< double, double > Gap
static ChangeSpeedBase * FetchParameters(ChangeSpeedBase &e, EffectSettings &)
ComponentInterfaceSymbol pairs a persistent string identifier used internally with an optional,...
virtual EffectType GetType() const =0
Type determines how it behaves.
virtual ManualPageID ManualPage() const
Name of a page in the Audacity alpha manual, default is empty.
OptionalMessage LoadFactoryDefaults(EffectSettings &settings) const override
Definition: Effect.cpp:165
virtual const EffectParameterMethods & Parameters() const
Definition: Effect.cpp:96
TranslatableString GetDescription() const override
Definition: Effect.cpp:64
double CalcPreviewInputLength(const EffectSettings &settings, double previewLength) const override
Default implementation returns previewLength
Definition: Effect.cpp:384
bool CheckWhetherSkipEffect(const EffectSettings &settings) const override
Default implementation returns false.
Definition: Effect.cpp:379
ComponentInterfaceSymbol GetSymbol() const override
Definition: Effect.cpp:49
Performs effect computation.
Interface for manipulations of an Effect's settings.
A LabelTrack is a Track that holds labels (LabelStruct).
Definition: LabelTrack.h:98
virtual bool Process(EffectInstance &instance, EffectSettings &settings)=0
Holds a msgid for the translation catalog; may also bind format arguments.
A Track that contains audio waveform data.
Definition: WaveTrack.h:203
Positions or offsets within audio files need a wide type.
Definition: SampleCount.h:19
const char * end(const char *str) noexcept
Definition: StringUtils.h:106
Externalized state of a plug-in.