Audacity 3.2.0
Public Member Functions | Public Attributes | Static Public Attributes | List of all members
DtmfSettings Struct Reference

#include <DtmfBase.h>

Public Member Functions

void Recalculate (EffectSettings &settings)
 

Public Attributes

wxString dtmfSequence { DefaultSequence }
 
size_t dtmfNTones
 
double dtmfTone {}
 
double dtmfSilence {}
 
double dtmfDutyCycle
 
double dtmfAmplitude
 

Static Public Attributes

static constexpr wchar_t DefaultSequence [] = L"audacity"
 
static constexpr double DefaultDutyCycle = 55.0
 
static constexpr double DefaultAmplitude = 0.8
 

Detailed Description

Definition at line 7 of file DtmfBase.h.

Member Function Documentation

◆ Recalculate()

void DtmfSettings::Recalculate ( EffectSettings settings)

Definition at line 227 of file DtmfBase.cpp.

228{
229 auto& extra = settings.extra;
230 // remember that dtmfDutyCycle is in range (0.0-100.0)
231
232 dtmfNTones = dtmfSequence.length();
233
234 if (dtmfNTones == 0)
235 {
236 // no tones, all zero: don't do anything
237 // this should take care of the case where user got an empty
238 // dtmf sequence into the generator: track won't be generated
239 extra.SetDuration(0.0);
240 dtmfTone = 0;
241 dtmfSilence = 0;
242 }
243 else
244 {
245 if (dtmfNTones == 1)
246 {
247 // single tone, as long as the sequence
248 dtmfTone = extra.GetDuration();
249 dtmfSilence = 0;
250 }
251 else
252 {
253 // Don't be fooled by the fact that you divide the sequence into
254 // dtmfNTones: the last slot will only contain a tone, not ending with
255 // silence. Given this, the right thing to do is to divide the sequence
256 // duration by dtmfNTones tones and (dtmfNTones-1) silences each sized
257 // according to the duty cycle: original division was: slot=mDuration /
258 // (dtmfNTones*(dtmfDutyCycle/DutyCycle.max)+(dtmfNTones-1)*(1.0-dtmfDutyCycle/DutyCycle.max))
259 // which can be simplified in the one below.
260 // Then just take the part that belongs to tone or silence.
261 //
262 double slot = extra.GetDuration() /
263 ((double)dtmfNTones + (dtmfDutyCycle / 100.0) - 1);
264 dtmfTone = slot * (dtmfDutyCycle / 100.0); // seconds
265 dtmfSilence = slot * (1.0 - (dtmfDutyCycle / 100.0)); // seconds
266
267 // Note that in the extremes we have:
268 // - dutyCycle=100%, this means no silence, so each tone will measure
269 // mDuration/dtmfNTones
270 // - dutyCycle=0%, this means no tones, so each silence slot will
271 // measure mDuration/(NTones-1) But we always count:
272 // - dtmfNTones tones
273 // - dtmfNTones-1 silences
274 }
275 }
276
277 // `this` is the settings copy in the validator
278 // Update the EffectSettings held by the dialog
280}
static Settings & settings()
Definition: TrackInfo.cpp:51
static DtmfSettings & GetSettings(EffectSettings &settings)
Assume settings originated from MakeSettings() and copies thereof.
Definition: Effect.h:166
double dtmfSilence
Definition: DtmfBase.h:17
wxString dtmfSequence
Definition: DtmfBase.h:13
size_t dtmfNTones
Definition: DtmfBase.h:14
double dtmfTone
Definition: DtmfBase.h:16
double dtmfDutyCycle
Definition: DtmfBase.h:18

References EffectWithSettings< DtmfSettings, PerTrackEffect >::GetSettings(), and settings().

Here is the call graph for this function:

Member Data Documentation

◆ DefaultAmplitude

constexpr double DtmfSettings::DefaultAmplitude = 0.8
staticconstexpr

Definition at line 11 of file DtmfBase.h.

◆ DefaultDutyCycle

constexpr double DtmfSettings::DefaultDutyCycle = 55.0
staticconstexpr

Definition at line 10 of file DtmfBase.h.

◆ DefaultSequence

constexpr wchar_t DtmfSettings::DefaultSequence[] = L"audacity"
staticconstexpr

Definition at line 9 of file DtmfBase.h.

◆ dtmfAmplitude

double DtmfSettings::dtmfAmplitude
Initial value:
{
}
static constexpr double DefaultAmplitude
Definition: DtmfBase.h:11

Definition at line 21 of file DtmfBase.h.

◆ dtmfDutyCycle

double DtmfSettings::dtmfDutyCycle
Initial value:
{
}
static constexpr double DefaultDutyCycle
Definition: DtmfBase.h:10

Definition at line 18 of file DtmfBase.h.

◆ dtmfNTones

size_t DtmfSettings::dtmfNTones
Initial value:
=
dtmfSequence.length()

Definition at line 14 of file DtmfBase.h.

◆ dtmfSequence

wxString DtmfSettings::dtmfSequence { DefaultSequence }

Definition at line 13 of file DtmfBase.h.

◆ dtmfSilence

double DtmfSettings::dtmfSilence {}

Definition at line 17 of file DtmfBase.h.

◆ dtmfTone

double DtmfSettings::dtmfTone {}

Definition at line 16 of file DtmfBase.h.


The documentation for this struct was generated from the following files: