Audacity  3.0.3
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
 
EffectType GetType () override
 
bool SupportsRealtime () override
 
unsigned GetAudioInCount () override
 
unsigned GetAudioOutCount () override
 
bool ProcessInitialize (sampleCount totalLen, ChannelNames chanMap=NULL) override
 
size_t ProcessBlock (float **inBlock, float **outBlock, size_t blockLen) override
 
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
 
bool GetAutomationParameters (CommandParameters &parms) override
 
bool SetAutomationParameters (CommandParameters &parms) 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
 
EffectFamilySymbol GetFamily () override
 
bool IsInteractive () override
 
bool IsDefault () override
 
bool IsLegacy () override
 
bool SupportsRealtime () override
 
bool SupportsAutomation () override
 
bool SetHost (EffectHostInterface *host) override
 
unsigned GetAudioInCount () override
 
unsigned GetAudioOutCount () override
 
int GetMidiInCount () override
 
int GetMidiOutCount () override
 
sampleCount GetLatency () override
 
size_t GetTailSize () override
 
void SetSampleRate (double rate) override
 
size_t SetBlockSize (size_t maxBlockSize) override
 
size_t GetBlockSize () const override
 
bool IsReady () override
 
bool ProcessInitialize (sampleCount totalLen, ChannelNames chanMap=NULL) override
 
bool ProcessFinalize () override
 
size_t ProcessBlock (float **inBlock, float **outBlock, size_t blockLen) override
 
bool RealtimeInitialize () override
 
bool RealtimeAddProcessor (unsigned numChannels, float sampleRate) override
 
bool RealtimeFinalize () override
 
bool RealtimeSuspend () override
 
bool RealtimeResume () override
 
bool RealtimeProcessStart () override
 
size_t RealtimeProcess (int group, float **inbuf, float **outbuf, size_t numSamples) override
 
bool RealtimeProcessEnd () override
 
bool ShowInterface (wxWindow &parent, const EffectDialogFactory &factory, bool forceModal=false) override
 
bool GetAutomationParameters (CommandParameters &parms) override
 
bool SetAutomationParameters (CommandParameters &parms) override
 
bool LoadUserPreset (const RegistryPath &name) override
 
bool SaveUserPreset (const RegistryPath &name) override
 
RegistryPaths GetFactoryPresets () override
 
bool LoadFactoryPreset (int id) override
 
bool LoadFactoryDefaults () override
 
void SetHostUI (EffectUIHostInterface *host) override
 
bool PopulateUI (ShuttleGui &S) final
 
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
 
double GetDefaultDuration () 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 ()
 
bool HasSharedConfigGroup (const RegistryPath &group) override
 
bool GetSharedConfigSubgroups (const RegistryPath &group, RegistryPaths &subgroups) override
 
bool GetSharedConfig (const RegistryPath &group, const RegistryPath &key, wxString &value, const wxString &defval={}) override
 
bool GetSharedConfig (const RegistryPath &group, const RegistryPath &key, int &value, int defval=0) override
 
bool GetSharedConfig (const RegistryPath &group, const RegistryPath &key, bool &value, bool defval=false) override
 
bool GetSharedConfig (const RegistryPath &group, const RegistryPath &key, float &value, float defval=0.0) override
 
bool GetSharedConfig (const RegistryPath &group, const RegistryPath &key, double &value, double defval=0.0) override
 
bool SetSharedConfig (const RegistryPath &group, const RegistryPath &key, const wxString &value) override
 
bool SetSharedConfig (const RegistryPath &group, const RegistryPath &key, const int &value) override
 
bool SetSharedConfig (const RegistryPath &group, const RegistryPath &key, const bool &value) override
 
bool SetSharedConfig (const RegistryPath &group, const RegistryPath &key, const float &value) override
 
bool SetSharedConfig (const RegistryPath &group, const RegistryPath &key, const double &value) override
 
bool RemoveSharedConfigSubgroup (const RegistryPath &group) override
 
bool RemoveSharedConfig (const RegistryPath &group, const RegistryPath &key) override
 
bool HasPrivateConfigGroup (const RegistryPath &group) override
 
bool GetPrivateConfigSubgroups (const RegistryPath &group, RegistryPaths &paths) override
 
bool GetPrivateConfig (const RegistryPath &group, const RegistryPath &key, wxString &value, const wxString &defval={}) override
 
bool GetPrivateConfig (const RegistryPath &group, const RegistryPath &key, int &value, int defval=0) override
 
bool GetPrivateConfig (const RegistryPath &group, const RegistryPath &key, bool &value, bool defval=false) override
 
bool GetPrivateConfig (const RegistryPath &group, const RegistryPath &key, float &value, float defval=0.0) override
 
bool GetPrivateConfig (const RegistryPath &group, const RegistryPath &key, double &value, double defval=0.0) override
 
bool SetPrivateConfig (const RegistryPath &group, const RegistryPath &key, const wxString &value) override
 
bool SetPrivateConfig (const RegistryPath &group, const RegistryPath &key, const int &value) override
 
bool SetPrivateConfig (const RegistryPath &group, const RegistryPath &key, const bool &value) override
 
bool SetPrivateConfig (const RegistryPath &group, const RegistryPath &key, const float &value) override
 
bool SetPrivateConfig (const RegistryPath &group, const RegistryPath &key, const double &value) override
 
bool RemovePrivateConfigSubgroup (const RegistryPath &group) override
 
bool RemovePrivateConfig (const RegistryPath &group, const RegistryPath &key) override
 
virtual PluginID GetID ()
 
virtual bool Startup (EffectClientInterface *client)
 
virtual bool Startup ()
 
virtual bool GetAutomationParameters (wxString &parms)
 
virtual bool SetAutomationParameters (const wxString &parms)
 
virtual RegistryPaths GetUserPresets ()
 
virtual bool HasCurrentSettings ()
 
virtual bool HasFactoryDefaults ()
 
virtual FilePath HelpPage ()
 
virtual void SetUIFlags (unsigned flags)
 
virtual unsigned TestUIFlags (unsigned mask)
 
virtual bool IsBatchProcessing ()
 
virtual void SetBatchProcessing (bool start)
 
void SetPresetParameters (const wxArrayString *Names, const wxArrayString *Values)
 
bool DoEffect (double projectRate, TrackList *list, WaveTrackFactory *factory, NotifyingSelectedRegion &selectedRegion, wxWindow *pParent=nullptr, const EffectDialogFactory &dialogFactory={})
 
bool Delegate (Effect &delegate, wxWindow &parent, const EffectDialogFactory &factory)
 
virtual bool IsHidden ()
 
int MessageBox (const TranslatableString &message, long style=DefaultMessageBoxStyle, const TranslatableString &titleStr={})
 
- Public Member Functions inherited from EffectClientInterface
virtual ~EffectClientInterface ()
 
- Public Member Functions inherited from EffectDefinitionInterface
virtual ~EffectDefinitionInterface ()
 
virtual EffectType GetClassification ()
 
- Public Member Functions inherited from ComponentInterface
virtual ~ComponentInterface ()
 
TranslatableString GetName ()
 
virtual bool DefineParams (ShuttleParams &WXUNUSED(S))
 
- Public Member Functions inherited from EffectUIClientInterface
virtual ~EffectUIClientInterface ()
 
- Public Member Functions inherited from EffectHostInterface
virtual ~EffectHostInterface ()
 
- Public Member Functions inherited from ConfigClientInterface
virtual ~ConfigClientInterface ()
 

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 }
 
using VetoDialogHook = bool(*)(wxDialog *)
 
- Public Types inherited from EffectClientInterface
using EffectDialogFactory = std::function< wxDialog *(wxWindow &parent, EffectHostInterface *, EffectUIClientInterface *) >
 
- Static Public Member Functions inherited from Effect
static VetoDialogHook SetVetoDialogHook (VetoDialogHook hook)
 
static CommandID GetSquashedName (wxString name)
 
static void IncEffectCounter ()
 
- Protected Member Functions inherited from Effect
virtual bool Init ()
 
virtual bool Process ()
 
virtual bool ProcessPass ()
 
virtual bool InitPass1 ()
 
virtual bool InitPass2 ()
 
virtual int GetPass ()
 
virtual void End ()
 
virtual double CalcPreviewInputLength (double previewLength)
 
virtual void Preview (bool dryOnly)
 
virtual bool EnableApply (bool enable=true)
 
virtual bool EnablePreview (bool enable=true)
 
virtual void EnableDebug (bool enable=true)
 
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
ProgressDialogmProgress
 
double mProjectRate
 
double mSampleRate
 
wxWeakRef< NotifyingSelectedRegionmpSelectedRegion {}
 
WaveTrackFactorymFactory
 
std::shared_ptr< TrackListmOutputTracks
 
double mT0
 
double mT1
 
wxArrayString mPresetNames
 
wxArrayString mPresetValues
 
int mPass
 
wxDialog * mUIDialog
 
wxWindow * mUIParent
 
int mUIResultID
 
unsigned mUIFlags
 
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 214 of file BassTreble.cpp.

215 {
216  return (mBass == 0.0 && mTreble == 0.0 && mGain == 0.0);
217 }

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 397 of file BassTreble.cpp.

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

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 181 of file BassTreble.cpp.

181  {
182  S.SHUTTLE_PARAM( mBass, Bass );
183  S.SHUTTLE_PARAM( mTreble, Treble );
184  S.SHUTTLE_PARAM( mGain, Gain );
185  S.SHUTTLE_PARAM( mLink, Link );
186  return true;
187 }

References mBass, mGain, mLink, and mTreble.

◆ DoFilter()

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

Definition at line 425 of file BassTreble.cpp.

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

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 EffectClientInterface.

Definition at line 125 of file BassTreble.cpp.

126 {
127  return 1;
128 }

◆ GetAudioOutCount()

unsigned EffectBassTreble::GetAudioOutCount ( )
overridevirtual

Implements EffectClientInterface.

Definition at line 130 of file BassTreble.cpp.

131 {
132  return 1;
133 }

◆ GetAutomationParameters()

bool EffectBassTreble::GetAutomationParameters ( CommandParameters parms)
overridevirtual

Implements EffectClientInterface.

Definition at line 189 of file BassTreble.cpp.

190 {
191  parms.Write(KEY_Bass, mBass);
192  parms.Write(KEY_Treble, mTreble);
193  parms.Write(KEY_Gain, mGain);
194  parms.Write(KEY_Link, mLink);
195 
196  return true;
197 }

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

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 318 of file BassTreble.cpp.

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

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 359 of file BassTreble.cpp.

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

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

Reimplemented from Effect.

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 484 of file BassTreble.cpp.

485 {
486  double oldBass = mBass;
487  mBass = (double) evt.GetInt() / SCL_Bass;
488  mBassT->GetValidator()->TransferToWindow();
489 
490  if (mLink) UpdateGain(oldBass, kBass);
491  EnableApply(mUIParent->Validate());
492 }

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 448 of file BassTreble.cpp.

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

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 504 of file BassTreble.cpp.

505 {
506  mGain = (double) evt.GetInt() / SCL_Gain;
507  mGainT->GetValidator()->TransferToWindow();
508 
509  EnableApply(mUIParent->Validate());
510 }

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 474 of file BassTreble.cpp.

475 {
476  if (!EnableApply(mUIParent->TransferDataFromWindow()))
477  {
478  return;
479  }
480 
481  mGainS->SetValue((int) (mGain * SCL_Gain));
482 }

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 512 of file BassTreble.cpp.

513 {
514  mLink = mLinkCheckBox->GetValue();
515 }

References mLink, and mLinkCheckBox.

◆ OnTrebleSlider()

void EffectBassTreble::OnTrebleSlider ( wxCommandEvent &  evt)
private

Definition at line 494 of file BassTreble.cpp.

495 {
496  double oldTreble = mTreble;
497  mTreble = (double) evt.GetInt() / SCL_Treble;
498  mTrebleT->GetValidator()->TransferToWindow();
499 
500  if (mLink) UpdateGain(oldTreble, kTreble);
501  EnableApply(mUIParent->Validate());
502 }

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 461 of file BassTreble.cpp.

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

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 222 of file BassTreble.cpp.

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

References ShuttleGuiBase::AddCheckBox(), ShuttleGuiBase::AddSlider(), ShuttleGui::AddSpace(), ShuttleGuiBase::EndMultiColumn(), ShuttleGuiBase::EndStatic(), ShuttleGui::Id(), ID_Bass, ID_Gain, ID_Link, ID_Treble, mBass, mBassS, mBassT, mGain, mGainS, mGainT, mLinkCheckBox, mTreble, mTrebleS, mTrebleT, ShuttleGui::Name(), ShuttleGuiBase::SetBorder(), ShuttleGuiBase::SetStretchyCol(), ShuttleGuiBase::StartMultiColumn(), ShuttleGuiBase::StartStatic(), ShuttleGui::Validator(), XO, and XXO.

Here is the call graph for this function:

◆ ProcessBlock()

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

Implements EffectClientInterface.

Definition at line 142 of file BassTreble.cpp.

143 {
144  return InstanceProcess(mMaster, inBlock, outBlock, blockLen);
145 }

References InstanceProcess(), and mMaster.

Here is the call graph for this function:

◆ ProcessInitialize()

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

Implements EffectClientInterface.

Definition at line 135 of file BassTreble.cpp.

136 {
138 
139  return true;
140 }

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

Here is the call graph for this function:

◆ RealtimeAddProcessor()

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

Implements EffectClientInterface.

Definition at line 156 of file BassTreble.cpp.

157 {
158  EffectBassTrebleState slave;
159 
160  InstanceInit(slave, sampleRate);
161 
162  mSlaves.push_back(slave);
163 
164  return true;
165 }

References InstanceInit(), and mSlaves.

Here is the call graph for this function:

◆ RealtimeFinalize()

bool EffectBassTreble::RealtimeFinalize ( )
overridevirtual

Implements EffectClientInterface.

Definition at line 167 of file BassTreble.cpp.

168 {
169  mSlaves.clear();
170 
171  return true;
172 }

References mSlaves.

◆ RealtimeInitialize()

bool EffectBassTreble::RealtimeInitialize ( )
overridevirtual

Implements EffectClientInterface.

Definition at line 147 of file BassTreble.cpp.

148 {
149  SetBlockSize(512);
150 
151  mSlaves.clear();
152 
153  return true;
154 }

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 EffectClientInterface.

Definition at line 174 of file BassTreble.cpp.

178 {
179  return InstanceProcess(mSlaves[group], inbuf, outbuf, numSamples);
180 }

References InstanceProcess(), and mSlaves.

Here is the call graph for this function:

◆ SetAutomationParameters()

bool EffectBassTreble::SetAutomationParameters ( CommandParameters parms)
overridevirtual

Implements EffectClientInterface.

Definition at line 199 of file BassTreble.cpp.

200 {
201  ReadAndVerifyDouble(Bass);
202  ReadAndVerifyDouble(Treble);
203  ReadAndVerifyDouble(Gain);
204  ReadAndVerifyBool(Link);
205 
206  mBass = Bass;
207  mTreble = Treble;
208  mGain = Gain;
209  mLink = Link;
210 
211  return true;
212 }

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

◆ SupportsRealtime()

bool EffectBassTreble::SupportsRealtime ( )
overridevirtual

Implements EffectDefinitionInterface.

Definition at line 113 of file BassTreble.cpp.

114 {
115 #if defined(EXPERIMENTAL_REALTIME_AUDACITY_EFFECTS)
116  return true;
117 #else
118  return false;
119 #endif
120 }

◆ TransferDataFromWindow()

bool EffectBassTreble::TransferDataFromWindow ( )
overridevirtual

Reimplemented from Effect.

Definition at line 305 of file BassTreble.cpp.

306 {
307  if (!mUIParent->Validate() || !mUIParent->TransferDataFromWindow())
308  {
309  return false;
310  }
311 
312  return true;
313 }

References Effect::mUIParent.

◆ TransferDataToWindow()

bool EffectBassTreble::TransferDataToWindow ( )
overridevirtual

Reimplemented from Effect.

Definition at line 290 of file BassTreble.cpp.

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

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

◆ UpdateGain()

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

Definition at line 517 of file BassTreble.cpp.

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

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:59
DB_TO_LINEAR
const double MIN_Threshold_Linear DB_TO_LINEAR(MIN_Threshold_dB)
ShuttleGuiBase::AddCheckBox
wxCheckBox * AddCheckBox(const TranslatableString &Prompt, bool Selected)
Definition: ShuttleGui.cpp:309
Effect::SetLinearEffectFlag
void SetLinearEffectFlag(bool linearEffectFlag)
Definition: Effect.cpp:2001
Effect::EnableApply
virtual bool EnableApply(bool enable=true)
Definition: Effect.cpp:1926
EffectBassTrebleState::yn1Bass
double yn1Bass
Definition: BassTreble.h:32
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
ShuttleGui::AddSpace
wxSizerItem * AddSpace(int width, int height, int prop=0)
Definition: ShuttleGui.cpp:2459
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
ShuttleGuiBase::EndMultiColumn
void EndMultiColumn()
Definition: ShuttleGui.cpp:1238
EffectBassTrebleState::bass
double bass
Definition: BassTreble.h:27
EffectBassTrebleState::samplerate
float samplerate
Definition: BassTreble.h:25
EffectBassTrebleState::hzTreble
double hzTreble
Definition: BassTreble.h:29
ShuttleGui::Id
ShuttleGui & Id(int id)
Definition: ShuttleGui.cpp:2274
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:318
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:425
ID_Gain
@ ID_Gain
Definition: BassTreble.cpp:41
EffectBassTreble::mGain
double mGain
Definition: BassTreble.h:108
ShuttleGuiBase::StartMultiColumn
void StartMultiColumn(int nCols, int PositionFlags=wxALIGN_LEFT)
Definition: ShuttleGui.cpp:1229
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
ShuttleGui::Validator
ShuttleGui & Validator(const Factory &f)
Definition: ShuttleGui.h:678
EffectBassTrebleState::yn1Treble
double yn1Treble
Definition: BassTreble.h:33
EffectBassTrebleState::xn1Bass
double xn1Bass
Definition: BassTreble.h:32
ReadAndVerifyDouble
#define ReadAndVerifyDouble(name)
Definition: Effect.h:633
ShuttleGuiBase::AddSlider
wxSlider * AddSlider(const TranslatableString &Prompt, int pos, int Max, int Min=0)
Definition: ShuttleGui.cpp:589
EffectBassTrebleState::a1Treble
double a1Treble
Definition: BassTreble.h:31
EffectBassTrebleState::xn2Bass
double xn2Bass
Definition: BassTreble.h:32
ShuttleGuiBase::StartStatic
wxStaticBox * StartStatic(const TranslatableString &Str, int iProp=0)
Definition: ShuttleGui.cpp:893
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
ShuttleGui::Name
ShuttleGui & Name(const TranslatableString &name)
Definition: ShuttleGui.h:663
Effect::mSampleRate
double mSampleRate
Definition: Effect.h:460
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:397
Effect::mUIParent
wxWindow * mUIParent
Definition: Effect.h:478
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:517
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
ShuttleGuiBase::SetBorder
void SetBorder(int Border)
Definition: ShuttleGui.h:489
EffectBassTreble::InstanceProcess
size_t InstanceProcess(EffectBassTrebleState &data, float **inBlock, float **outBlock, size_t blockLen)
Definition: BassTreble.cpp:359
EffectBassTrebleState::a0Bass
double a0Bass
Definition: BassTreble.h:30
EffectBassTrebleState::hzBass
double hzBass
Definition: BassTreble.h:29
ShuttleGuiBase::EndStatic
void EndStatic()
Definition: ShuttleGui.cpp:922
ShuttleGuiBase::SetStretchyCol
void SetStretchyCol(int i)
Used to modify an already placed FlexGridSizer to make a column stretchy.
Definition: ShuttleGui.cpp:202
Effect::SetBlockSize
size_t SetBlockSize(size_t maxBlockSize) override
Definition: Effect.cpp:317
EffectBassTreble::mMaster
EffectBassTrebleState mMaster
Definition: BassTreble.h:103
EffectBassTrebleState::treble
double treble
Definition: BassTreble.h:26
ReadAndVerifyBool
#define ReadAndVerifyBool(name)
Definition: Effect.h:635
ID_Bass
@ ID_Bass
Definition: BassTreble.cpp:39