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 471 of file DtmfGen.cpp.

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