Audacity 3.2.0
ToneGenBase.h
Go to the documentation of this file.
1/**********************************************************************
2
3 Audacity: A Digital Audio Editor
4
5 Split from ToneGen.h
6
7 Steve Jolly
8
9 This class implements a tone generator effect.
10
11**********************************************************************/
12#pragma once
13
14#include "SettingsVisitor.h" // EffectParameter
16#include <float.h> // for DBL_MAX
17
18class NumericTextCtrl;
19class ShuttleGui;
20
21class BUILTIN_EFFECTS_API ToneGenBase : public StatefulPerTrackEffect
22{
23public:
25 {
26 return &e;
27 }
28 ToneGenBase(bool isChirp);
29 virtual ~ToneGenBase();
30
31 // EffectDefinitionInterface implementation
32
33 EffectType GetType() const override;
34
35 unsigned GetAudioOutCount() const override;
38 ChannelNames chanMap) override;
39 size_t ProcessBlock(
40 EffectSettings& settings, const float* const* inBlock,
41 float* const* outBlock, size_t blockLen) override;
42
43protected:
44 double mSampleRate {};
45 const bool mChirp;
46
47private:
48 // mSample is an external placeholder to remember the last "buffer"
49 // position so we use it to reinitialize from where we left
52
53protected:
54 // If we made these static variables,
55 // Tone and Chirp would share the same parameters.
62
63private:
64 double mLogFrequency[2];
65
66 void PostSet();
67
68 const EffectParameterMethods& Parameters() const override;
69
70protected:
72 {
78 nWaveforms
79 };
80
81 static const EnumValueSymbol kWaveStrings[nWaveforms];
82
84 {
87 nInterpolations
88 };
89
90 static const EnumValueSymbol kInterStrings[nInterpolations];
91
92 // Yes, mFrequency0 and mAmplitude0 are each associated with more than one
93 static constexpr EffectParameter StartFreq {
94 &ToneGenBase::mFrequency0, L"StartFreq", 440.0, 1.0, DBL_MAX, 1
95 };
96 static constexpr EffectParameter EndFreq {
97 &ToneGenBase::mFrequency1, L"EndFreq", 1320.0, 1.0, DBL_MAX, 1
98 };
99 static constexpr EffectParameter StartAmp {
100 &ToneGenBase::mAmplitude0, L"StartAmp", 0.8, 0.0, 1.0, 1
101 };
102 static constexpr EffectParameter EndAmp {
103 &ToneGenBase::mAmplitude1, L"EndAmp", 0.1, 0.0, 1.0, 1
104 };
105 static constexpr EffectParameter Frequency {
106 &ToneGenBase::mFrequency0, L"Frequency", 440.0, 1.0, DBL_MAX, 1
107 };
108 static constexpr EffectParameter Amplitude {
109 &ToneGenBase::mAmplitude0, L"Amplitude", 0.8, 0.0, 1.0, 1
110 };
112 L"Waveform",
113 0,
114 0,
115 nWaveforms - 1,
116 1,
117 kWaveStrings,
118 nWaveforms };
119 static constexpr EnumParameter Interp { &ToneGenBase::mInterpolation,
120 L"Interpolation",
121 0,
122 0,
123 nInterpolations - 1,
124 1,
125 kInterStrings,
126 nInterpolations };
127};
EffectType
ChannelName
static Settings & settings()
Definition: TrackInfo.cpp:51
ComponentInterfaceSymbol pairs a persistent string identifier used internally with an optional,...
virtual EffectType GetType() const =0
Type determines how it behaves.
virtual const EffectParameterMethods & Parameters() const
Definition: Effect.cpp:96
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
virtual unsigned GetAudioOutCount() const
How many output buffers to allocate at once.
Base class for many of the effects in Audacity.
bool ProcessInitialize(EffectSettings &settings, double sampleRate, ChannelNames chanMap=nullptr) override
virtual size_t ProcessBlock(EffectSettings &settings, const float *const *inBlock, float *const *outBlock, size_t blockLen)=0
Called for destructive effect computation.
An Effect that can generate a sine, square or sawtooth wave. An extended mode of ToneGenBase supports...
Definition: ToneGenBase.h:22
double mAmplitude1
Definition: ToneGenBase.h:61
const bool mChirp
Definition: ToneGenBase.h:45
sampleCount mSample
Definition: ToneGenBase.h:50
static ToneGenBase * FetchParameters(ToneGenBase &e, EffectSettings &)
Definition: ToneGenBase.h:24
double mFrequency0
Definition: ToneGenBase.h:58
double mFrequency1
Definition: ToneGenBase.h:59
int mInterpolation
Definition: ToneGenBase.h:57
double mAmplitude0
Definition: ToneGenBase.h:60
double mPositionInCycles
Definition: ToneGenBase.h:51
Positions or offsets within audio files need a wide type.
Definition: SampleCount.h:19
Externalized state of a plug-in.