Audacity  3.2.0
Public Member Functions | Static Public Attributes | Private Member Functions | Private Attributes | List of all members
EffectBassTreble Class Referencefinal

A high shelf and low shelf filter. More...

#include <BassTreble.h>

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

Public Member Functions

 EffectBassTreble ()
 
virtual ~EffectBassTreble ()
 
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 SupportsRealtime () override
 Whether the effect supports realtime previewing (while audio is playing). 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 GetAudioInCount () override
 
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 RealtimeInitialize () override
 
bool RealtimeAddProcessor (unsigned numChannels, float sampleRate) override
 
bool RealtimeFinalize () override
 
size_t RealtimeProcess (int group, float **inbuf, float **outbuf, size_t numSamples) override
 
bool DefineParams (ShuttleParams &S) override
 
void PopulateOrExchange (ShuttleGui &S) override
 
bool TransferDataToWindow () override
 
bool TransferDataFromWindow () override
 
bool CheckWhetherSkipEffect () override
 
- Public Member Functions inherited from Effect
 Effect ()
 
virtual ~Effect ()
 
PluginPath GetPath () override
 
ComponentInterfaceSymbol GetSymbol () override
 
VendorSymbol GetVendor () override
 
wxString GetVersion () override
 
TranslatableString GetDescription () override
 
EffectType GetType () override
 Type determines how it behaves. More...
 
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 GetAutomationParameters (CommandParameters &parms) override
 Save current settings into parms. More...
 
bool SetAutomationParameters (CommandParameters &parms) override
 Change settings to those stored in parms. 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
 
unsigned GetAudioOutCount () 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 ProcessInitialize (sampleCount totalLen, ChannelNames chanMap=NULL) override
 Called for destructive, non-realtime effect computation. More...
 
bool ProcessFinalize () 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 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 ()
 

Static Public Attributes

static const ComponentInterfaceSymbol Symbol { XO("Bass and Treble") }
 
- 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>")
 

Private Member Functions

void InstanceInit (EffectBassTrebleState &data, float sampleRate)
 
size_t InstanceProcess (EffectBassTrebleState &data, float **inBlock, float **outBlock, size_t blockLen)
 
void Coefficients (double hz, double slope, double gain, double samplerate, int type, double &a0, double &a1, double &a2, double &b0, double &b1, double &b2)
 
float DoFilter (EffectBassTrebleState &data, float in)
 
void OnBassText (wxCommandEvent &evt)
 
void OnTrebleText (wxCommandEvent &evt)
 
void OnGainText (wxCommandEvent &evt)
 
void OnBassSlider (wxCommandEvent &evt)
 
void OnTrebleSlider (wxCommandEvent &evt)
 
void OnGainSlider (wxCommandEvent &evt)
 
void OnLinkCheckbox (wxCommandEvent &evt)
 
void UpdateGain (double oldVal, int control)
 

Private Attributes

EffectBassTrebleState mMaster
 
std::vector< EffectBassTrebleStatemSlaves
 
double mBass
 
double mTreble
 
double mGain
 
bool mLink
 
wxSlider * mBassS
 
wxSlider * mTrebleS
 
wxSlider * mGainS
 
wxTextCtrl * mBassT
 
wxTextCtrl * mTrebleT
 
wxTextCtrl * mGainT
 
wxCheckBox * mLinkCheckBox
 

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...
 
- Protected Member Functions inherited from Effect
bool EnableApply (bool enable=true)
 
bool EnablePreview (bool enable=true)
 
virtual bool Init ()
 
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

A high shelf and low shelf filter.

Definition at line 36 of file BassTreble.h.

Constructor & Destructor Documentation

◆ EffectBassTreble()

EffectBassTreble::EffectBassTreble ( )

Definition at line 75 of file BassTreble.cpp.

76 {
77  mBass = DEF_Bass;
78  mTreble = DEF_Treble;
79  mGain = DEF_Gain;
80  mLink = DEF_Link;
81 
82  SetLinearEffectFlag(true);
83 }

◆ ~EffectBassTreble()

EffectBassTreble::~EffectBassTreble ( )
virtual

Definition at line 85 of file BassTreble.cpp.

86 {
87 }

Member Function Documentation

◆ CheckWhetherSkipEffect()

bool EffectBassTreble::CheckWhetherSkipEffect ( )
overridevirtual

Reimplemented from Effect.

Definition at line 210 of file BassTreble.cpp.

211 {
212  return (mBass == 0.0 && mTreble == 0.0 && mGain == 0.0);
213 }

References mBass, mGain, and mTreble.

◆ Coefficients()

void EffectBassTreble::Coefficients ( double  hz,
double  slope,
double  gain,
double  samplerate,
int  type,
double &  a0,
double &  a1,
double &  a2,
double &  b0,
double &  b1,
double &  b2 
)
private

Definition at line 393 of file BassTreble.cpp.

396 {
397  double w = 2 * M_PI * hz / samplerate;
398  double a = exp(log(10.0) * gain / 40);
399  double b = sqrt((a * a + 1) / slope - (pow((a - 1), 2)));
400 
401  if (type == kBass)
402  {
403  b0 = a * ((a + 1) - (a - 1) * cos(w) + b * sin(w));
404  b1 = 2 * a * ((a - 1) - (a + 1) * cos(w));
405  b2 = a * ((a + 1) - (a - 1) * cos(w) - b * sin(w));
406  a0 = ((a + 1) + (a - 1) * cos(w) + b * sin(w));
407  a1 = -2 * ((a - 1) + (a + 1) * cos(w));
408  a2 = (a + 1) + (a - 1) * cos(w) - b * sin(w);
409  }
410  else //assumed kTreble
411  {
412  b0 = a * ((a + 1) + (a - 1) * cos(w) + b * sin(w));
413  b1 = -2 * a * ((a - 1) + (a + 1) * cos(w));
414  b2 = a * ((a + 1) + (a - 1) * cos(w) - b * sin(w));
415  a0 = ((a + 1) - (a - 1) * cos(w) + b * sin(w));
416  a1 = 2 * ((a - 1) - (a + 1) * cos(w));
417  a2 = (a + 1) - (a - 1) * cos(w) - b * sin(w);
418  }
419 }

References kBass, and M_PI.

Referenced by InstanceProcess().

Here is the caller graph for this function:

◆ DefineParams()

bool EffectBassTreble::DefineParams ( ShuttleParams S)
override

Definition at line 177 of file BassTreble.cpp.

177  {
178  S.SHUTTLE_PARAM( mBass, Bass );
179  S.SHUTTLE_PARAM( mTreble, Treble );
180  S.SHUTTLE_PARAM( mGain, Gain );
181  S.SHUTTLE_PARAM( mLink, Link );
182  return true;
183 }

References mBass, mGain, mLink, mTreble, and S.

◆ DoFilter()

float EffectBassTreble::DoFilter ( EffectBassTrebleState data,
float  in 
)
private

Definition at line 421 of file BassTreble.cpp.

422 {
423  // Bass filter
424  float out = (data.b0Bass * in + data.b1Bass * data.xn1Bass + data.b2Bass * data.xn2Bass -
425  data.a1Bass * data.yn1Bass - data.a2Bass * data.yn2Bass) / data.a0Bass;
426  data.xn2Bass = data.xn1Bass;
427  data.xn1Bass = in;
428  data.yn2Bass = data.yn1Bass;
429  data.yn1Bass = out;
430 
431  // Treble filter
432  in = out;
433  out = (data.b0Treble * in + data.b1Treble * data.xn1Treble + data.b2Treble * data.xn2Treble -
434  data.a1Treble * data.yn1Treble - data.a2Treble * data.yn2Treble) / data.a0Treble;
435  data.xn2Treble = data.xn1Treble;
436  data.xn1Treble = in;
437  data.yn2Treble = data.yn1Treble;
438  data.yn1Treble = out;
439 
440  return out;
441 }

References EffectBassTrebleState::a0Bass, EffectBassTrebleState::a0Treble, EffectBassTrebleState::a1Bass, EffectBassTrebleState::a1Treble, EffectBassTrebleState::a2Bass, EffectBassTrebleState::a2Treble, EffectBassTrebleState::b0Bass, EffectBassTrebleState::b0Treble, EffectBassTrebleState::b1Bass, EffectBassTrebleState::b1Treble, EffectBassTrebleState::b2Bass, EffectBassTrebleState::b2Treble, EffectBassTrebleState::xn1Bass, EffectBassTrebleState::xn1Treble, EffectBassTrebleState::xn2Bass, EffectBassTrebleState::xn2Treble, EffectBassTrebleState::yn1Bass, EffectBassTrebleState::yn1Treble, EffectBassTrebleState::yn2Bass, and EffectBassTrebleState::yn2Treble.

Referenced by InstanceProcess().

Here is the caller graph for this function:

◆ GetAudioInCount()

unsigned EffectBassTreble::GetAudioInCount ( )
overridevirtual

Implements EffectProcessor.

Definition at line 121 of file BassTreble.cpp.

122 {
123  return 1;
124 }

◆ GetAudioOutCount()

unsigned EffectBassTreble::GetAudioOutCount ( )
overridevirtual

Implements EffectProcessor.

Definition at line 126 of file BassTreble.cpp.

127 {
128  return 1;
129 }

◆ GetAutomationParameters()

bool EffectBassTreble::GetAutomationParameters ( CommandParameters parms)
overridevirtual

Save current settings into parms.

Implements EffectDefinitionInterface.

Definition at line 185 of file BassTreble.cpp.

186 {
187  parms.Write(KEY_Bass, mBass);
188  parms.Write(KEY_Treble, mTreble);
189  parms.Write(KEY_Gain, mGain);
190  parms.Write(KEY_Link, mLink);
191 
192  return true;
193 }

References mBass, mGain, mLink, and mTreble.

◆ GetDescription()

TranslatableString EffectBassTreble::GetDescription ( )
overridevirtual

Implements ComponentInterface.

Definition at line 96 of file BassTreble.cpp.

97 {
98  return XO("Simple tone control effect");
99 }

References XO.

◆ GetSymbol()

ComponentInterfaceSymbol EffectBassTreble::GetSymbol ( )
overridevirtual

Implements ComponentInterface.

Definition at line 91 of file BassTreble.cpp.

92 {
93  return Symbol;
94 }

References Symbol.

◆ GetType()

EffectType EffectBassTreble::GetType ( )
overridevirtual

Type determines how it behaves.

Implements EffectDefinitionInterface.

Definition at line 108 of file BassTreble.cpp.

109 {
110  return EffectTypeProcess;
111 }

References EffectTypeProcess.

◆ InstanceInit()

void EffectBassTreble::InstanceInit ( EffectBassTrebleState data,
float  sampleRate 
)
private

Definition at line 314 of file BassTreble.cpp.

315 {
316  data.samplerate = sampleRate;
317  data.slope = 0.4f; // same slope for both filters
318  data.hzBass = 250.0f; // could be tunable in a more advanced version
319  data.hzTreble = 4000.0f; // could be tunable in a more advanced version
320 
321  data.a0Bass = 1;
322  data.a1Bass = 0;
323  data.a2Bass = 0;
324  data.b0Bass = 0;
325  data.b1Bass = 0;
326  data.b2Bass = 0;
327 
328  data.a0Treble = 1;
329  data.a1Treble = 0;
330  data.a2Treble = 0;
331  data.b0Treble = 0;
332  data.b1Treble = 0;
333  data.b2Treble = 0;
334 
335  data.xn1Bass = 0;
336  data.xn2Bass = 0;
337  data.yn1Bass = 0;
338  data.yn2Bass = 0;
339 
340  data.xn1Treble = 0;
341  data.xn2Treble = 0;
342  data.yn1Treble = 0;
343  data.yn2Treble = 0;
344 
345  data.bass = -1;
346  data.treble = -1;
347  data.gain = DB_TO_LINEAR(mGain);
348 
349 }

References EffectBassTrebleState::a0Bass, EffectBassTrebleState::a0Treble, EffectBassTrebleState::a1Bass, EffectBassTrebleState::a1Treble, EffectBassTrebleState::a2Bass, EffectBassTrebleState::a2Treble, EffectBassTrebleState::b0Bass, EffectBassTrebleState::b0Treble, EffectBassTrebleState::b1Bass, EffectBassTrebleState::b1Treble, EffectBassTrebleState::b2Bass, EffectBassTrebleState::b2Treble, EffectBassTrebleState::bass, DB_TO_LINEAR(), EffectBassTrebleState::gain, EffectBassTrebleState::hzBass, EffectBassTrebleState::hzTreble, mGain, EffectBassTrebleState::samplerate, EffectBassTrebleState::slope, EffectBassTrebleState::treble, EffectBassTrebleState::xn1Bass, EffectBassTrebleState::xn1Treble, EffectBassTrebleState::xn2Bass, EffectBassTrebleState::xn2Treble, EffectBassTrebleState::yn1Bass, EffectBassTrebleState::yn1Treble, EffectBassTrebleState::yn2Bass, and EffectBassTrebleState::yn2Treble.

Referenced by ProcessInitialize(), and RealtimeAddProcessor().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ InstanceProcess()

size_t EffectBassTreble::InstanceProcess ( EffectBassTrebleState data,
float **  inBlock,
float **  outBlock,
size_t  blockLen 
)
private

Definition at line 355 of file BassTreble.cpp.

359 {
360  float *ibuf = inBlock[0];
361  float *obuf = outBlock[0];
362 
363  // Set value to ensure correct rounding
364  double oldBass = DB_TO_LINEAR(mBass);
365  double oldTreble = DB_TO_LINEAR(mTreble);
366 
367  data.gain = DB_TO_LINEAR(mGain);
368 
369  // Compute coefficients of the low shelf biquand IIR filter
370  if (data.bass != oldBass)
371  Coefficients(data.hzBass, data.slope, mBass, data.samplerate, kBass,
372  data.a0Bass, data.a1Bass, data.a2Bass,
373  data.b0Bass, data.b1Bass, data.b2Bass);
374 
375  // Compute coefficients of the high shelf biquand IIR filter
376  if (data.treble != oldTreble)
378  data.a0Treble, data.a1Treble, data.a2Treble,
379  data.b0Treble, data.b1Treble, data.b2Treble);
380 
381  for (decltype(blockLen) i = 0; i < blockLen; i++) {
382  obuf[i] = DoFilter(data, ibuf[i]) * data.gain;
383  }
384 
385  return blockLen;
386 }

References EffectBassTrebleState::a0Bass, EffectBassTrebleState::a0Treble, EffectBassTrebleState::a1Bass, EffectBassTrebleState::a1Treble, EffectBassTrebleState::a2Bass, EffectBassTrebleState::a2Treble, EffectBassTrebleState::b0Bass, EffectBassTrebleState::b0Treble, EffectBassTrebleState::b1Bass, EffectBassTrebleState::b1Treble, EffectBassTrebleState::b2Bass, EffectBassTrebleState::b2Treble, EffectBassTrebleState::bass, Coefficients(), DB_TO_LINEAR(), DoFilter(), EffectBassTrebleState::gain, EffectBassTrebleState::hzBass, EffectBassTrebleState::hzTreble, kBass, kTreble, mBass, mGain, mTreble, EffectBassTrebleState::samplerate, EffectBassTrebleState::slope, and EffectBassTrebleState::treble.

Referenced by ProcessBlock(), and RealtimeProcess().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ManualPage()

ManualPageID EffectBassTreble::ManualPage ( )
overridevirtual

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

Reimplemented from EffectDefinitionInterface.

Definition at line 101 of file BassTreble.cpp.

102 {
103  return L"Bass_and_Treble";
104 }

◆ OnBassSlider()

void EffectBassTreble::OnBassSlider ( wxCommandEvent &  evt)
private

Definition at line 480 of file BassTreble.cpp.

481 {
482  double oldBass = mBass;
483  mBass = (double) evt.GetInt() / SCL_Bass;
484  mBassT->GetValidator()->TransferToWindow();
485 
486  if (mLink) UpdateGain(oldBass, kBass);
487  EnableApply(mUIParent->Validate());
488 }

References Effect::EnableApply(), kBass, mBass, mBassT, mLink, Effect::mUIParent, and UpdateGain().

Here is the call graph for this function:

◆ OnBassText()

void EffectBassTreble::OnBassText ( wxCommandEvent &  evt)
private

Definition at line 444 of file BassTreble.cpp.

445 {
446  double oldBass = mBass;
447 
448  if (!EnableApply(mUIParent->TransferDataFromWindow()))
449  {
450  return;
451  }
452 
453  if (mLink) UpdateGain(oldBass, kBass);
454  mBassS->SetValue((int) (mBass * SCL_Bass));
455 }

References Effect::EnableApply(), kBass, mBass, mBassS, mLink, Effect::mUIParent, and UpdateGain().

Here is the call graph for this function:

◆ OnGainSlider()

void EffectBassTreble::OnGainSlider ( wxCommandEvent &  evt)
private

Definition at line 500 of file BassTreble.cpp.

501 {
502  mGain = (double) evt.GetInt() / SCL_Gain;
503  mGainT->GetValidator()->TransferToWindow();
504 
505  EnableApply(mUIParent->Validate());
506 }

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

Here is the call graph for this function:

◆ OnGainText()

void EffectBassTreble::OnGainText ( wxCommandEvent &  evt)
private

Definition at line 470 of file BassTreble.cpp.

471 {
472  if (!EnableApply(mUIParent->TransferDataFromWindow()))
473  {
474  return;
475  }
476 
477  mGainS->SetValue((int) (mGain * SCL_Gain));
478 }

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

Here is the call graph for this function:

◆ OnLinkCheckbox()

void EffectBassTreble::OnLinkCheckbox ( wxCommandEvent &  evt)
private

Definition at line 508 of file BassTreble.cpp.

509 {
510  mLink = mLinkCheckBox->GetValue();
511 }

References mLink, and mLinkCheckBox.

◆ OnTrebleSlider()

void EffectBassTreble::OnTrebleSlider ( wxCommandEvent &  evt)
private

Definition at line 490 of file BassTreble.cpp.

491 {
492  double oldTreble = mTreble;
493  mTreble = (double) evt.GetInt() / SCL_Treble;
494  mTrebleT->GetValidator()->TransferToWindow();
495 
496  if (mLink) UpdateGain(oldTreble, kTreble);
497  EnableApply(mUIParent->Validate());
498 }

References Effect::EnableApply(), kTreble, mLink, mTreble, mTrebleT, Effect::mUIParent, and UpdateGain().

Here is the call graph for this function:

◆ OnTrebleText()

void EffectBassTreble::OnTrebleText ( wxCommandEvent &  evt)
private

Definition at line 457 of file BassTreble.cpp.

458 {
459  double oldTreble = mTreble;
460 
461  if (!EnableApply(mUIParent->TransferDataFromWindow()))
462  {
463  return;
464  }
465 
466  if (mLink) UpdateGain(oldTreble, kTreble);
467  mTrebleS->SetValue((int) (mTreble * SCL_Treble));
468 }

References Effect::EnableApply(), kTreble, mLink, mTreble, mTrebleS, Effect::mUIParent, and UpdateGain().

Here is the call graph for this function:

◆ PopulateOrExchange()

void EffectBassTreble::PopulateOrExchange ( ShuttleGui S)
overridevirtual

Reimplemented from Effect.

Definition at line 218 of file BassTreble.cpp.

219 {
220  S.SetBorder(5);
221  S.AddSpace(0, 5);
222 
223  S.StartStatic(XO("Tone controls"));
224  {
225  S.StartMultiColumn(3, wxEXPAND);
226  {
227  S.SetStretchyCol(2);
228 
229  // Bass control
230  mBassT = S.Id(ID_Bass)
231  .Name(XO("Bass (dB):"))
232  .Validator<FloatingPointValidator<double>>(
233  1, &mBass, NumValidatorStyle::DEFAULT, MIN_Bass, MAX_Bass)
234  .AddTextBox(XXO("Ba&ss (dB):"), wxT(""), 10);
235 
236  mBassS = S.Id(ID_Bass)
237  .Name(XO("Bass"))
238  .Style(wxSL_HORIZONTAL)
239  .AddSlider( {}, 0, MAX_Bass * SCL_Bass, MIN_Bass * SCL_Bass);
240 
241  // Treble control
242  mTrebleT = S.Id(ID_Treble)
243  .Validator<FloatingPointValidator<double>>(
244  1, &mTreble, NumValidatorStyle::DEFAULT, MIN_Treble, MAX_Treble)
245  .AddTextBox(XXO("&Treble (dB):"), wxT(""), 10);
246 
247  mTrebleS = S.Id(ID_Treble)
248  .Name(XO("Treble"))
249  .Style(wxSL_HORIZONTAL)
250  .AddSlider( {}, 0, MAX_Treble * SCL_Treble, MIN_Treble * SCL_Treble);
251  }
252  S.EndMultiColumn();
253  }
254  S.EndStatic();
255 
256  S.StartStatic(XO("Output"));
257  {
258  S.StartMultiColumn(3, wxEXPAND);
259  {
260  S.SetStretchyCol(2);
261 
262  // Gain control
263  mGainT = S.Id(ID_Gain)
264  .Validator<FloatingPointValidator<double>>(
265  1, &mGain, NumValidatorStyle::DEFAULT, MIN_Gain, MAX_Gain)
266  .AddTextBox(XXO("&Volume (dB):"), wxT(""), 10);
267 
268  mGainS = S.Id(ID_Gain)
269  .Name(XO("Level"))
270  .Style(wxSL_HORIZONTAL)
271  .AddSlider( {}, 0, MAX_Gain * SCL_Gain, MIN_Gain * SCL_Gain);
272  }
273  S.EndMultiColumn();
274 
275  S.StartMultiColumn(2, wxCENTER);
276  {
277  // Link checkbox
278  mLinkCheckBox = S.Id(ID_Link).AddCheckBox(XXO("&Link Volume control to Tone controls"),
279  DEF_Link);
280  }
281  S.EndMultiColumn();
282  }
283  S.EndStatic();
284 }

References ID_Bass, ID_Gain, ID_Link, ID_Treble, mBass, mBassS, mBassT, mGain, mGainS, mGainT, mLinkCheckBox, mTreble, mTrebleS, mTrebleT, S, XO, and XXO.

◆ ProcessBlock()

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

Called for destructive, non-realtime effect computation.

Implements EffectProcessor.

Definition at line 138 of file BassTreble.cpp.

139 {
140  return InstanceProcess(mMaster, inBlock, outBlock, blockLen);
141 }

References InstanceProcess(), and mMaster.

Here is the call graph for this function:

◆ ProcessInitialize()

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

Called for destructive, non-realtime effect computation.

Implements EffectProcessor.

Definition at line 131 of file BassTreble.cpp.

132 {
134 
135  return true;
136 }

References InstanceInit(), mMaster, and Effect::mSampleRate.

Here is the call graph for this function:

◆ RealtimeAddProcessor()

bool EffectBassTreble::RealtimeAddProcessor ( unsigned  numChannels,
float  sampleRate 
)
overridevirtual

Implements EffectProcessor.

Definition at line 152 of file BassTreble.cpp.

153 {
154  EffectBassTrebleState slave;
155 
156  InstanceInit(slave, sampleRate);
157 
158  mSlaves.push_back(slave);
159 
160  return true;
161 }

References InstanceInit(), and mSlaves.

Here is the call graph for this function:

◆ RealtimeFinalize()

bool EffectBassTreble::RealtimeFinalize ( )
overridevirtual

Implements EffectProcessor.

Definition at line 163 of file BassTreble.cpp.

164 {
165  mSlaves.clear();
166 
167  return true;
168 }

References mSlaves.

◆ RealtimeInitialize()

bool EffectBassTreble::RealtimeInitialize ( )
overridevirtual

Implements EffectProcessor.

Definition at line 143 of file BassTreble.cpp.

144 {
145  SetBlockSize(512);
146 
147  mSlaves.clear();
148 
149  return true;
150 }

References mSlaves, and Effect::SetBlockSize().

Here is the call graph for this function:

◆ RealtimeProcess()

size_t EffectBassTreble::RealtimeProcess ( int  group,
float **  inbuf,
float **  outbuf,
size_t  numSamples 
)
overridevirtual

Implements EffectProcessor.

Definition at line 170 of file BassTreble.cpp.

174 {
175  return InstanceProcess(mSlaves[group], inbuf, outbuf, numSamples);
176 }

References InstanceProcess(), and mSlaves.

Here is the call graph for this function:

◆ SetAutomationParameters()

bool EffectBassTreble::SetAutomationParameters ( CommandParameters parms)
overridevirtual

Change settings to those stored in parms.

Implements EffectDefinitionInterface.

Definition at line 195 of file BassTreble.cpp.

196 {
197  ReadAndVerifyDouble(Bass);
198  ReadAndVerifyDouble(Treble);
199  ReadAndVerifyDouble(Gain);
200  ReadAndVerifyBool(Link);
201 
202  mBass = Bass;
203  mTreble = Treble;
204  mGain = Gain;
205  mLink = Link;
206 
207  return true;
208 }

References mBass, mGain, mLink, mTreble, ReadAndVerifyBool, and ReadAndVerifyDouble.

◆ SupportsRealtime()

bool EffectBassTreble::SupportsRealtime ( )
overridevirtual

Whether the effect supports realtime previewing (while audio is playing).

Implements EffectDefinitionInterface.

Definition at line 113 of file BassTreble.cpp.

114 {
115  return true;
116 }

◆ TransferDataFromWindow()

bool EffectBassTreble::TransferDataFromWindow ( )
overridevirtual

Reimplemented from Effect.

Definition at line 301 of file BassTreble.cpp.

302 {
303  if (!mUIParent->Validate() || !mUIParent->TransferDataFromWindow())
304  {
305  return false;
306  }
307 
308  return true;
309 }

References Effect::mUIParent.

◆ TransferDataToWindow()

bool EffectBassTreble::TransferDataToWindow ( )
overridevirtual

Reimplemented from Effect.

Definition at line 286 of file BassTreble.cpp.

287 {
288  if (!mUIParent->TransferDataToWindow())
289  {
290  return false;
291  }
292 
293  mBassS->SetValue((int) (mBass * SCL_Bass));
294  mTrebleS->SetValue((int) mTreble *SCL_Treble);
295  mGainS->SetValue((int) mGain * SCL_Gain);
296  mLinkCheckBox->SetValue(mLink);
297 
298  return true;
299 }

References mBass, mBassS, mGain, mGainS, mLink, mLinkCheckBox, mTreble, mTrebleS, and Effect::mUIParent.

◆ UpdateGain()

void EffectBassTreble::UpdateGain ( double  oldVal,
int  control 
)
private

Definition at line 513 of file BassTreble.cpp.

514 {
515  double newVal;
516  oldVal = (oldVal > 0)? oldVal / 2.0 : oldVal / 4.0;
517 
518  if (control == kBass)
519  newVal = (mBass > 0)? mBass / 2.0 : mBass / 4.0;
520  else
521  newVal = (mTreble > 0)? mTreble / 2.0 : mTreble / 4.0;
522 
523  mGain -= newVal - oldVal;
524  mGain = std::min(MAX_Gain, std::max(MIN_Gain, mGain));
525 
526  mGainS->SetValue(mGain);
527  mGainT->GetValidator()->TransferToWindow();
528 
529 }

References kBass, mBass, mGain, mGainS, mGainT, min(), and mTreble.

Referenced by OnBassSlider(), OnBassText(), OnTrebleSlider(), and OnTrebleText().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ mBass

double EffectBassTreble::mBass
private

◆ mBassS

wxSlider* EffectBassTreble::mBassS
private

Definition at line 111 of file BassTreble.h.

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

◆ mBassT

wxTextCtrl* EffectBassTreble::mBassT
private

Definition at line 115 of file BassTreble.h.

Referenced by OnBassSlider(), and PopulateOrExchange().

◆ mGain

double EffectBassTreble::mGain
private

◆ mGainS

wxSlider* EffectBassTreble::mGainS
private

Definition at line 113 of file BassTreble.h.

Referenced by OnGainText(), PopulateOrExchange(), TransferDataToWindow(), and UpdateGain().

◆ mGainT

wxTextCtrl* EffectBassTreble::mGainT
private

Definition at line 117 of file BassTreble.h.

Referenced by OnGainSlider(), PopulateOrExchange(), and UpdateGain().

◆ mLink

bool EffectBassTreble::mLink
private

◆ mLinkCheckBox

wxCheckBox* EffectBassTreble::mLinkCheckBox
private

Definition at line 119 of file BassTreble.h.

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

◆ mMaster

EffectBassTrebleState EffectBassTreble::mMaster
private

Definition at line 103 of file BassTreble.h.

Referenced by ProcessBlock(), and ProcessInitialize().

◆ mSlaves

std::vector<EffectBassTrebleState> EffectBassTreble::mSlaves
private

◆ mTreble

double EffectBassTreble::mTreble
private

◆ mTrebleS

wxSlider* EffectBassTreble::mTrebleS
private

Definition at line 112 of file BassTreble.h.

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

◆ mTrebleT

wxTextCtrl* EffectBassTreble::mTrebleT
private

Definition at line 116 of file BassTreble.h.

Referenced by OnTrebleSlider(), and PopulateOrExchange().

◆ Symbol

const ComponentInterfaceSymbol EffectBassTreble::Symbol { XO("Bass and Treble") }
static

Definition at line 39 of file BassTreble.h.

Referenced by GetSymbol().


The documentation for this class was generated from the following files:
EffectBassTrebleState
Definition: BassTreble.h:23
EffectBassTrebleState::xn2Treble
double xn2Treble
Definition: BassTreble.h:33
EffectBassTrebleState::slope
double slope
Definition: BassTreble.h:29
kBass
@ kBass
Definition: BassTreble.cpp:56
EffectBassTreble::mTrebleT
wxTextCtrl * mTrebleT
Definition: BassTreble.h:116
EffectBassTrebleState::b0Treble
double b0Treble
Definition: BassTreble.h:31
EffectBassTrebleState::b2Treble
double b2Treble
Definition: BassTreble.h:31
EffectTypeProcess
@ EffectTypeProcess
Definition: EffectInterface.h:56
DB_TO_LINEAR
const double MIN_Threshold_Linear DB_TO_LINEAR(MIN_Threshold_dB)
Effect::SetLinearEffectFlag
void SetLinearEffectFlag(bool linearEffectFlag)
Definition: Effect.cpp:1764
Effect::EnableApply
bool EnableApply(bool enable=true)
Definition: Effect.cpp:1694
EffectBassTrebleState::yn1Bass
double yn1Bass
Definition: BassTreble.h:32
S
#define S(N)
Definition: ToChars.cpp:64
EffectBassTreble::mLinkCheckBox
wxCheckBox * mLinkCheckBox
Definition: BassTreble.h:119
EffectBassTrebleState::yn2Treble
double yn2Treble
Definition: BassTreble.h:33
EffectBassTrebleState::a2Bass
double a2Bass
Definition: BassTreble.h:30
EffectBassTreble::mTrebleS
wxSlider * mTrebleS
Definition: BassTreble.h:112
EffectBassTrebleState::yn2Bass
double yn2Bass
Definition: BassTreble.h:32
EffectBassTrebleState::gain
double gain
Definition: BassTreble.h:28
EffectBassTrebleState::b0Bass
double b0Bass
Definition: BassTreble.h:30
EffectBassTrebleState::a2Treble
double a2Treble
Definition: BassTreble.h:31
XO
#define XO(s)
Definition: Internat.h:31
EffectBassTrebleState::b1Treble
double b1Treble
Definition: BassTreble.h:31
EffectBassTrebleState::bass
double bass
Definition: BassTreble.h:27
EffectBassTrebleState::samplerate
float samplerate
Definition: BassTreble.h:25
EffectBassTrebleState::hzTreble
double hzTreble
Definition: BassTreble.h:29
EffectBassTrebleState::b2Bass
double b2Bass
Definition: BassTreble.h:30
EffectBassTrebleState::xn1Treble
double xn1Treble
Definition: BassTreble.h:33
EffectBassTreble::Symbol
static const ComponentInterfaceSymbol Symbol
Definition: BassTreble.h:39
EffectBassTreble::mGainT
wxTextCtrl * mGainT
Definition: BassTreble.h:117
EffectBassTreble::InstanceInit
void InstanceInit(EffectBassTrebleState &data, float sampleRate)
Definition: BassTreble.cpp:314
kTreble
@ kTreble
Definition: BassTreble.cpp:57
XXO
#define XXO(s)
Definition: Internat.h:44
EffectBassTreble::mSlaves
std::vector< EffectBassTrebleState > mSlaves
Definition: BassTreble.h:104
EffectBassTreble::DoFilter
float DoFilter(EffectBassTrebleState &data, float in)
Definition: BassTreble.cpp:421
ID_Gain
@ ID_Gain
Definition: BassTreble.cpp:41
EffectBassTreble::mGain
double mGain
Definition: BassTreble.h:108
EffectBassTreble::mLink
bool mLink
Definition: BassTreble.h:109
EffectBassTrebleState::a0Treble
double a0Treble
Definition: BassTreble.h:31
EffectBassTrebleState::b1Bass
double b1Bass
Definition: BassTreble.h:30
EffectBassTreble::mBass
double mBass
Definition: BassTreble.h:106
EffectBassTrebleState::yn1Treble
double yn1Treble
Definition: BassTreble.h:33
EffectBassTrebleState::xn1Bass
double xn1Bass
Definition: BassTreble.h:32
ReadAndVerifyDouble
#define ReadAndVerifyDouble(name)
Definition: Effect.h:592
EffectBassTrebleState::a1Treble
double a1Treble
Definition: BassTreble.h:31
EffectBassTrebleState::xn2Bass
double xn2Bass
Definition: BassTreble.h:32
min
int min(int a, int b)
Definition: CompareAudioCommand.cpp:106
EffectBassTreble::mBassS
wxSlider * mBassS
Definition: BassTreble.h:111
ID_Treble
@ ID_Treble
Definition: BassTreble.cpp:40
EffectBassTreble::mBassT
wxTextCtrl * mBassT
Definition: BassTreble.h:115
Effect::mSampleRate
double mSampleRate
Definition: Effect.h:418
EffectBassTreble::Coefficients
void Coefficients(double hz, double slope, double gain, double samplerate, int type, double &a0, double &a1, double &a2, double &b0, double &b1, double &b2)
Definition: BassTreble.cpp:393
Effect::mUIParent
wxWindow * mUIParent
Definition: Effect.h:438
EffectBassTreble::mTreble
double mTreble
Definition: BassTreble.h:107
EffectBassTreble::mGainS
wxSlider * mGainS
Definition: BassTreble.h:113
EffectBassTreble::UpdateGain
void UpdateGain(double oldVal, int control)
Definition: BassTreble.cpp:513
EffectBassTrebleState::a1Bass
double a1Bass
Definition: BassTreble.h:30
M_PI
#define M_PI
Definition: Distortion.cpp:29
ID_Link
@ ID_Link
Definition: BassTreble.cpp:42
EffectBassTreble::InstanceProcess
size_t InstanceProcess(EffectBassTrebleState &data, float **inBlock, float **outBlock, size_t blockLen)
Definition: BassTreble.cpp:355
EffectBassTrebleState::a0Bass
double a0Bass
Definition: BassTreble.h:30
EffectBassTrebleState::hzBass
double hzBass
Definition: BassTreble.h:29
Effect::SetBlockSize
size_t SetBlockSize(size_t maxBlockSize) override
Definition: Effect.cpp:294
EffectBassTreble::mMaster
EffectBassTrebleState mMaster
Definition: BassTreble.h:103
EffectBassTrebleState::treble
double treble
Definition: BassTreble.h:26
ReadAndVerifyBool
#define ReadAndVerifyBool(name)
Definition: Effect.h:594
ID_Bass
@ ID_Bass
Definition: BassTreble.cpp:39