Audacity  3.2.0
Public Member Functions | Private Member Functions | Private Attributes | List of all members
EffectToneGen Class Reference

An Effect that can generate a sine, square or sawtooth wave. An extended mode of EffectToneGen supports 'chirps' where the frequency changes smoothly during the tone. More...

#include <ToneGen.h>

Inheritance diagram for EffectToneGen:
[legend]
Collaboration diagram for EffectToneGen:
[legend]

Public Member Functions

 EffectToneGen (bool isChirp)
 
virtual ~EffectToneGen ()
 
ComponentInterfaceSymbol GetSymbol () override
 
TranslatableString GetDescription () override
 
ManualPageID ManualPage () override
 Name of a page in the Audacity alpha manual, default is empty. More...
 
EffectType GetType () override
 Type determines how it behaves. More...
 
bool GetAutomationParameters (CommandParameters &parms) override
 Save current settings into parms. More...
 
bool SetAutomationParameters (CommandParameters &parms) override
 Change settings to those stored in parms. More...
 
unsigned GetAudioOutCount () override
 
bool ProcessInitialize (sampleCount totalLen, ChannelNames chanMap=NULL) override
 Called for destructive, non-realtime effect computation. More...
 
size_t ProcessBlock (float **inBlock, float **outBlock, size_t blockLen) override
 Called for destructive, non-realtime effect computation. More...
 
bool DefineParams (ShuttleParams &S) override
 
void PopulateOrExchange (ShuttleGui &S) override
 
bool TransferDataFromWindow () override
 
bool TransferDataToWindow () override
 
- Public Member Functions inherited from Effect
 Effect ()
 
virtual ~Effect ()
 
PluginPath GetPath () override
 
VendorSymbol GetVendor () override
 
wxString GetVersion () override
 
EffectFamilySymbol GetFamily () override
 Report identifier and user-visible name of the effect protocol. More...
 
bool IsInteractive () override
 Whether the effect needs a dialog for entry of settings. More...
 
bool IsDefault () override
 Whether the effect sorts "above the line" in the menus. More...
 
bool IsLegacy () override
 
bool SupportsRealtime () override
 Whether the effect supports realtime previewing (while audio is playing). More...
 
bool SupportsAutomation () override
 Whether the effect can be used without the UI, in a macro. More...
 
bool LoadUserPreset (const RegistryPath &name) override
 Change settings to a user-named preset. More...
 
bool SaveUserPreset (const RegistryPath &name) override
 Save current settings as a user-named preset. More...
 
RegistryPaths GetFactoryPresets () override
 Report names of factory presets. More...
 
bool LoadFactoryPreset (int id) override
 Change settings to the preset whose name is GetFactoryPresets()[id] More...
 
bool LoadFactoryDefaults () override
 Change settings back to "factory default". More...
 
bool SetHost (EffectHostInterface *host) override
 
unsigned GetAudioInCount () override
 
int GetMidiInCount () override
 
int GetMidiOutCount () override
 
sampleCount GetLatency () override
 Called for destructive, non-realtime effect computation. More...
 
size_t GetTailSize () override
 
void SetSampleRate (double rate) override
 
size_t SetBlockSize (size_t maxBlockSize) override
 
size_t GetBlockSize () const override
 
bool ProcessFinalize () override
 Called for destructive, non-realtime effect computation. More...
 
bool RealtimeInitialize () override
 
bool RealtimeAddProcessor (unsigned numChannels, float sampleRate) override
 
bool RealtimeFinalize () override
 
bool RealtimeSuspend () override
 
bool RealtimeResume () noexcept override
 
bool RealtimeProcessStart () override
 
size_t RealtimeProcess (int group, float **inbuf, float **outbuf, size_t numSamples) override
 
bool RealtimeProcessEnd () noexcept override
 
int ShowClientInterface (wxWindow &parent, wxDialog &dialog, bool forceModal=false) override
 
bool PopulateUI (ShuttleGui &S) final
 Adds controls to a panel that is given as the parent window of S More...
 
bool IsGraphicalUI () override
 
bool ValidateUI () override
 
bool HideUI () override
 
bool CloseUI () override
 
bool CanExportPresets () override
 
void ExportPresets () override
 
void ImportPresets () override
 
bool HasOptions () override
 
void ShowOptions () override
 
EffectDefinitionInterfaceGetDefinition () override
 
double GetDuration () override
 
NumericFormatSymbol GetDurationFormat () override
 
virtual NumericFormatSymbol GetSelectionFormat ()
 
void SetDuration (double duration) override
 
RegistryPath GetUserPresetsGroup (const RegistryPath &name) override
 
RegistryPath GetCurrentSettingsGroup () override
 
RegistryPath GetFactoryDefaultsGroup () override
 
virtual wxString GetSavedStateGroup ()
 
int ShowHostInterface (wxWindow &parent, const EffectDialogFactory &factory, bool forceModal=false) override
 
unsigned TestUIFlags (unsigned mask)
 
void SetPresetParameters (const wxArrayString *Names, const wxArrayString *Values)
 
virtual bool Startup (EffectUIClientInterface *client)
 
virtual bool GetAutomationParametersAsString (wxString &parms)
 
virtual bool SetAutomationParametersFromString (const wxString &parms)
 
virtual bool IsBatchProcessing ()
 
virtual void SetBatchProcessing (bool start)
 
bool DoEffect (double projectRate, TrackList *list, WaveTrackFactory *factory, NotifyingSelectedRegion &selectedRegion, unsigned flags, wxWindow *pParent=nullptr, const EffectDialogFactory &dialogFactory={})
 
bool Delegate (Effect &delegate, wxWindow &parent, const EffectDialogFactory &factory)
 
int MessageBox (const TranslatableString &message, long style=DefaultMessageBoxStyle, const TranslatableString &titleStr={})
 
virtual bool Startup ()
 
- Public Member Functions inherited from EffectUIClientInterface
virtual ~EffectUIClientInterface ()
 
- Public Member Functions inherited from EffectProcessor
virtual ~EffectProcessor ()
 
- Public Member Functions inherited from EffectDefinitionInterface
virtual ~EffectDefinitionInterface ()
 
virtual EffectType GetClassification ()
 Determines which menu it appears in; default same as GetType(). More...
 
virtual bool EnablesDebug ()
 Whether the effect dialog should have a Debug button; default, always false. More...
 
virtual FilePath HelpPage ()
 Fully qualified local help file name, default is empty. More...
 
virtual bool IsHiddenFromMenus ()
 Default is false. More...
 
- Public Member Functions inherited from ComponentInterface
virtual ~ComponentInterface ()
 
TranslatableString GetName ()
 
virtual bool DefineParams (ShuttleParams &WXUNUSED(S))
 
- Public Member Functions inherited from EffectUIHostInterface
virtual ~EffectUIHostInterface ()
 
- Public Member Functions inherited from EffectHostInterface
virtual ~EffectHostInterface ()
 

Private Member Functions

void OnControlUpdate (wxCommandEvent &evt)
 

Private Attributes

bool mChirp
 
sampleCount mSample
 
double mPositionInCycles
 
int mWaveform
 
int mInterpolation
 
double mFrequency [2]
 
double mAmplitude [2]
 
double mLogFrequency [2]
 
NumericTextCtrlmToneDurationT
 

Additional Inherited Members

- Public Types inherited from Effect
enum  : long { DefaultMessageBoxStyle = wxOK | wxCENTRE }
 
- Static Public Member Functions inherited from Effect
static void IncEffectCounter ()
 
- Static Public Member Functions inherited from EffectDefinitionInterface
static Identifier GetSquashedName (const Identifier &ident)
 A utility that strips spaces and CamelCases a name. More...
 
- Static Public Attributes inherited from Effect
static const wxString kUserPresetIdent = wxT("User Preset:")
 
static const wxString kFactoryPresetIdent = wxT("Factory Preset:")
 
static const wxString kCurrentSettingsIdent = wxT("<Current Settings>")
 
static const wxString kFactoryDefaultsIdent = wxT("<Factory Defaults>")
 
- Protected Member Functions inherited from Effect
bool EnableApply (bool enable=true)
 
bool EnablePreview (bool enable=true)
 
virtual bool Init ()
 
virtual bool CheckWhetherSkipEffect ()
 
virtual bool Process ()
 
virtual bool ProcessPass ()
 
virtual bool InitPass1 ()
 
virtual bool InitPass2 ()
 
virtual void End ()
 
virtual double CalcPreviewInputLength (double previewLength)
 
virtual void Preview (bool dryOnly)
 
bool TotalProgress (double frac, const TranslatableString &={})
 
bool TrackProgress (int whichTrack, double frac, const TranslatableString &={})
 
bool TrackGroupProgress (int whichGroup, double frac, const TranslatableString &={})
 
int GetNumWaveTracks ()
 
int GetNumWaveGroups ()
 
void GetBounds (const WaveTrack &track, const WaveTrack *pRight, sampleCount *start, sampleCount *len)
 
void SetLinearEffectFlag (bool linearEffectFlag)
 
void SetPreviewFullSelectionFlag (bool previewDurationFlag)
 
bool IsPreviewing ()
 
void IncludeNotSelectedPreviewTracks (bool includeNotSelected)
 
void CopyInputTracks (bool allSyncLockSelected=false)
 
std::shared_ptr< AddedAnalysisTrackAddAnalysisTrack (const wxString &name=wxString())
 
ModifiedAnalysisTrack ModifyAnalysisTrack (const LabelTrack *pOrigTrack, const wxString &name=wxString())
 
void ReplaceProcessedTracks (const bool bGoodResult)
 
TrackAddToOutputTracks (const std::shared_ptr< Track > &t)
 
const TrackListinputTracks () const
 
const AudacityProjectFindProject () const
 
- Protected Attributes inherited from Effect
BasicUI::ProgressDialogmProgress = nullptr
 
double mProjectRate
 
double mSampleRate
 
WaveTrackFactorymFactory
 
std::shared_ptr< TrackListmOutputTracks
 
double mT0
 
double mT1
 
wxArrayString mPresetNames
 
wxArrayString mPresetValues
 
int mPass
 
wxWeakRef< wxDialog > mHostUIDialog
 This smart pointer tracks the lifetime of the dialog. More...
 
wxWeakRef< wxDialog > mUIDialog
 This weak pointer may be the same as the above, or null. More...
 
wxWindow * mUIParent
 
unsigned mUIFlags { 0 }
 
sampleCount mSampleCnt
 
- Static Protected Attributes inherited from Effect
static int nEffectsDone =0
 

Detailed Description

An Effect that can generate a sine, square or sawtooth wave. An extended mode of EffectToneGen supports 'chirps' where the frequency changes smoothly during the tone.

Definition at line 21 of file ToneGen.h.

Constructor & Destructor Documentation

◆ EffectToneGen()

EffectToneGen::EffectToneGen ( bool  isChirp)

Definition at line 102 of file ToneGen.cpp.

103 {
104  wxASSERT(nWaveforms == WXSIZEOF(kWaveStrings));
105  wxASSERT(nInterpolations == WXSIZEOF(kInterStrings));
106 
107  mChirp = isChirp;
108 
109  mWaveform = DEF_Waveform;
110  mFrequency[0] = DEF_StartFreq;
111  mFrequency[1] = DEF_EndFreq;
112  mAmplitude[0] = DEF_StartAmp;
113  mAmplitude[1] = DEF_EndAmp;
114  mInterpolation = DEF_Interp;
115 
116  // Chirp varies over time so must use selected duration.
117  // TODO: When previewing, calculate only the first 'preview length'.
118  if (isChirp)
119  SetLinearEffectFlag(false);
120  else
121  SetLinearEffectFlag(true);
122 }

References kInterStrings, kWaveStrings, nInterpolations, and nWaveforms.

◆ ~EffectToneGen()

EffectToneGen::~EffectToneGen ( )
virtual

Definition at line 124 of file ToneGen.cpp.

125 {
126 }

Member Function Documentation

◆ DefineParams()

bool EffectToneGen::DefineParams ( ShuttleParams S)
override

Definition at line 274 of file ToneGen.cpp.

274  {
275  if( mChirp ){
276  S.SHUTTLE_PARAM( mFrequency[0], StartFreq );
277  S.SHUTTLE_PARAM( mFrequency[1], EndFreq );
278  S.SHUTTLE_PARAM( mAmplitude[0], StartAmp );
279  S.SHUTTLE_PARAM( mAmplitude[1], EndAmp );
280  } else {
281  S.SHUTTLE_PARAM( mFrequency[0], Frequency );
282  S.SHUTTLE_PARAM( mAmplitude[0], Amplitude );
283  // Slightly hacky way to set freq and ampl
284  // since we do this whatever query to params was made.
285  mFrequency[1] = mFrequency[0];
286  mAmplitude[1] = mAmplitude[0];
287  }
288  S.SHUTTLE_ENUM_PARAM( mWaveform, Waveform, kWaveStrings, nWaveforms );
289  S.SHUTTLE_ENUM_PARAM( mInterpolation, Interp, kInterStrings, nInterpolations );
290 
291 
292 // double freqMax = (FindProject() ? FindProject()->GetRate() : 44100.0) / 2.0;
293 // mFrequency[1] = TrapDouble(mFrequency[1], MIN_EndFreq, freqMax);
294 
295 
296  return true;
297 }

References kInterStrings, kWaveStrings, mAmplitude, mChirp, mFrequency, mInterpolation, mWaveform, nInterpolations, nWaveforms, S, and WaveTrackViewConstants::Waveform.

◆ GetAudioOutCount()

unsigned EffectToneGen::GetAudioOutCount ( )
overridevirtual

Reimplemented from Effect.

Definition at line 160 of file ToneGen.cpp.

161 {
162  return 1;
163 }

◆ GetAutomationParameters()

bool EffectToneGen::GetAutomationParameters ( CommandParameters parms)
overridevirtual

Save current settings into parms.

Reimplemented from Effect.

Definition at line 299 of file ToneGen.cpp.

300 {
301  if (mChirp)
302  {
303  parms.Write(KEY_StartFreq, mFrequency[0]);
304  parms.Write(KEY_EndFreq, mFrequency[1]);
305  parms.Write(KEY_StartAmp, mAmplitude[0]);
306  parms.Write(KEY_EndAmp, mAmplitude[1]);
307  }
308  else
309  {
310  parms.Write(KEY_Frequency, mFrequency[0]);
311  parms.Write(KEY_Amplitude, mAmplitude[0]);
312  }
313 
314  parms.Write(KEY_Waveform, kWaveStrings[mWaveform].Internal());
315  parms.Write(KEY_Interp, kInterStrings[mInterpolation].Internal());
316 
317  return true;
318 }

References Internal, kInterStrings, kWaveStrings, mAmplitude, mChirp, mFrequency, mInterpolation, and mWaveform.

◆ GetDescription()

TranslatableString EffectToneGen::GetDescription ( )
overridevirtual

Reimplemented from Effect.

Definition at line 137 of file ToneGen.cpp.

138 {
139  return mChirp
140  ? XO("Generates an ascending or descending tone of one of four types")
141  : XO("Generates a constant frequency tone of one of four types");
142 }

References mChirp, and XO.

◆ GetSymbol()

ComponentInterfaceSymbol EffectToneGen::GetSymbol ( )
overridevirtual

Reimplemented from Effect.

Definition at line 130 of file ToneGen.cpp.

131 {
132  return mChirp
135 }

References mChirp, EffectChirp::Symbol, and EffectTone::Symbol.

◆ GetType()

EffectType EffectToneGen::GetType ( )
overridevirtual

Type determines how it behaves.

Reimplemented from Effect.

Definition at line 153 of file ToneGen.cpp.

154 {
155  return EffectTypeGenerate;
156 }

References EffectTypeGenerate.

◆ ManualPage()

ManualPageID EffectToneGen::ManualPage ( )
overridevirtual

Name of a page in the Audacity alpha manual, default is empty.

Reimplemented from EffectDefinitionInterface.

Definition at line 144 of file ToneGen.cpp.

145 {
146  return mChirp
147  ? L"Chirp"
148  : L"Tone";
149 }

References mChirp.

◆ OnControlUpdate()

void EffectToneGen::OnControlUpdate ( wxCommandEvent &  evt)
private

Definition at line 517 of file ToneGen.cpp.

518 {
519  if (!EnableApply(mUIParent->TransferDataFromWindow()))
520  {
521  return;
522  }
523 }

References Effect::EnableApply(), and Effect::mUIParent.

Here is the call graph for this function:

◆ PopulateOrExchange()

void EffectToneGen::PopulateOrExchange ( ShuttleGui S)
overridevirtual

Reimplemented from Effect.

Definition at line 360 of file ToneGen.cpp.

361 {
362  wxTextCtrl *t;
363 
364  S.StartMultiColumn(2, wxCENTER);
365  {
366  S.Validator<wxGenericValidator>(&mWaveform)
367  .AddChoice(XXO("&Waveform:"),
369 
370  if (mChirp)
371  {
372  S.AddFixedText( {} );
373  S.StartHorizontalLay(wxEXPAND);
374  {
375  S.StartHorizontalLay(wxLEFT, 50);
376  {
377  S.AddTitle(XO("Start"));
378  }
379  S.EndHorizontalLay();
380 
381  S.StartHorizontalLay(wxLEFT, 50);
382  {
383  S.AddTitle(XO("End"));
384  }
385  S.EndHorizontalLay();
386  }
387  S.EndHorizontalLay();
388 
389  S.AddPrompt(XXO("&Frequency (Hz):"));
390  S.StartHorizontalLay(wxEXPAND);
391  {
392  S.StartHorizontalLay(wxLEFT, 50);
393  {
394  t = S.Name(XO("Frequency Hertz Start"))
395  .Validator<FloatingPointValidator<double>>(
396  6, &mFrequency[0],
397  NumValidatorStyle::NO_TRAILING_ZEROES,
398  MIN_StartFreq,
399  mProjectRate / 2.0
400  )
401  .AddTextBox( {}, wxT(""), 12);
402  }
403  S.EndHorizontalLay();
404 
405  S.StartHorizontalLay(wxLEFT, 50);
406  {
407  t = S.Name(XO("Frequency Hertz End"))
408  .Validator<FloatingPointValidator<double>>(
409  6, &mFrequency[1],
410  NumValidatorStyle::NO_TRAILING_ZEROES,
411  MIN_EndFreq,
412  mProjectRate / 2.0
413  )
414  .AddTextBox( {}, wxT(""), 12);
415  }
416  S.EndHorizontalLay();
417  }
418  S.EndHorizontalLay();
419 
420  S.AddPrompt(XXO("&Amplitude (0-1):"));
421  S.StartHorizontalLay(wxEXPAND);
422  {
423  S.StartHorizontalLay(wxLEFT, 50);
424  {
425  t = S.Name(XO("Amplitude Start"))
426  .Validator<FloatingPointValidator<double>>(
427  6, &mAmplitude[0], NumValidatorStyle::NO_TRAILING_ZEROES,
428  MIN_StartAmp, MAX_StartAmp
429  )
430  .AddTextBox( {}, wxT(""), 12);
431  }
432  S.EndHorizontalLay();
433 
434  S.StartHorizontalLay(wxLEFT, 50);
435  {
436  t = S.Name(XO("Amplitude End"))
437  .Validator<FloatingPointValidator<double>>(
438  6, &mAmplitude[1], NumValidatorStyle::NO_TRAILING_ZEROES,
439  MIN_EndAmp, MAX_EndAmp
440  )
441  .AddTextBox( {}, wxT(""), 12);
442  }
443  S.EndHorizontalLay();
444  }
445  S.EndHorizontalLay();
446 
447  S.Validator<wxGenericValidator>(&mInterpolation)
448  .AddChoice(XXO("I&nterpolation:"),
450  }
451  else
452  {
453  t = S.Validator<FloatingPointValidator<double>>(
454  6, &mFrequency[0], NumValidatorStyle::NO_TRAILING_ZEROES,
455  MIN_Frequency,
456  mProjectRate / 2.0
457  )
458  .AddTextBox(XXO("&Frequency (Hz):"), wxT(""), 12);
459 
460  t = S.Validator<FloatingPointValidator<double>>(
461  6, &mAmplitude[0], NumValidatorStyle::NO_TRAILING_ZEROES,
462  MIN_Amplitude, MAX_Amplitude
463  )
464  .AddTextBox(XXO("&Amplitude (0-1):"), wxT(""), 12);
465  }
466 
467  S.AddPrompt(XXO("&Duration:"));
469  NumericTextCtrl(S.GetParent(), wxID_ANY,
472  GetDuration(),
473  mProjectRate,
475  .AutoPos(true));
476  S.Name(XO("Duration"))
477  .Position(wxALIGN_LEFT | wxALL)
478  .AddWindow(mToneDurationT);
479  }
480  S.EndMultiColumn();
481 
482  return;
483 }

References NumericTextCtrl::Options::AutoPos(), Effect::GetDuration(), Effect::GetDurationFormat(), kInterStrings, kWaveStrings, mAmplitude, mChirp, mFrequency, mInterpolation, Effect::mProjectRate, Msgids(), mToneDurationT, mWaveform, nInterpolations, nWaveforms, S, safenew, NumericConverter::TIME, XO, and XXO.

Here is the call graph for this function:

◆ ProcessBlock()

size_t EffectToneGen::ProcessBlock ( float **  inBlock,
float **  outBlock,
size_t  blockLen 
)
overridevirtual

Called for destructive, non-realtime effect computation.

Reimplemented from Effect.

Definition at line 173 of file ToneGen.cpp.

174 {
175  float *buffer = outBlock[0];
176  double throwaway = 0; //passed to modf but never used
177  double f = 0.0;
178  double a, b;
179  int k;
180 
181  double frequencyQuantum;
182  double BlendedFrequency;
183  double BlendedAmplitude;
184  double BlendedLogFrequency = 0.0;
185 
186  // calculate delta, and reposition from where we left
187  auto doubleSampleCount = mSampleCnt.as_double();
188  auto doubleSample = mSample.as_double();
189  double amplitudeQuantum =
190  (mAmplitude[1] - mAmplitude[0]) / doubleSampleCount;
191  BlendedAmplitude = mAmplitude[0] +
192  amplitudeQuantum * doubleSample;
193 
194  // precalculations:
195  double pre2PI = 2.0 * M_PI;
196  double pre4divPI = 4.0 / M_PI;
197 
198  // initial setup should calculate deltas
200  {
201  // this for log interpolation
202  mLogFrequency[0] = log10(mFrequency[0]);
203  mLogFrequency[1] = log10(mFrequency[1]);
204  // calculate delta, and reposition from where we left
205  frequencyQuantum = (mLogFrequency[1] - mLogFrequency[0]) / doubleSampleCount;
206  BlendedLogFrequency = mLogFrequency[0] + frequencyQuantum * doubleSample;
207  BlendedFrequency = pow(10.0, BlendedLogFrequency);
208  }
209  else
210  {
211  // this for regular case, linear interpolation
212  frequencyQuantum = (mFrequency[1] - mFrequency[0]) / doubleSampleCount;
213  BlendedFrequency = mFrequency[0] + frequencyQuantum * doubleSample;
214  }
215 
216  // synth loop
217  for (decltype(blockLen) i = 0; i < blockLen; i++)
218  {
219  switch (mWaveform)
220  {
221  case kSine:
222  f = sin(pre2PI * mPositionInCycles / mSampleRate);
223  break;
224  case kSquare:
225  f = (modf(mPositionInCycles / mSampleRate, &throwaway) < 0.5) ? 1.0 : -1.0;
226  break;
227  case kSawtooth:
228  f = (2.0 * modf(mPositionInCycles / mSampleRate + 0.5, &throwaway)) - 1.0;
229  break;
230  case kTriangle:
231  f = modf(mPositionInCycles / mSampleRate, &throwaway);
232  if(f < 0.25) {
233  f *= 4.0;
234  } else if(f > 0.75) {
235  f = (f - 1.0) * 4.0;
236  } else { /* f >= 0.25 || f <= 0.75 */
237  f = (0.5 - f) * 4.0;
238  }
239  break;
240  case kSquareNoAlias: // Good down to 110Hz @ 44100Hz sampling.
241  //do fundamental (k=1) outside loop
242  b = (1.0 + cos((pre2PI * BlendedFrequency) / mSampleRate)) / pre4divPI; //scaling
243  f = pre4divPI * sin(pre2PI * mPositionInCycles / mSampleRate);
244  for (k = 3; (k < 200) && (k * BlendedFrequency < mSampleRate / 2.0); k += 2)
245  {
246  //Hann Window in freq domain
247  a = 1.0 + cos((pre2PI * k * BlendedFrequency) / mSampleRate);
248  //calc harmonic, apply window, scale to amplitude of fundamental
249  f += a * sin(pre2PI * mPositionInCycles / mSampleRate * k) / (b * k);
250  }
251  }
252  // insert value in buffer
253  buffer[i] = (float) (BlendedAmplitude * f);
254  // update freq,amplitude
255  mPositionInCycles += BlendedFrequency;
256  BlendedAmplitude += amplitudeQuantum;
258  {
259  BlendedLogFrequency += frequencyQuantum;
260  BlendedFrequency = pow(10.0, BlendedLogFrequency);
261  }
262  else
263  {
264  BlendedFrequency += frequencyQuantum;
265  }
266  }
267 
268  // update external placeholder
269  mSample += blockLen;
270 
271  return blockLen;
272 }

References sampleCount::as_double(), kLogarithmic, kSawtooth, kSine, kSquare, kSquareNoAlias, kTriangle, M_PI, mAmplitude, mFrequency, mInterpolation, mLogFrequency, mPositionInCycles, mSample, Effect::mSampleCnt, Effect::mSampleRate, and mWaveform.

Here is the call graph for this function:

◆ ProcessInitialize()

bool EffectToneGen::ProcessInitialize ( sampleCount  totalLen,
ChannelNames  chanMap = NULL 
)
overridevirtual

Called for destructive, non-realtime effect computation.

Reimplemented from Effect.

Definition at line 165 of file ToneGen.cpp.

166 {
167  mPositionInCycles = 0.0;
168  mSample = 0;
169 
170  return true;
171 }

References mPositionInCycles, and mSample.

◆ SetAutomationParameters()

bool EffectToneGen::SetAutomationParameters ( CommandParameters parms)
overridevirtual

Change settings to those stored in parms.

Reimplemented from Effect.

Definition at line 320 of file ToneGen.cpp.

321 {
324  if (mChirp)
325  {
326  ReadAndVerifyDouble(StartFreq);
327  ReadAndVerifyDouble(EndFreq);
328  ReadAndVerifyDouble(StartAmp);
329  ReadAndVerifyDouble(EndAmp);
330  mFrequency[0] = StartFreq;
331  mFrequency[1] = EndFreq;
332  mAmplitude[0] = StartAmp;
333  mAmplitude[1] = EndAmp;
334  }
335  else
336  {
337  ReadAndVerifyDouble(Frequency);
338  ReadAndVerifyDouble(Amplitude);
339  mFrequency[0] = Frequency;
340  mFrequency[1] = Frequency;
341  mAmplitude[0] = Amplitude;
342  mAmplitude[1] = Amplitude;
343  }
344 
346  mInterpolation = Interp;
347 
348  double freqMax =
349  (FindProject()
351  : 44100.0)
352  / 2.0;
353  mFrequency[1] = TrapDouble(mFrequency[1], MIN_EndFreq, freqMax);
354 
355  return true;
356 }

References Effect::FindProject(), ProjectRate::Get(), ProjectRate::GetRate(), kInterStrings, kWaveStrings, mAmplitude, mChirp, mFrequency, mInterpolation, mWaveform, nInterpolations, nWaveforms, ReadAndVerifyDouble, ReadAndVerifyEnum, TrapDouble(), and WaveTrackViewConstants::Waveform.

Here is the call graph for this function:

◆ TransferDataFromWindow()

bool EffectToneGen::TransferDataFromWindow ( )
overridevirtual

Reimplemented from Effect.

Definition at line 497 of file ToneGen.cpp.

498 {
499  if (!mUIParent->Validate() || !mUIParent->TransferDataFromWindow())
500  {
501  return false;
502  }
503 
504  if (!mChirp)
505  {
506  mFrequency[1] = mFrequency[0];
507  mAmplitude[1] = mAmplitude[0];
508  }
509 
511 
512  return true;
513 }

References NumericConverter::GetValue(), mAmplitude, mChirp, mFrequency, mToneDurationT, Effect::mUIParent, and Effect::SetDuration().

Here is the call graph for this function:

◆ TransferDataToWindow()

bool EffectToneGen::TransferDataToWindow ( )
overridevirtual

Reimplemented from Effect.

Definition at line 485 of file ToneGen.cpp.

486 {
487  if (!mUIParent->TransferDataToWindow())
488  {
489  return false;
490  }
491 
493 
494  return true;
495 }

References Effect::GetDuration(), mToneDurationT, Effect::mUIParent, and NumericTextCtrl::SetValue().

Here is the call graph for this function:

Member Data Documentation

◆ mAmplitude

double EffectToneGen::mAmplitude[2]
private

◆ mChirp

bool EffectToneGen::mChirp
private

◆ mFrequency

double EffectToneGen::mFrequency[2]
private

◆ mInterpolation

int EffectToneGen::mInterpolation
private

◆ mLogFrequency

double EffectToneGen::mLogFrequency[2]
private

Definition at line 71 of file ToneGen.h.

Referenced by ProcessBlock().

◆ mPositionInCycles

double EffectToneGen::mPositionInCycles
private

Definition at line 63 of file ToneGen.h.

Referenced by ProcessBlock(), and ProcessInitialize().

◆ mSample

sampleCount EffectToneGen::mSample
private

Definition at line 62 of file ToneGen.h.

Referenced by ProcessBlock(), and ProcessInitialize().

◆ mToneDurationT

NumericTextCtrl* EffectToneGen::mToneDurationT
private

Definition at line 73 of file ToneGen.h.

Referenced by PopulateOrExchange(), TransferDataFromWindow(), and TransferDataToWindow().

◆ mWaveform

int EffectToneGen::mWaveform
private

The documentation for this class was generated from the following files:
Effect::mSampleCnt
sampleCount mSampleCnt
Definition: Effect.h:441
EffectToneGen::mSample
sampleCount mSample
Definition: ToneGen.h:62
Effect::FindProject
const AudacityProject * FindProject() const
Definition: Effect.cpp:2035
Effect::GetDuration
double GetDuration() override
Definition: Effect.cpp:769
Effect::SetLinearEffectFlag
void SetLinearEffectFlag(bool linearEffectFlag)
Definition: Effect.cpp:1764
Effect::EnableApply
bool EnableApply(bool enable=true)
Definition: Effect.cpp:1694
S
#define S(N)
Definition: ToChars.cpp:64
NumericTextCtrl::Options::AutoPos
Options & AutoPos(bool enable)
Definition: NumericTextCtrl.h:190
kSquareNoAlias
@ kSquareNoAlias
Definition: ToneGen.cpp:58
ProjectRate::Get
static ProjectRate & Get(AudacityProject &project)
Definition: ProjectRate.cpp:28
EffectTypeGenerate
@ EffectTypeGenerate
Definition: EffectInterface.h:55
EffectTone::Symbol
static const ComponentInterfaceSymbol Symbol
Definition: ToneGen.h:90
EffectToneGen::mChirp
bool mChirp
Definition: ToneGen.h:58
Validator
A Validator is an object which checks whether a wxVariant satisfies a certain criterion....
Definition: Validators.h:53
XO
#define XO(s)
Definition: Internat.h:31
EffectToneGen::mToneDurationT
NumericTextCtrl * mToneDurationT
Definition: ToneGen.h:73
NumericTextCtrl
Definition: NumericTextCtrl.h:172
NumericTextCtrl::SetValue
void SetValue(double newValue)
Definition: NumericTextCtrl.cpp:1474
NumericTextCtrl::Options
Definition: NumericTextCtrl.h:178
kSquare
@ kSquare
Definition: ToneGen.cpp:56
Effect::mProjectRate
double mProjectRate
Definition: Effect.h:416
ReadAndVerifyEnum
#define ReadAndVerifyEnum(name, list, listSize)
Definition: Effect.h:580
kInterStrings
static const EnumValueSymbol kInterStrings[nInterpolations]
Definition: ToneGen.cpp:46
EffectToneGen::mWaveform
int mWaveform
Definition: ToneGen.h:67
XXO
#define XXO(s)
Definition: Internat.h:44
EffectToneGen::mLogFrequency
double mLogFrequency[2]
Definition: ToneGen.h:71
sampleCount::as_double
double as_double() const
Definition: SampleCount.h:45
EffectChirp::Symbol
static const ComponentInterfaceSymbol Symbol
Definition: ToneGen.h:81
NumericConverter::TIME
@ TIME
Definition: NumericTextCtrl.h:52
EffectToneGen::mFrequency
double mFrequency[2]
Definition: ToneGen.h:69
ProjectRate::GetRate
double GetRate() const
Definition: ProjectRate.cpp:53
nWaveforms
@ nWaveforms
Definition: ToneGen.cpp:60
Msgids
TranslatableStrings Msgids(const EnumValueSymbol strings[], size_t nStrings)
Convenience function often useful when adding choice controls.
Definition: ShuttleGui.cpp:2523
ReadAndVerifyDouble
#define ReadAndVerifyDouble(name)
Definition: Effect.h:592
EffectToneGen::mInterpolation
int mInterpolation
Definition: ToneGen.h:68
Effect::SetDuration
void SetDuration(double duration) override
Definition: Effect.cpp:791
Effect::mSampleRate
double mSampleRate
Definition: Effect.h:418
EffectToneGen::mPositionInCycles
double mPositionInCycles
Definition: ToneGen.h:63
Effect::mUIParent
wxWindow * mUIParent
Definition: Effect.h:438
kTriangle
@ kTriangle
Definition: ToneGen.cpp:59
ExceptionType::Internal
@ Internal
Indicates internal failure from Audacity.
M_PI
#define M_PI
Definition: Distortion.cpp:29
TrapDouble
double TrapDouble(double x, double min, double max)
Definition: Effect.h:523
Effect::GetDurationFormat
NumericFormatSymbol GetDurationFormat() override
Definition: Effect.cpp:779
safenew
#define safenew
Definition: MemoryX.h:10
EffectToneGen::mAmplitude
double mAmplitude[2]
Definition: ToneGen.h:70
kSine
@ kSine
Definition: ToneGen.cpp:55
NumericConverter::GetValue
double GetValue()
Definition: NumericTextCtrl.cpp:1174
nInterpolations
@ nInterpolations
Definition: ToneGen.cpp:43
kSawtooth
@ kSawtooth
Definition: ToneGen.cpp:57
kLogarithmic
@ kLogarithmic
Definition: ToneGen.cpp:42
WaveTrackViewConstants::Waveform
@ Waveform
Definition: WaveTrackViewConstants.h:24
kWaveStrings
static const EnumValueSymbol kWaveStrings[nWaveforms]
Definition: ToneGen.cpp:63