audacia/src/effects/DtmfGen.h
Paul Licameli 67cec5ad83 Make many counts of tracks and channels unsigned...
... And in some places where a library uses signed types, assert that
the reported number is not negative.

What led me to this, is that there are many places where a size_t value for
an allocation is the product of a number of channels and some other number.
2016-09-07 10:11:41 -04:00

105 lines
3.2 KiB
C++

/**********************************************************************
Audacity: A Digital Audio Editor
DtmfGen.h
Salvo Ventura
Dec 2006
An effect that generates DTMF tones
**********************************************************************/
#ifndef __AUDACITY_EFFECT_DTMF__
#define __AUDACITY_EFFECT_DTMF__
#include <wx/event.h>
#include <wx/slider.h>
#include <wx/stattext.h>
#include <wx/string.h>
#include "../widgets/NumericTextCtrl.h"
#include "Effect.h"
class ShuttleGui;
#define DTMFTONES_PLUGIN_SYMBOL XO("DTMF Tones")
class EffectDtmf final : public Effect
{
public:
EffectDtmf();
virtual ~EffectDtmf();
// IdentInterface implementation
wxString GetSymbol() override;
wxString GetDescription() override;
// EffectIdentInterface implementation
EffectType GetType() override;
// EffectClientInterface implementation
unsigned GetAudioOutCount() override;
bool ProcessInitialize(sampleCount totalLen, ChannelNames chanMap = NULL) override;
sampleCount ProcessBlock(float **inBlock, float **outBlock, sampleCount blockLen) override;
bool GetAutomationParameters(EffectAutomationParameters & parms) override;
bool SetAutomationParameters(EffectAutomationParameters & parms) override;
// Effect implementation
bool Startup() override;
bool Init() override;
void PopulateOrExchange(ShuttleGui & S) override;
bool TransferDataFromWindow() override;
bool TransferDataToWindow() override;
private:
// EffectDtmf implementation
bool MakeDtmfTone(float *buffer, sampleCount len, float fs,
wxChar tone, sampleCount last,
sampleCount total, float amplitude);
void Recalculate();
void UpdateUI();
void OnSequence(wxCommandEvent & evt);
void OnAmplitude(wxCommandEvent & evt);
void OnDuration(wxCommandEvent & evt);
void OnDutyCycle(wxCommandEvent & evt);
private:
sampleCount numSamplesSequence; // total number of samples to generate
sampleCount numSamplesTone; // number of samples in a tone block
sampleCount numSamplesSilence; // number of samples in a silence block
sampleCount diff; // number of extra samples to redistribute
sampleCount numRemaining; // number of samples left to produce in the current block
sampleCount curTonePos; // position in tone to start the wave
bool isTone; // true if block is tone, otherwise silence
int curSeqPos; // index into dtmf tone string
wxString dtmfSequence; // dtmf tone string
int dtmfNTones; // total number of tones to generate
double dtmfTone; // duration of a single tone in ms
double dtmfSilence; // duration of silence between tones in ms
double dtmfDutyCycle; // ratio of dtmfTone/(dtmfTone+dtmfSilence)
double dtmfAmplitude; // amplitude of dtmf tone sequence, restricted to (0-1)
wxTextCtrl *mDtmfSequenceT;
wxTextCtrl *mDtmfAmplitudeT;
wxSlider *mDtmfDutyCycleS;
NumericTextCtrl *mDtmfDurationT;
wxStaticText *mDtmfToneT;
wxStaticText *mDtmfSilenceT;
wxStaticText *mDtmfDutyT;
DECLARE_EVENT_TABLE();
};
#endif