Audacity  3.0.3
Phaser.h
Go to the documentation of this file.
1 /**********************************************************************
2 
3  Audacity: A Digital Audio Editor
4 
5  Phaser
6 
7  Effect programming:
8  Nasca Octavian Paul (Paul Nasca)
9 
10  UI programming:
11  Dominic Mazzoni (with the help of wxDesigner)
12  Vaughan Johnson (Preview)
13 
14 **********************************************************************/
15 
16 #ifndef __AUDACITY_EFFECT_PHASER__
17 #define __AUDACITY_EFFECT_PHASER__
18 
19 #include "Effect.h"
20 
21 class wxSlider;
22 class wxTextCtrl;
23 class ShuttleGui;
24 
25 #define NUM_STAGES 24
26 
28 {
29 public:
30  // state variables
31  float samplerate;
33  double old[NUM_STAGES]; // must be as large as MAX_STAGES
34  double gain;
35  double fbout;
36  double outgain;
37  double lfoskip;
38  double phase;
40 };
41 
42 class EffectPhaser final : public Effect
43 {
44 public:
46 
47  EffectPhaser();
48  virtual ~EffectPhaser();
49 
50  // ComponentInterface implementation
51 
54  wxString ManualPage() override;
55 
56  // EffectDefinitionInterface implementation
57 
58  EffectType GetType() override;
59  bool SupportsRealtime() override;
60 
61  // EffectClientInterface implementation
62 
63  unsigned GetAudioInCount() override;
64  unsigned GetAudioOutCount() override;
65  bool ProcessInitialize(sampleCount totalLen, ChannelNames chanMap = NULL) override;
66  size_t ProcessBlock(float **inBlock, float **outBlock, size_t blockLen) override;
67  bool RealtimeInitialize() override;
68  bool RealtimeAddProcessor(unsigned numChannels, float sampleRate) override;
69  bool RealtimeFinalize() override;
70  size_t RealtimeProcess(int group,
71  float **inbuf,
72  float **outbuf,
73  size_t numSamples) override;
74  bool DefineParams( ShuttleParams & S ) override;
75  bool GetAutomationParameters(CommandParameters & parms) override;
76  bool SetAutomationParameters(CommandParameters & parms) override;
77 
78  // Effect implementation
79 
80  void PopulateOrExchange(ShuttleGui & S) override;
81  bool TransferDataToWindow() override;
82  bool TransferDataFromWindow() override;
83 
84 private:
85  // EffectPhaser implementation
86 
87  void InstanceInit(EffectPhaserState & data, float sampleRate);
88  size_t InstanceProcess(EffectPhaserState & data, float **inBlock, float **outBlock, size_t blockLen);
89 
90  void OnStagesSlider(wxCommandEvent & evt);
91  void OnDryWetSlider(wxCommandEvent & evt);
92  void OnFeedbackSlider(wxCommandEvent & evt);
93  void OnDepthSlider(wxCommandEvent & evt);
94  void OnPhaseSlider(wxCommandEvent & evt);
95  void OnFreqSlider(wxCommandEvent & evt);
96  void OnGainSlider(wxCommandEvent & evt);
97 
98  void OnStagesText(wxCommandEvent & evt);
99  void OnDryWetText(wxCommandEvent & evt);
100  void OnFeedbackText(wxCommandEvent & evt);
101  void OnDepthText(wxCommandEvent & evt);
102  void OnPhaseText(wxCommandEvent & evt);
103  void OnFreqText(wxCommandEvent & evt);
104  void OnGainText(wxCommandEvent & evt);
105 /*
106  Phaser Parameters
107 
108  mFreq - Phaser's LFO frequency
109  mPhase - Phaser's LFO startphase (radians), needed for stereo Phasers
110  mDepth - Phaser depth (0 - no depth, 255 - max depth)
111  mStages - Phaser stages (recomanded from 2 to 16-24, and EVEN NUMBER)
112  mDryWet - Dry/wet mix, (0 - dry, 128 - dry=wet, 255 - wet)
113  mFeedback - Phaser FeedBack (0 - no feedback, 100 = 100% Feedback,
114  -100 = -100% FeedBack)
115 */
116 
117 private:
119  std::vector<EffectPhaserState> mSlaves;
120 
121  // parameters
122  int mStages;
123  int mDryWet;
124  double mFreq;
125  double mPhase;
126  int mDepth;
128  double mOutGain;
129 
130  wxTextCtrl *mStagesT;
131  wxTextCtrl *mDryWetT;
132  wxTextCtrl *mFreqT;
133  wxTextCtrl *mPhaseT;
134  wxTextCtrl *mDepthT;
135  wxTextCtrl *mFeedbackT;
136  wxTextCtrl *mOutGainT;
137 
138  wxSlider *mStagesS;
139  wxSlider *mDryWetS;
140  wxSlider *mFreqS;
141  wxSlider *mPhaseS;
142  wxSlider *mDepthS;
143  wxSlider *mFeedbackS;
144  wxSlider *mOutGainS;
145 
146  DECLARE_EVENT_TABLE()
147 };
148 
149 #endif
TranslatableString
Holds a msgid for the translation catalog; may also bind format arguments.
Definition: TranslatableString.h:32
EffectPhaser::mFreq
double mFreq
Definition: Phaser.h:124
CommandParameters
CommandParameters, derived from wxFileConfig, is essentially doing the same things as the Shuttle cla...
Definition: EffectAutomationParameters.h:67
EffectPhaser::OnDepthText
void OnDepthText(wxCommandEvent &evt)
Definition: Phaser.cpp:548
EffectPhaserState::outgain
double outgain
Definition: Phaser.h:36
EffectPhaser::mPhaseT
wxTextCtrl * mPhaseT
Definition: Phaser.h:133
EffectPhaser::mDryWetT
wxTextCtrl * mDryWetT
Definition: Phaser.h:131
EffectPhaser::RealtimeProcess
size_t RealtimeProcess(int group, float **inbuf, float **outbuf, size_t numSamples) override
Definition: Phaser.cpp:194
EffectPhaser
An Effect that changes frequencies in a time varying manner.
Definition: Phaser.h:43
Effect.h
EffectPhaser::mFeedback
int mFeedback
Definition: Phaser.h:127
EffectPhaser::SetAutomationParameters
bool SetAutomationParameters(CommandParameters &parms) override
Definition: Phaser.cpp:226
Effect
Base class for many of the effects in Audacity.
Definition: Effect.h:70
EffectPhaserState::samplerate
float samplerate
Definition: Phaser.h:31
EffectPhaser::OnPhaseText
void OnPhaseText(wxCommandEvent &evt)
Definition: Phaser.cpp:538
EffectPhaserState::gain
double gain
Definition: Phaser.h:34
EffectPhaser::ProcessBlock
size_t ProcessBlock(float **inBlock, float **outBlock, size_t blockLen) override
Definition: Phaser.cpp:162
EffectPhaser::GetAutomationParameters
bool GetAutomationParameters(CommandParameters &parms) override
Definition: Phaser.cpp:213
EffectPhaser::mFreqT
wxTextCtrl * mFreqT
Definition: Phaser.h:132
ShuttleParams
Shuttle that deals with parameters. This is a base class with lots of virtual functions that do nothi...
Definition: Shuttle.h:61
EffectPhaser::RealtimeFinalize
bool RealtimeFinalize() override
Definition: Phaser.cpp:187
EffectPhaser::OnPhaseSlider
void OnPhaseSlider(wxCommandEvent &evt)
Definition: Phaser.cpp:473
EffectPhaser::mOutGain
double mOutGain
Definition: Phaser.h:128
EffectPhaser::mStagesS
wxSlider * mStagesS
Definition: Phaser.h:138
EffectPhaser::mOutGainT
wxTextCtrl * mOutGainT
Definition: Phaser.h:136
ComponentInterfaceSymbol
ComponentInterfaceSymbol pairs a persistent string identifier used internally with an optional,...
Definition: ComponentInterface.h:61
EffectPhaserState
Definition: Phaser.h:28
EffectPhaser::~EffectPhaser
virtual ~EffectPhaser()
Definition: Phaser.cpp:102
EffectPhaser::SupportsRealtime
bool SupportsRealtime() override
Definition: Phaser.cpp:130
NUM_STAGES
#define NUM_STAGES
Definition: Phaser.h:25
EffectPhaser::InstanceInit
void InstanceInit(EffectPhaserState &data, float sampleRate)
Definition: Phaser.cpp:382
EffectPhaser::PopulateOrExchange
void PopulateOrExchange(ShuttleGui &S) override
Definition: Phaser.cpp:254
EffectPhaser::OnDepthSlider
void OnDepthSlider(wxCommandEvent &evt)
Definition: Phaser.cpp:483
EffectPhaser::GetDescription
TranslatableString GetDescription() override
Definition: Phaser.cpp:113
EffectPhaser::DefineParams
bool DefineParams(ShuttleParams &S) override
Definition: Phaser.cpp:202
EffectPhaser::mDepthS
wxSlider * mDepthS
Definition: Phaser.h:142
EffectPhaser::OnStagesText
void OnStagesText(wxCommandEvent &evt)
Definition: Phaser.cpp:508
EffectPhaser::OnFeedbackText
void OnFeedbackText(wxCommandEvent &evt)
Definition: Phaser.cpp:558
EffectPhaserState::lfoskip
double lfoskip
Definition: Phaser.h:37
EffectPhaser::RealtimeAddProcessor
bool RealtimeAddProcessor(unsigned numChannels, float sampleRate) override
Definition: Phaser.cpp:176
ChannelNames
enum ChannelName * ChannelNames
EffectPhaser::mMaster
EffectPhaserState mMaster
Definition: Phaser.h:118
EffectPhaser::ProcessInitialize
bool ProcessInitialize(sampleCount totalLen, ChannelNames chanMap=NULL) override
Definition: Phaser.cpp:151
EffectPhaser::GetSymbol
ComponentInterfaceSymbol GetSymbol() override
Definition: Phaser.cpp:108
EffectPhaserState::phase
double phase
Definition: Phaser.h:38
EffectPhaser::mDryWet
int mDryWet
Definition: Phaser.h:123
EffectPhaserState::laststages
int laststages
Definition: Phaser.h:39
EffectPhaser::mStagesT
wxTextCtrl * mStagesT
Definition: Phaser.h:130
EffectPhaser::mPhase
double mPhase
Definition: Phaser.h:125
EffectPhaser::OnFreqSlider
void OnFreqSlider(wxCommandEvent &evt)
Definition: Phaser.cpp:465
EffectPhaserState::fbout
double fbout
Definition: Phaser.h:35
EffectPhaser::GetAudioOutCount
unsigned GetAudioOutCount() override
Definition: Phaser.cpp:146
EffectPhaserState::skipcount
sampleCount skipcount
Definition: Phaser.h:32
EffectPhaserState::old
double old[NUM_STAGES]
Definition: Phaser.h:33
EffectPhaser::OnGainSlider
void OnGainSlider(wxCommandEvent &evt)
Definition: Phaser.cpp:501
EffectPhaser::InstanceProcess
size_t InstanceProcess(EffectPhaserState &data, float **inBlock, float **outBlock, size_t blockLen)
Definition: Phaser.cpp:400
EffectPhaser::mFeedbackS
wxSlider * mFeedbackS
Definition: Phaser.h:143
EffectPhaser::mStages
int mStages
Definition: Phaser.h:122
EffectPhaser::OnGainText
void OnGainText(wxCommandEvent &evt)
Definition: Phaser.cpp:568
EffectPhaser::mSlaves
std::vector< EffectPhaserState > mSlaves
Definition: Phaser.h:119
EffectPhaser::mDryWetS
wxSlider * mDryWetS
Definition: Phaser.h:139
EffectPhaser::OnDryWetSlider
void OnDryWetSlider(wxCommandEvent &evt)
Definition: Phaser.cpp:458
EffectPhaser::mOutGainS
wxSlider * mOutGainS
Definition: Phaser.h:144
EffectPhaser::OnFreqText
void OnFreqText(wxCommandEvent &evt)
Definition: Phaser.cpp:528
sampleCount
Definition: Types.h:66
EffectPhaser::mDepthT
wxTextCtrl * mDepthT
Definition: Phaser.h:134
EffectPhaser::mFreqS
wxSlider * mFreqS
Definition: Phaser.h:140
EffectPhaser::ManualPage
wxString ManualPage() override
Definition: Phaser.cpp:118
EffectPhaser::GetType
EffectType GetType() override
Definition: Phaser.cpp:125
EffectPhaser::OnFeedbackSlider
void OnFeedbackSlider(wxCommandEvent &evt)
Definition: Phaser.cpp:490
EffectPhaser::Symbol
static const ComponentInterfaceSymbol Symbol
Definition: Phaser.h:45
EffectPhaser::TransferDataToWindow
bool TransferDataToWindow() override
Definition: Phaser.cpp:346
EffectPhaser::mDepth
int mDepth
Definition: Phaser.h:126
EffectPhaser::RealtimeInitialize
bool RealtimeInitialize() override
Definition: Phaser.cpp:167
EffectPhaser::EffectPhaser
EffectPhaser()
Definition: Phaser.cpp:89
EffectPhaser::mFeedbackT
wxTextCtrl * mFeedbackT
Definition: Phaser.h:135
EffectPhaser::GetAudioInCount
unsigned GetAudioInCount() override
Definition: Phaser.cpp:141
EffectPhaser::TransferDataFromWindow
bool TransferDataFromWindow() override
Definition: Phaser.cpp:364
EffectPhaser::OnDryWetText
void OnDryWetText(wxCommandEvent &evt)
Definition: Phaser.cpp:518
EffectType
EffectType
Definition: EffectInterface.h:55
EffectPhaser::mPhaseS
wxSlider * mPhaseS
Definition: Phaser.h:141
ShuttleGui
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI.
Definition: ShuttleGui.h:625
EffectPhaser::OnStagesSlider
void OnStagesSlider(wxCommandEvent &evt)
Definition: Phaser.cpp:451