Audacity  2.2.0
DtmfGen.h
Go to the documentation of this file.
1 /**********************************************************************
2 
3  Audacity: A Digital Audio Editor
4 
5  DtmfGen.h
6 
7  Salvo Ventura
8  Dec 2006
9 
10  An effect that generates DTMF tones
11 
12 **********************************************************************/
13 
14 #ifndef __AUDACITY_EFFECT_DTMF__
15 #define __AUDACITY_EFFECT_DTMF__
16 
17 #include <wx/event.h>
18 #include <wx/slider.h>
19 #include <wx/stattext.h>
20 #include <wx/string.h>
21 
22 #include "../widgets/NumericTextCtrl.h"
23 
24 #include "Effect.h"
25 
26 class ShuttleGui;
27 
28 #define DTMFTONES_PLUGIN_SYMBOL XO("DTMF Tones")
29 
30 class EffectDtmf final : public Effect
31 {
32 public:
33  EffectDtmf();
34  virtual ~EffectDtmf();
35 
36  // IdentInterface implementation
37 
38  wxString GetSymbol() override;
39  wxString GetDescription() override;
40  wxString ManualPage() override;
41 
42  // EffectIdentInterface implementation
43 
44  EffectType GetType() override;
45 
46  // EffectClientInterface implementation
47 
48  unsigned GetAudioOutCount() override;
49  bool ProcessInitialize(sampleCount totalLen, ChannelNames chanMap = NULL) override;
50  size_t ProcessBlock(float **inBlock, float **outBlock, size_t blockLen) override;
51  bool GetAutomationParameters(EffectAutomationParameters & parms) override;
52  bool SetAutomationParameters(EffectAutomationParameters & parms) override;
53 
54  // Effect implementation
55 
56  bool Startup() override;
57  bool Init() override;
58  void PopulateOrExchange(ShuttleGui & S) override;
59  bool TransferDataFromWindow() override;
60  bool TransferDataToWindow() override;
61 
62 private:
63  // EffectDtmf implementation
64 
65  bool MakeDtmfTone(float *buffer, size_t len, float fs,
66  wxChar tone, sampleCount last,
67  sampleCount total, float amplitude);
68  void Recalculate();
69 
70  void UpdateUI();
71 
72  void OnSequence(wxCommandEvent & evt);
73  void OnAmplitude(wxCommandEvent & evt);
74  void OnDuration(wxCommandEvent & evt);
75  void OnDutyCycle(wxCommandEvent & evt);
76 
77 private:
78  sampleCount numSamplesSequence; // total number of samples to generate
79  sampleCount numSamplesTone; // number of samples in a tone block
80  sampleCount numSamplesSilence; // number of samples in a silence block
81  sampleCount diff; // number of extra samples to redistribute
82  sampleCount numRemaining; // number of samples left to produce in the current block
83  sampleCount curTonePos; // position in tone to start the wave
84  bool isTone; // true if block is tone, otherwise silence
85  int curSeqPos; // index into dtmf tone string
86 
87  wxString dtmfSequence; // dtmf tone string
88  int dtmfNTones; // total number of tones to generate
89  double dtmfTone; // duration of a single tone in ms
90  double dtmfSilence; // duration of silence between tones in ms
91  double dtmfDutyCycle; // ratio of dtmfTone/(dtmfTone+dtmfSilence)
92  double dtmfAmplitude; // amplitude of dtmf tone sequence, restricted to (0-1)
93 
94  wxTextCtrl *mDtmfSequenceT;
95  wxTextCtrl *mDtmfAmplitudeT;
96  wxSlider *mDtmfDutyCycleS;
98  wxStaticText *mDtmfToneT;
99  wxStaticText *mDtmfSilenceT;
100  wxStaticText *mDtmfDutyT;
101 
102  DECLARE_EVENT_TABLE()
103 };
104 
105 #endif
void OnAmplitude(wxCommandEvent &evt)
Definition: DtmfGen.cpp:593
wxStaticText * mDtmfToneT
Definition: DtmfGen.h:98
wxString GetSymbol() override
Definition: DtmfGen.cpp:94
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI...
Definition: ShuttleGui.h:366
bool GetAutomationParameters(EffectAutomationParameters &parms) override
Definition: DtmfGen.cpp:233
EffectDtmf()
Definition: DtmfGen.cpp:79
wxStaticText * mDtmfDutyT
Definition: DtmfGen.h:100
wxSlider * mDtmfDutyCycleS
Definition: DtmfGen.h:96
void OnDutyCycle(wxCommandEvent &evt)
Definition: DtmfGen.cpp:609
void Recalculate()
Definition: DtmfGen.cpp:403
Base class for many of the effects in Audacity.
Definition: Effect.h:62
sampleCount numSamplesSilence
Definition: DtmfGen.h:80
bool Startup() override
Definition: DtmfGen.cpp:270
size_t ProcessBlock(float **inBlock, float **outBlock, size_t blockLen) override
Definition: DtmfGen.cpp:166
sampleCount diff
Definition: DtmfGen.h:81
wxString dtmfSequence
Definition: DtmfGen.h:87
int curSeqPos
Definition: DtmfGen.h:85
wxTextCtrl * mDtmfSequenceT
Definition: DtmfGen.h:94
bool ProcessInitialize(sampleCount totalLen, ChannelNames chanMap=NULL) override
Definition: DtmfGen.cpp:123
void OnSequence(wxCommandEvent &evt)
Definition: DtmfGen.cpp:586
void OnDuration(wxCommandEvent &evt)
Definition: DtmfGen.cpp:602
void PopulateOrExchange(ShuttleGui &S) override
Definition: DtmfGen.cpp:306
unsigned GetAudioOutCount() override
Definition: DtmfGen.cpp:118
double dtmfAmplitude
Definition: DtmfGen.h:92
bool TransferDataToWindow() override
Definition: DtmfGen.cpp:366
sampleCount numRemaining
Definition: DtmfGen.h:82
sampleCount numSamplesSequence
Definition: DtmfGen.h:78
double dtmfSilence
Definition: DtmfGen.h:90
bool MakeDtmfTone(float *buffer, size_t len, float fs, wxChar tone, sampleCount last, sampleCount total, float amplitude)
Definition: DtmfGen.cpp:445
void UpdateUI()
Definition: DtmfGen.cpp:574
wxTextCtrl * mDtmfAmplitudeT
Definition: DtmfGen.h:95
wxStaticText * mDtmfSilenceT
Definition: DtmfGen.h:99
bool Init() override
Definition: DtmfGen.cpp:299
Definition: NumericTextCtrl.h:141
sampleCount curTonePos
Definition: DtmfGen.h:83
EffectType GetType() override
Definition: DtmfGen.cpp:111
bool TransferDataFromWindow() override
Definition: DtmfGen.cpp:384
An effect that generates DTMF tones.
Definition: DtmfGen.h:30
double dtmfDutyCycle
Definition: DtmfGen.h:91
int dtmfNTones
Definition: DtmfGen.h:88
NumericTextCtrl * mDtmfDurationT
Definition: DtmfGen.h:97
sampleCount numSamplesTone
Definition: DtmfGen.h:79
wxString GetDescription() override
Definition: DtmfGen.cpp:99
virtual ~EffectDtmf()
Definition: DtmfGen.cpp:88
double dtmfTone
Definition: DtmfGen.h:89
bool SetAutomationParameters(EffectAutomationParameters &parms) override
Definition: DtmfGen.cpp:242
wxString ManualPage() override
Definition: DtmfGen.cpp:104
bool isTone
Definition: DtmfGen.h:84