Audacity  2.2.2
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 IdentInterfaceSymbol{ XO("DTMF Tones") }
29 
30 class EffectDtmf final : public Effect
31 {
32 public:
33  EffectDtmf();
34  virtual ~EffectDtmf();
35 
36  // IdentInterface implementation
37 
39  wxString GetDescription() override;
40  wxString ManualPage() override;
41 
42  // EffectDefinitionInterface 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 DefineParams( ShuttleParams & S ) override;
52  bool GetAutomationParameters(CommandParameters & parms) override;
53  bool SetAutomationParameters(CommandParameters & parms) override;
54 
55  // Effect implementation
56 
57  bool Startup() override;
58  bool Init() override;
59  void PopulateOrExchange(ShuttleGui & S) override;
60  bool TransferDataFromWindow() override;
61  bool TransferDataToWindow() override;
62 
63 private:
64  // EffectDtmf implementation
65 
66  bool MakeDtmfTone(float *buffer, size_t len, float fs,
67  wxChar tone, sampleCount last,
68  sampleCount total, float amplitude);
69  void Recalculate();
70 
71  void UpdateUI();
72 
73  void OnSequence(wxCommandEvent & evt);
74  void OnAmplitude(wxCommandEvent & evt);
75  void OnDuration(wxCommandEvent & evt);
76  void OnDutyCycle(wxCommandEvent & evt);
77 
78 private:
79  sampleCount numSamplesSequence; // total number of samples to generate
80  sampleCount numSamplesTone; // number of samples in a tone block
81  sampleCount numSamplesSilence; // number of samples in a silence block
82  sampleCount diff; // number of extra samples to redistribute
83  sampleCount numRemaining; // number of samples left to produce in the current block
84  sampleCount curTonePos; // position in tone to start the wave
85  bool isTone; // true if block is tone, otherwise silence
86  int curSeqPos; // index into dtmf tone string
87 
88  wxString dtmfSequence; // dtmf tone string
89  int dtmfNTones; // total number of tones to generate
90  double dtmfTone; // duration of a single tone in ms
91  double dtmfSilence; // duration of silence between tones in ms
92  double dtmfDutyCycle; // ratio of dtmfTone/(dtmfTone+dtmfSilence)
93  double dtmfAmplitude; // amplitude of dtmf tone sequence, restricted to (0-1)
94 
95  wxTextCtrl *mDtmfSequenceT;
96  wxTextCtrl *mDtmfAmplitudeT;
97  wxSlider *mDtmfDutyCycleS;
99  wxStaticText *mDtmfToneT;
100  wxStaticText *mDtmfSilenceT;
101  wxStaticText *mDtmfDutyT;
102 
103  DECLARE_EVENT_TABLE()
104 };
105 
106 #endif
void OnAmplitude(wxCommandEvent &evt)
Definition: DtmfGen.cpp:596
wxStaticText * mDtmfToneT
Definition: DtmfGen.h:99
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI...
Definition: ShuttleGui.h:409
EffectDtmf()
Definition: DtmfGen.cpp:79
wxStaticText * mDtmfDutyT
Definition: DtmfGen.h:101
wxSlider * mDtmfDutyCycleS
Definition: DtmfGen.h:97
void OnDutyCycle(wxCommandEvent &evt)
Definition: DtmfGen.cpp:612
void Recalculate()
Definition: DtmfGen.cpp:406
IdentInterfaceSymbol GetSymbol() override
Definition: DtmfGen.cpp:94
Base class for many of the effects in Audacity.
Definition: Effect.h:62
sampleCount numSamplesSilence
Definition: DtmfGen.h:81
Shuttle that deals with parameters. This is a base class with lots of virtual functions that do nothi...
Definition: Shuttle.h:60
bool Startup() override
Definition: DtmfGen.cpp:276
size_t ProcessBlock(float **inBlock, float **outBlock, size_t blockLen) override
Definition: DtmfGen.cpp:166
sampleCount diff
Definition: DtmfGen.h:82
wxString dtmfSequence
Definition: DtmfGen.h:88
int curSeqPos
Definition: DtmfGen.h:86
wxTextCtrl * mDtmfSequenceT
Definition: DtmfGen.h:95
bool ProcessInitialize(sampleCount totalLen, ChannelNames chanMap=NULL) override
Definition: DtmfGen.cpp:123
void OnSequence(wxCommandEvent &evt)
Definition: DtmfGen.cpp:589
void OnDuration(wxCommandEvent &evt)
Definition: DtmfGen.cpp:605
void PopulateOrExchange(ShuttleGui &S) override
Definition: DtmfGen.cpp:312
bool DefineParams(ShuttleParams &S) override
Definition: DtmfGen.cpp:232
unsigned GetAudioOutCount() override
Definition: DtmfGen.cpp:118
double dtmfAmplitude
Definition: DtmfGen.h:93
bool TransferDataToWindow() override
Definition: DtmfGen.cpp:369
sampleCount numRemaining
Definition: DtmfGen.h:83
CommandParameters, derived from wxFileConfig, is essentially doing the same things as the Shuttle cla...
sampleCount numSamplesSequence
Definition: DtmfGen.h:79
double dtmfSilence
Definition: DtmfGen.h:91
bool MakeDtmfTone(float *buffer, size_t len, float fs, wxChar tone, sampleCount last, sampleCount total, float amplitude)
Definition: DtmfGen.cpp:448
void UpdateUI()
Definition: DtmfGen.cpp:577
wxTextCtrl * mDtmfAmplitudeT
Definition: DtmfGen.h:96
IdentInterfaceSymbol pairs a persistent string identifier used internally with an optional...
enum ChannelName * ChannelNames
wxStaticText * mDtmfSilenceT
Definition: DtmfGen.h:100
bool Init() override
Definition: DtmfGen.cpp:305
sampleCount curTonePos
Definition: DtmfGen.h:84
EffectType GetType() override
Definition: DtmfGen.cpp:111
bool SetAutomationParameters(CommandParameters &parms) override
Definition: DtmfGen.cpp:248
EffectType
bool TransferDataFromWindow() override
Definition: DtmfGen.cpp:387
An effect that generates DTMF tones.
Definition: DtmfGen.h:30
double dtmfDutyCycle
Definition: DtmfGen.h:92
int dtmfNTones
Definition: DtmfGen.h:89
NumericTextCtrl * mDtmfDurationT
Definition: DtmfGen.h:98
sampleCount numSamplesTone
Definition: DtmfGen.h:80
wxString GetDescription() override
Definition: DtmfGen.cpp:99
bool GetAutomationParameters(CommandParameters &parms) override
Definition: DtmfGen.cpp:239
virtual ~EffectDtmf()
Definition: DtmfGen.cpp:88
double dtmfTone
Definition: DtmfGen.h:90
wxString ManualPage() override
Definition: DtmfGen.cpp:104
bool isTone
Definition: DtmfGen.h:85