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

#include <DtmfGen.h>

Public Member Functions

void Recalculate (EffectSettings &settings)
 

Public Attributes

wxString dtmfSequence {DefaultSequence}
 
size_t dtmfNTones = dtmfSequence.length()
 
double dtmfTone {}
 
double dtmfSilence {}
 
double dtmfDutyCycle {DefaultDutyCycle}
 
double dtmfAmplitude {DefaultAmplitude}
 

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 26 of file DtmfGen.h.

Member Function Documentation

◆ Recalculate()

void DtmfSettings::Recalculate ( EffectSettings settings)

Definition at line 470 of file DtmfGen.cpp.

471{
472 auto &extra = settings.extra;
473 // remember that dtmfDutyCycle is in range (0.0-100.0)
474
475 dtmfNTones = dtmfSequence.length();
476
477 if (dtmfNTones==0) {
478 // no tones, all zero: don't do anything
479 // this should take care of the case where user got an empty
480 // dtmf sequence into the generator: track won't be generated
481 extra.SetDuration(0.0);
482 dtmfTone = 0;
483 dtmfSilence = 0;
484 } else {
485 if (dtmfNTones==1) {
486 // single tone, as long as the sequence
487 dtmfTone = extra.GetDuration();
488 dtmfSilence = 0;
489 } else {
490 // Don't be fooled by the fact that you divide the sequence into dtmfNTones:
491 // the last slot will only contain a tone, not ending with silence.
492 // Given this, the right thing to do is to divide the sequence duration
493 // by dtmfNTones tones and (dtmfNTones-1) silences each sized according to the duty
494 // cycle: original division was:
495 // slot=mDuration / (dtmfNTones*(dtmfDutyCycle/DutyCycle.max)+(dtmfNTones-1)*(1.0-dtmfDutyCycle/DutyCycle.max))
496 // which can be simplified in the one below.
497 // Then just take the part that belongs to tone or silence.
498 //
499 double slot = extra.GetDuration()
500 / ((double)dtmfNTones + (dtmfDutyCycle / 100.0) - 1);
501 dtmfTone = slot * (dtmfDutyCycle / 100.0); // seconds
502 dtmfSilence = slot * (1.0 - (dtmfDutyCycle / 100.0)); // seconds
503
504 // Note that in the extremes we have:
505 // - dutyCycle=100%, this means no silence, so each tone will measure mDuration/dtmfNTones
506 // - dutyCycle=0%, this means no tones, so each silence slot will measure mDuration/(NTones-1)
507 // But we always count:
508 // - dtmfNTones tones
509 // - dtmfNTones-1 silences
510 }
511 }
512
513 // `this` is the settings copy in the validator
514 // Update the EffectSettings held by the dialog
516}
static Settings & settings()
Definition: TrackInfo.cpp:69
static DtmfSettings & GetSettings(EffectSettings &settings)
Assume settings originated from MakeSettings() and copies thereof.
Definition: Effect.h:166
double dtmfSilence
Definition: DtmfGen.h:34
wxString dtmfSequence
Definition: DtmfGen.h:31
size_t dtmfNTones
Definition: DtmfGen.h:32
double dtmfTone
Definition: DtmfGen.h:33
double dtmfDutyCycle
Definition: DtmfGen.h:35

References EffectWithSettings< DtmfSettings, StatelessPerTrackEffect >::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 29 of file DtmfGen.h.

◆ DefaultDutyCycle

constexpr double DtmfSettings::DefaultDutyCycle = 55.0
staticconstexpr

Definition at line 28 of file DtmfGen.h.

◆ DefaultSequence

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

Definition at line 27 of file DtmfGen.h.

◆ dtmfAmplitude

double DtmfSettings::dtmfAmplitude {DefaultAmplitude}

Definition at line 36 of file DtmfGen.h.

◆ dtmfDutyCycle

double DtmfSettings::dtmfDutyCycle {DefaultDutyCycle}

Definition at line 35 of file DtmfGen.h.

◆ dtmfNTones

size_t DtmfSettings::dtmfNTones = dtmfSequence.length()

Definition at line 32 of file DtmfGen.h.

◆ dtmfSequence

wxString DtmfSettings::dtmfSequence {DefaultSequence}

Definition at line 31 of file DtmfGen.h.

◆ dtmfSilence

double DtmfSettings::dtmfSilence {}

Definition at line 34 of file DtmfGen.h.

◆ dtmfTone

double DtmfSettings::dtmfTone {}

Definition at line 33 of file DtmfGen.h.


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