Audacity  2.2.2
Public Member Functions | 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:
Effect EffectClientInterface EffectUIClientInterface EffectHostInterface EffectDefinitionInterface ConfigClientInterface IdentInterface ParamsInterface

Public Member Functions

 EffectBassTreble ()
 
virtual ~EffectBassTreble ()
 
IdentInterfaceSymbol GetSymbol () override
 
wxString GetDescription () override
 
wxString 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 ()
 
wxString GetPath () override
 
IdentInterfaceSymbol GetSymbol () override
 
IdentInterfaceSymbol GetVendor () override
 
wxString GetVersion () override
 
wxString GetDescription () override
 
EffectType GetType () override
 
IdentInterfaceSymbol GetFamilyId () 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
 
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, bool forceModal=false) override
 
bool GetAutomationParameters (CommandParameters &parms) override
 
bool SetAutomationParameters (CommandParameters &parms) override
 
bool LoadUserPreset (const wxString &name) override
 
bool SaveUserPreset (const wxString &name) override
 
wxArrayString GetFactoryPresets () override
 
bool LoadFactoryPreset (int id) override
 
bool LoadFactoryDefaults () override
 
void SetHostUI (EffectUIHostInterface *host) override
 
bool PopulateUI (wxWindow *parent) override
 
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
 
NumericFormatId GetDurationFormat () override
 
virtual NumericFormatId GetSelectionFormat ()
 
void SetDuration (double duration) override
 
bool Apply () override
 
void Preview () override
 
wxDialog * CreateUI (wxWindow *parent, EffectUIClientInterface *client) override
 
wxString GetUserPresetsGroup (const wxString &name) override
 
wxString GetCurrentSettingsGroup () override
 
wxString GetFactoryDefaultsGroup () override
 
virtual wxString GetSavedStateGroup ()
 
bool HasSharedConfigGroup (const wxString &group) override
 
bool GetSharedConfigSubgroups (const wxString &group, wxArrayString &subgroups) override
 
bool GetSharedConfig (const wxString &group, const wxString &key, wxString &value, const wxString &defval=wxEmptyString) override
 
bool GetSharedConfig (const wxString &group, const wxString &key, int &value, int defval=0) override
 
bool GetSharedConfig (const wxString &group, const wxString &key, bool &value, bool defval=false) override
 
bool GetSharedConfig (const wxString &group, const wxString &key, float &value, float defval=0.0) override
 
bool GetSharedConfig (const wxString &group, const wxString &key, double &value, double defval=0.0) override
 
bool SetSharedConfig (const wxString &group, const wxString &key, const wxString &value) override
 
bool SetSharedConfig (const wxString &group, const wxString &key, const int &value) override
 
bool SetSharedConfig (const wxString &group, const wxString &key, const bool &value) override
 
bool SetSharedConfig (const wxString &group, const wxString &key, const float &value) override
 
bool SetSharedConfig (const wxString &group, const wxString &key, const double &value) override
 
bool RemoveSharedConfigSubgroup (const wxString &group) override
 
bool RemoveSharedConfig (const wxString &group, const wxString &key) override
 
bool HasPrivateConfigGroup (const wxString &group) override
 
bool GetPrivateConfigSubgroups (const wxString &group, wxArrayString &subgroups) override
 
bool GetPrivateConfig (const wxString &group, const wxString &key, wxString &value, const wxString &defval=wxEmptyString) override
 
bool GetPrivateConfig (const wxString &group, const wxString &key, int &value, int defval=0) override
 
bool GetPrivateConfig (const wxString &group, const wxString &key, bool &value, bool defval=false) override
 
bool GetPrivateConfig (const wxString &group, const wxString &key, float &value, float defval=0.0) override
 
bool GetPrivateConfig (const wxString &group, const wxString &key, double &value, double defval=0.0) override
 
bool SetPrivateConfig (const wxString &group, const wxString &key, const wxString &value) override
 
bool SetPrivateConfig (const wxString &group, const wxString &key, const int &value) override
 
bool SetPrivateConfig (const wxString &group, const wxString &key, const bool &value) override
 
bool SetPrivateConfig (const wxString &group, const wxString &key, const float &value) override
 
bool SetPrivateConfig (const wxString &group, const wxString &key, const double &value) override
 
bool RemovePrivateConfigSubgroup (const wxString &group) override
 
bool RemovePrivateConfig (const wxString &group, const wxString &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 wxArrayString GetUserPresets ()
 
virtual bool HasCurrentSettings ()
 
virtual bool HasFactoryDefaults ()
 
virtual wxString GetPreset (wxWindow *parent, const wxString &parms)
 
virtual wxString HelpPage ()
 
virtual bool IsBatchProcessing ()
 
virtual void SetBatchProcessing (bool start)
 
void SetPresetParameters (const wxArrayString *Names, const wxArrayString *Values)
 
bool DoEffect (wxWindow *parent, double projectRate, TrackList *list, TrackFactory *factory, SelectedRegion *selectedRegion, bool shouldPrompt=true)
 
bool Delegate (Effect &delegate, wxWindow *parent, bool shouldPrompt)
 
bool RealtimeAddProcessor (int group, unsigned chans, float rate)
 
size_t RealtimeProcess (int group, unsigned chans, float **inbuf, float **outbuf, size_t numSamples)
 
bool IsRealtimeActive ()
 
virtual bool IsHidden ()
 
int MessageBox (const wxString &message, long style=DefaultMessageBoxStyle, const wxString &titleStr=wxString{})
 
- Public Member Functions inherited from EffectClientInterface
virtual ~EffectClientInterface ()
 
- Public Member Functions inherited from EffectDefinitionInterface
virtual ~EffectDefinitionInterface ()
 
- Public Member Functions inherited from IdentInterface
virtual ~IdentInterface ()
 
const wxString & GetTranslatedName ()
 
- Public Member Functions inherited from ParamsInterface
virtual ~ParamsInterface ()
 
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 ()
 

Private Member Functions

void InstanceInit (EffectBassTrebleState &data, float sampleRate)
 
size_t InstanceProcess (EffectBassTrebleState &data, float **inBlock, float **outBlock, size_t blockLen)
 
void Coefficents (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
< EffectBassTrebleState
mSlaves
 
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 }
 
- Protected Member Functions inherited from Effect
virtual bool Init ()
 
virtual bool PromptUser (wxWindow *parent)
 
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)
 
bool TrackProgress (int whichTrack, double frac, const wxString &=wxEmptyString)
 
bool TrackGroupProgress (int whichGroup, double frac, const wxString &=wxEmptyString)
 
int GetNumWaveTracks ()
 
int GetNumWaveGroups ()
 
void GetSamples (const WaveTrack *track, sampleCount *start, sampleCount *len)
 
void SetLinearEffectFlag (bool linearEffectFlag)
 
void SetPreviewFullSelectionFlag (bool previewDurationFlag)
 
bool IsPreviewing ()
 
void IncludeNotSelectedPreviewTracks (bool includeNotSelected)
 
void CopyInputTracks ()
 
void CopyInputTracks (int trackType)
 
std::shared_ptr
< AddedAnalysisTrack
AddAnalysisTrack (const wxString &name=wxString())
 
ModifiedAnalysisTrack ModifyAnalysisTrack (const LabelTrack *pOrigTrack, const wxString &name=wxString())
 
void ReplaceProcessedTracks (const bool bGoodResult)
 
TrackAddToOutputTracks (std::unique_ptr< Track > &&t)
 
TrackListinputTracks () const
 
- Protected Attributes inherited from Effect
ProgressDialogmProgress
 
double mProjectRate
 
double mSampleRate
 
SelectedRegionmpSelectedRegion {}
 
TrackFactorymFactory
 
std::shared_ptr< TrackListmOutputTracks
 
double mT0
 
double mT1
 
double mF0
 
double mF1
 
wxArrayString mPresetNames
 
wxArrayString mPresetValues
 
int mPass
 
wxDialog * mUIDialog
 
wxWindow * mUIParent
 
int mUIResultID
 
sampleCount mSampleCnt
 
int mOutputTracksType
 

Detailed Description

A high shelf and low shelf filter.

Definition at line 42 of file BassTreble.h.

Constructor & Destructor Documentation

EffectBassTreble::EffectBassTreble ( )

Definition at line 66 of file BassTreble.cpp.

67 {
68  mBass = DEF_Bass;
69  mTreble = DEF_Treble;
70  mGain = DEF_Gain;
71  mLink = DEF_Link;
72 
73  SetLinearEffectFlag(true);
74 }
void SetLinearEffectFlag(bool linearEffectFlag)
Definition: Effect.cpp:1961
EffectBassTreble::~EffectBassTreble ( )
virtual

Definition at line 76 of file BassTreble.cpp.

77 {
78 }

Member Function Documentation

bool EffectBassTreble::CheckWhetherSkipEffect ( )
overridevirtual

Reimplemented from Effect.

Definition at line 205 of file BassTreble.cpp.

References mBass, mGain, and mTreble.

206 {
207  return (mBass == 0.0 && mTreble == 0.0 && mGain == 0.0);
208 }
void EffectBassTreble::Coefficents ( 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 385 of file BassTreble.cpp.

References kBass, and M_PI.

Referenced by InstanceProcess().

388 {
389  double w = 2 * M_PI * hz / samplerate;
390  double a = exp(log(10.0) * gain / 40);
391  double b = sqrt((a * a + 1) / slope - (pow((a - 1), 2)));
392 
393  if (type == kBass)
394  {
395  b0 = a * ((a + 1) - (a - 1) * cos(w) + b * sin(w));
396  b1 = 2 * a * ((a - 1) - (a + 1) * cos(w));
397  b2 = a * ((a + 1) - (a - 1) * cos(w) - b * sin(w));
398  a0 = ((a + 1) + (a - 1) * cos(w) + b * sin(w));
399  a1 = -2 * ((a - 1) + (a + 1) * cos(w));
400  a2 = (a + 1) + (a - 1) * cos(w) - b * sin(w);
401  }
402  else //assumed kTreble
403  {
404  b0 = a * ((a + 1) + (a - 1) * cos(w) + b * sin(w));
405  b1 = -2 * a * ((a - 1) + (a + 1) * cos(w));
406  b2 = a * ((a + 1) + (a - 1) * cos(w) - b * sin(w));
407  a0 = ((a + 1) - (a - 1) * cos(w) + b * sin(w));
408  a1 = 2 * ((a - 1) - (a + 1) * cos(w));
409  a2 = (a + 1) - (a - 1) * cos(w) - b * sin(w);
410  }
411 }
#define M_PI
Definition: Distortion.cpp:28
bool EffectBassTreble::DefineParams ( ShuttleParams S)
override

Definition at line 172 of file BassTreble.cpp.

References mBass, mGain, mLink, and mTreble.

172  {
173  S.SHUTTLE_PARAM( mBass, Bass );
174  S.SHUTTLE_PARAM( mTreble, Treble );
175  S.SHUTTLE_PARAM( mGain, Gain );
176  S.SHUTTLE_PARAM( mLink, Link );
177  return true;
178 }
float EffectBassTreble::DoFilter ( EffectBassTrebleState data,
float  in 
)
private

Definition at line 413 of file BassTreble.cpp.

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().

414 {
415  // Bass filter
416  float out = (data.b0Bass * in + data.b1Bass * data.xn1Bass + data.b2Bass * data.xn2Bass -
417  data.a1Bass * data.yn1Bass - data.a2Bass * data.yn2Bass) / data.a0Bass;
418  data.xn2Bass = data.xn1Bass;
419  data.xn1Bass = in;
420  data.yn2Bass = data.yn1Bass;
421  data.yn1Bass = out;
422 
423  // Treble filter
424  in = out;
425  out = (data.b0Treble * in + data.b1Treble * data.xn1Treble + data.b2Treble * data.xn2Treble -
426  data.a1Treble * data.yn1Treble - data.a2Treble * data.yn2Treble) / data.a0Treble;
427  data.xn2Treble = data.xn1Treble;
428  data.xn1Treble = in;
429  data.yn2Treble = data.yn1Treble;
430  data.yn1Treble = out;
431 
432  return out;
433 }
unsigned EffectBassTreble::GetAudioInCount ( )
overridevirtual

Implements EffectClientInterface.

Definition at line 116 of file BassTreble.cpp.

117 {
118  return 1;
119 }
unsigned EffectBassTreble::GetAudioOutCount ( )
overridevirtual

Implements EffectClientInterface.

Definition at line 121 of file BassTreble.cpp.

122 {
123  return 1;
124 }
bool EffectBassTreble::GetAutomationParameters ( CommandParameters parms)
overridevirtual

Implements EffectClientInterface.

Definition at line 180 of file BassTreble.cpp.

References mBass, mGain, mLink, and mTreble.

181 {
182  parms.Write(KEY_Bass, mBass);
183  parms.Write(KEY_Treble, mTreble);
184  parms.Write(KEY_Gain, mGain);
185  parms.Write(KEY_Link, mLink);
186 
187  return true;
188 }
wxString EffectBassTreble::GetDescription ( )
overridevirtual

Implements IdentInterface.

Definition at line 87 of file BassTreble.cpp.

References _().

88 {
89  return _("Simple tone control effect");
90 }
_("Move Track &Down")+wxT("\t")+(GetActiveProject() -> GetCommandManager() ->GetKeyFromName(wxT("TrackMoveDown")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveTopID, _("Move Track to &Top")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveTop")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveBottomID, _("Move Track to &Bottom")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveBottom")).Raw()), OnMoveTrack)#define SET_TRACK_NAME_PLUGIN_SYMBOLclass SetTrackNameCommand:public AudacityCommand
IdentInterfaceSymbol EffectBassTreble::GetSymbol ( )
overridevirtual

Implements IdentInterface.

Definition at line 82 of file BassTreble.cpp.

References BASSTREBLE_PLUGIN_SYMBOL.

83 {
85 }
#define BASSTREBLE_PLUGIN_SYMBOL
Definition: BassTreble.h:26
EffectType EffectBassTreble::GetType ( )
overridevirtual

Implements EffectDefinitionInterface.

Definition at line 99 of file BassTreble.cpp.

References EffectTypeProcess.

100 {
101  return EffectTypeProcess;
102 }
void EffectBassTreble::InstanceInit ( EffectBassTrebleState data,
float  sampleRate 
)
private

Definition at line 306 of file BassTreble.cpp.

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().

307 {
308  data.samplerate = sampleRate;
309  data.slope = 0.4f; // same slope for both filters
310  data.hzBass = 250.0f; // could be tunable in a more advanced version
311  data.hzTreble = 4000.0f; // could be tunable in a more advanced version
312 
313  data.a0Bass = 1;
314  data.a1Bass = 0;
315  data.a2Bass = 0;
316  data.b0Bass = 0;
317  data.b1Bass = 0;
318  data.b2Bass = 0;
319 
320  data.a0Treble = 1;
321  data.a1Treble = 0;
322  data.a2Treble = 0;
323  data.b0Treble = 0;
324  data.b1Treble = 0;
325  data.b2Treble = 0;
326 
327  data.xn1Bass = 0;
328  data.xn2Bass = 0;
329  data.yn1Bass = 0;
330  data.yn2Bass = 0;
331 
332  data.xn1Treble = 0;
333  data.xn2Treble = 0;
334  data.yn1Treble = 0;
335  data.yn2Treble = 0;
336 
337  data.bass = -1;
338  data.treble = -1;
339  data.gain = DB_TO_LINEAR(mGain);
340 
341 }
const double MIN_Threshold_Linear DB_TO_LINEAR(MIN_Threshold_dB)
size_t EffectBassTreble::InstanceProcess ( EffectBassTrebleState data,
float **  inBlock,
float **  outBlock,
size_t  blockLen 
)
private

Definition at line 347 of file BassTreble.cpp.

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, Coefficents(), 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().

351 {
352  float *ibuf = inBlock[0];
353  float *obuf = outBlock[0];
354 
355  // Set value to ensure correct rounding
356  double oldBass = DB_TO_LINEAR(mBass);
357  double oldTreble = DB_TO_LINEAR(mTreble);
358 
359  data.gain = DB_TO_LINEAR(mGain);
360 
361  // Compute coefficents of the low shelf biquand IIR filter
362  if (data.bass != oldBass)
363  Coefficents(data.hzBass, data.slope, mBass, data.samplerate, kBass,
364  data.a0Bass, data.a1Bass, data.a2Bass,
365  data.b0Bass, data.b1Bass, data.b2Bass);
366 
367  // Compute coefficents of the high shelf biquand IIR filter
368  if (data.treble != oldTreble)
369  Coefficents(data.hzTreble, data.slope, mTreble, data.samplerate, kTreble,
370  data.a0Treble, data.a1Treble, data.a2Treble,
371  data.b0Treble, data.b1Treble, data.b2Treble);
372 
373  for (decltype(blockLen) i = 0; i < blockLen; i++) {
374  obuf[i] = DoFilter(data, ibuf[i]) * data.gain;
375  }
376 
377  return blockLen;
378 }
float DoFilter(EffectBassTrebleState &data, float in)
Definition: BassTreble.cpp:413
void Coefficents(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:385
const double MIN_Threshold_Linear DB_TO_LINEAR(MIN_Threshold_dB)
wxString EffectBassTreble::ManualPage ( )
overridevirtual

Reimplemented from Effect.

Definition at line 92 of file BassTreble.cpp.

93 {
94  return wxT("Bass_and_Treble");
95 }
void EffectBassTreble::OnBassSlider ( wxCommandEvent &  evt)
private

Definition at line 472 of file BassTreble.cpp.

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

473 {
474  double oldBass = mBass;
475  mBass = (double) evt.GetInt() / SCL_Bass;
476  mBassT->GetValidator()->TransferToWindow();
477 
478  if (mLink) UpdateGain(oldBass, kBass);
479  EnableApply(mUIParent->Validate());
480 }
void UpdateGain(double oldVal, int control)
Definition: BassTreble.cpp:505
wxWindow * mUIParent
Definition: Effect.h:472
wxTextCtrl * mBassT
Definition: BassTreble.h:119
virtual bool EnableApply(bool enable=true)
Definition: Effect.cpp:1886
void EffectBassTreble::OnBassText ( wxCommandEvent &  evt)
private

Definition at line 436 of file BassTreble.cpp.

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

437 {
438  double oldBass = mBass;
439 
440  if (!EnableApply(mUIParent->TransferDataFromWindow()))
441  {
442  return;
443  }
444 
445  if (mLink) UpdateGain(oldBass, kBass);
446  mBassS->SetValue((int) (mBass * SCL_Bass));
447 }
void UpdateGain(double oldVal, int control)
Definition: BassTreble.cpp:505
wxWindow * mUIParent
Definition: Effect.h:472
wxSlider * mBassS
Definition: BassTreble.h:115
virtual bool EnableApply(bool enable=true)
Definition: Effect.cpp:1886
void EffectBassTreble::OnGainSlider ( wxCommandEvent &  evt)
private

Definition at line 492 of file BassTreble.cpp.

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

493 {
494  mGain = (double) evt.GetInt() / SCL_Gain;
495  mGainT->GetValidator()->TransferToWindow();
496 
497  EnableApply(mUIParent->Validate());
498 }
wxTextCtrl * mGainT
Definition: BassTreble.h:121
wxWindow * mUIParent
Definition: Effect.h:472
virtual bool EnableApply(bool enable=true)
Definition: Effect.cpp:1886
void EffectBassTreble::OnGainText ( wxCommandEvent &  evt)
private

Definition at line 462 of file BassTreble.cpp.

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

463 {
464  if (!EnableApply(mUIParent->TransferDataFromWindow()))
465  {
466  return;
467  }
468 
469  mGainS->SetValue((int) (mGain * SCL_Gain));
470 }
wxSlider * mGainS
Definition: BassTreble.h:117
wxWindow * mUIParent
Definition: Effect.h:472
virtual bool EnableApply(bool enable=true)
Definition: Effect.cpp:1886
void EffectBassTreble::OnLinkCheckbox ( wxCommandEvent &  evt)
private

Definition at line 500 of file BassTreble.cpp.

References mLink, and mLinkCheckBox.

501 {
502  mLink = mLinkCheckBox->GetValue();
503 }
wxCheckBox * mLinkCheckBox
Definition: BassTreble.h:123
void EffectBassTreble::OnTrebleSlider ( wxCommandEvent &  evt)
private

Definition at line 482 of file BassTreble.cpp.

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

483 {
484  double oldTreble = mTreble;
485  mTreble = (double) evt.GetInt() / SCL_Treble;
486  mTrebleT->GetValidator()->TransferToWindow();
487 
488  if (mLink) UpdateGain(oldTreble, kTreble);
489  EnableApply(mUIParent->Validate());
490 }
void UpdateGain(double oldVal, int control)
Definition: BassTreble.cpp:505
wxTextCtrl * mTrebleT
Definition: BassTreble.h:120
wxWindow * mUIParent
Definition: Effect.h:472
virtual bool EnableApply(bool enable=true)
Definition: Effect.cpp:1886
void EffectBassTreble::OnTrebleText ( wxCommandEvent &  evt)
private

Definition at line 449 of file BassTreble.cpp.

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

450 {
451  double oldTreble = mTreble;
452 
453  if (!EnableApply(mUIParent->TransferDataFromWindow()))
454  {
455  return;
456  }
457 
458  if (mLink) UpdateGain(oldTreble, kTreble);
459  mTrebleS->SetValue((int) (mTreble * SCL_Treble));
460 }
wxSlider * mTrebleS
Definition: BassTreble.h:116
void UpdateGain(double oldVal, int control)
Definition: BassTreble.cpp:505
wxWindow * mUIParent
Definition: Effect.h:472
virtual bool EnableApply(bool enable=true)
Definition: Effect.cpp:1886
void EffectBassTreble::PopulateOrExchange ( ShuttleGui S)
overridevirtual

Reimplemented from Effect.

Definition at line 213 of file BassTreble.cpp.

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

214 {
215  S.SetBorder(5);
216  S.AddSpace(0, 5);
217 
218  S.StartStatic(_("Tone controls"));
219  {
220  S.StartMultiColumn(3, wxEXPAND);
221  {
222  S.SetStretchyCol(2);
223 
224  // Bass control
225  FloatingPointValidator<double> vldBass(1, &mBass);
226  vldBass.SetRange(MIN_Bass, MAX_Bass);
227  mBassT = S.Id(ID_Bass).AddTextBox(_("Ba&ss (dB):"), wxT(""), 10);
228  mBassT->SetName(_("Bass (dB):"));
229  mBassT->SetValidator(vldBass);
230 
231  S.SetStyle(wxSL_HORIZONTAL);
232  mBassS = S.Id(ID_Bass).AddSlider( {}, 0, MAX_Bass * SCL_Bass, MIN_Bass * SCL_Bass);
233  mBassS->SetName(_("Bass"));
234 
235  // Treble control
236  FloatingPointValidator<double> vldTreble(1, &mTreble);
237  vldTreble.SetRange(MIN_Treble, MAX_Treble);
238  mTrebleT = S.Id(ID_Treble).AddTextBox(_("&Treble (dB):"), wxT(""), 10);
239  mTrebleT->SetValidator(vldTreble);
240 
241  S.SetStyle(wxSL_HORIZONTAL);
242  mTrebleS = S.Id(ID_Treble).AddSlider( {}, 0, MAX_Treble * SCL_Treble, MIN_Treble * SCL_Treble);
243  mTrebleS->SetName(_("Treble"));
244  }
245  S.EndMultiColumn();
246  }
247  S.EndStatic();
248 
249  S.StartStatic(_("Output"));
250  {
251  S.StartMultiColumn(3, wxEXPAND);
252  {
253  S.SetStretchyCol(2);
254 
255  // Gain control
256  FloatingPointValidator<double> vldGain(1, &mGain);
257  vldGain.SetRange(MIN_Gain, MAX_Gain);
258  mGainT = S.Id(ID_Gain).AddTextBox(_("&Volume (dB):"), wxT(""), 10);
259  mGainT->SetValidator(vldGain);
260 
261  S.SetStyle(wxSL_HORIZONTAL);
262  mGainS = S.Id(ID_Gain).AddSlider( {}, 0, MAX_Gain * SCL_Gain, MIN_Gain * SCL_Gain);
263  mGainS->SetName(_("Level"));
264  }
265  S.EndMultiColumn();
266 
267  S.StartMultiColumn(2, wxCENTER);
268  {
269  // Link checkbox
270  mLinkCheckBox = S.Id(ID_Link).AddCheckBox(_("&Link Volume control to Tone controls"),
271  DEF_Link ? wxT("true") : wxT("false"));
272  }
273  S.EndMultiColumn();
274  }
275  S.EndStatic();
276 }
wxTextCtrl * mGainT
Definition: BassTreble.h:121
wxSlider * mGainS
Definition: BassTreble.h:117
void EndMultiColumn()
wxSlider * mTrebleS
Definition: BassTreble.h:116
wxTextCtrl * mTrebleT
Definition: BassTreble.h:120
wxTextCtrl * AddTextBox(const wxString &Caption, const wxString &Value, const int nChars)
Definition: ShuttleGui.cpp:540
wxCheckBox * AddCheckBox(const wxString &Prompt, const wxString &Selected)
Definition: ShuttleGui.cpp:298
void StartMultiColumn(int nCols, int PositionFlags=wxALIGN_LEFT)
ShuttleGui & Id(int id)
void SetStyle(int Style)
Definition: ShuttleGui.h:287
_("Move Track &Down")+wxT("\t")+(GetActiveProject() -> GetCommandManager() ->GetKeyFromName(wxT("TrackMoveDown")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveTopID, _("Move Track to &Top")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveTop")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveBottomID, _("Move Track to &Bottom")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveBottom")).Raw()), OnMoveTrack)#define SET_TRACK_NAME_PLUGIN_SYMBOLclass SetTrackNameCommand:public AudacityCommand
wxSlider * mBassS
Definition: BassTreble.h:115
wxStaticBox * StartStatic(const wxString &Str, int iProp=0)
Definition: ShuttleGui.cpp:763
wxTextCtrl * mBassT
Definition: BassTreble.h:119
wxSizerItem * AddSpace(int width, int height)
wxCheckBox * mLinkCheckBox
Definition: BassTreble.h:123
void SetBorder(int Border)
Definition: ShuttleGui.h:286
void SetStretchyCol(int i)
Used to modify an already placed FlexGridSizer to make a column stretchy.
Definition: ShuttleGui.cpp:203
wxSlider * AddSlider(const wxString &Prompt, int pos, int Max, int Min=0)
Definition: ShuttleGui.cpp:497
size_t EffectBassTreble::ProcessBlock ( float **  inBlock,
float **  outBlock,
size_t  blockLen 
)
overridevirtual

Implements EffectClientInterface.

Definition at line 133 of file BassTreble.cpp.

References InstanceProcess(), and mMaster.

134 {
135  return InstanceProcess(mMaster, inBlock, outBlock, blockLen);
136 }
size_t InstanceProcess(EffectBassTrebleState &data, float **inBlock, float **outBlock, size_t blockLen)
Definition: BassTreble.cpp:347
EffectBassTrebleState mMaster
Definition: BassTreble.h:107
bool EffectBassTreble::ProcessInitialize ( sampleCount  totalLen,
ChannelNames  chanMap = NULL 
)
overridevirtual

Implements EffectClientInterface.

Definition at line 126 of file BassTreble.cpp.

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

127 {
129 
130  return true;
131 }
double mSampleRate
Definition: Effect.h:455
void InstanceInit(EffectBassTrebleState &data, float sampleRate)
Definition: BassTreble.cpp:306
EffectBassTrebleState mMaster
Definition: BassTreble.h:107
bool EffectBassTreble::RealtimeAddProcessor ( unsigned  numChannels,
float  sampleRate 
)
overridevirtual

Implements EffectClientInterface.

Definition at line 147 of file BassTreble.cpp.

References InstanceInit(), and mSlaves.

148 {
149  EffectBassTrebleState slave;
150 
151  InstanceInit(slave, sampleRate);
152 
153  mSlaves.push_back(slave);
154 
155  return true;
156 }
std::vector< EffectBassTrebleState > mSlaves
Definition: BassTreble.h:108
void InstanceInit(EffectBassTrebleState &data, float sampleRate)
Definition: BassTreble.cpp:306
bool EffectBassTreble::RealtimeFinalize ( )
overridevirtual

Implements EffectClientInterface.

Definition at line 158 of file BassTreble.cpp.

References mSlaves.

159 {
160  mSlaves.clear();
161 
162  return true;
163 }
std::vector< EffectBassTrebleState > mSlaves
Definition: BassTreble.h:108
bool EffectBassTreble::RealtimeInitialize ( )
overridevirtual

Implements EffectClientInterface.

Definition at line 138 of file BassTreble.cpp.

References mSlaves, and Effect::SetBlockSize().

139 {
140  SetBlockSize(512);
141 
142  mSlaves.clear();
143 
144  return true;
145 }
size_t SetBlockSize(size_t maxBlockSize) override
Definition: Effect.cpp:332
std::vector< EffectBassTrebleState > mSlaves
Definition: BassTreble.h:108
size_t EffectBassTreble::RealtimeProcess ( int  group,
float **  inbuf,
float **  outbuf,
size_t  numSamples 
)
overridevirtual

Implements EffectClientInterface.

Definition at line 165 of file BassTreble.cpp.

References InstanceProcess(), and mSlaves.

169 {
170  return InstanceProcess(mSlaves[group], inbuf, outbuf, numSamples);
171 }
std::vector< EffectBassTrebleState > mSlaves
Definition: BassTreble.h:108
size_t InstanceProcess(EffectBassTrebleState &data, float **inBlock, float **outBlock, size_t blockLen)
Definition: BassTreble.cpp:347
bool EffectBassTreble::SetAutomationParameters ( CommandParameters parms)
overridevirtual

Implements EffectClientInterface.

Definition at line 190 of file BassTreble.cpp.

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

191 {
192  ReadAndVerifyDouble(Bass);
193  ReadAndVerifyDouble(Treble);
194  ReadAndVerifyDouble(Gain);
195  ReadAndVerifyBool(Link);
196 
197  mBass = Bass;
198  mTreble = Treble;
199  mGain = Gain;
200  mLink = Link;
201 
202  return true;
203 }
#define ReadAndVerifyDouble(name)
Definition: Effect.h:798
#define ReadAndVerifyBool(name)
Definition: Effect.h:800
bool EffectBassTreble::SupportsRealtime ( )
overridevirtual

Implements EffectDefinitionInterface.

Definition at line 104 of file BassTreble.cpp.

105 {
106 #if defined(EXPERIMENTAL_REALTIME_AUDACITY_EFFECTS)
107  return true;
108 #else
109  return false;
110 #endif
111 }
bool EffectBassTreble::TransferDataFromWindow ( )
overridevirtual

Reimplemented from Effect.

Definition at line 293 of file BassTreble.cpp.

References Effect::mUIParent.

294 {
295  if (!mUIParent->Validate() || !mUIParent->TransferDataFromWindow())
296  {
297  return false;
298  }
299 
300  return true;
301 }
wxWindow * mUIParent
Definition: Effect.h:472
bool EffectBassTreble::TransferDataToWindow ( )
overridevirtual

Reimplemented from Effect.

Definition at line 278 of file BassTreble.cpp.

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

279 {
280  if (!mUIParent->TransferDataToWindow())
281  {
282  return false;
283  }
284 
285  mBassS->SetValue((int) (mBass * SCL_Bass));
286  mTrebleS->SetValue((int) mTreble *SCL_Treble);
287  mGainS->SetValue((int) mGain * SCL_Gain);
288  mLinkCheckBox->SetValue(mLink);
289 
290  return true;
291 }
wxSlider * mGainS
Definition: BassTreble.h:117
wxSlider * mTrebleS
Definition: BassTreble.h:116
wxWindow * mUIParent
Definition: Effect.h:472
wxSlider * mBassS
Definition: BassTreble.h:115
wxCheckBox * mLinkCheckBox
Definition: BassTreble.h:123
void EffectBassTreble::UpdateGain ( double  oldVal,
int  control 
)
private

Definition at line 505 of file BassTreble.cpp.

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

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

506 {
507  double newVal;
508  oldVal = (oldVal > 0)? oldVal / 2.0 : oldVal / 4.0;
509 
510  if (control == kBass)
511  newVal = (mBass > 0)? mBass / 2.0 : mBass / 4.0;
512  else
513  newVal = (mTreble > 0)? mTreble / 2.0 : mTreble / 4.0;
514 
515  mGain -= newVal - oldVal;
516  mGain = std::min(MAX_Gain, std::max(MIN_Gain, mGain));
517 
518  mGainS->SetValue(mGain);
519  mGainT->GetValidator()->TransferToWindow();
520 
521 }
wxTextCtrl * mGainT
Definition: BassTreble.h:121
wxSlider * mGainS
Definition: BassTreble.h:117
int min(int a, int b)

Member Data Documentation

double EffectBassTreble::mBass
private
wxSlider* EffectBassTreble::mBassS
private

Definition at line 115 of file BassTreble.h.

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

wxTextCtrl* EffectBassTreble::mBassT
private

Definition at line 119 of file BassTreble.h.

Referenced by OnBassSlider(), and PopulateOrExchange().

double EffectBassTreble::mGain
private
wxSlider* EffectBassTreble::mGainS
private

Definition at line 117 of file BassTreble.h.

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

wxTextCtrl* EffectBassTreble::mGainT
private

Definition at line 121 of file BassTreble.h.

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

bool EffectBassTreble::mLink
private
wxCheckBox* EffectBassTreble::mLinkCheckBox
private

Definition at line 123 of file BassTreble.h.

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

EffectBassTrebleState EffectBassTreble::mMaster
private

Definition at line 107 of file BassTreble.h.

Referenced by ProcessBlock(), and ProcessInitialize().

std::vector<EffectBassTrebleState> EffectBassTreble::mSlaves
private
double EffectBassTreble::mTreble
private
wxSlider* EffectBassTreble::mTrebleS
private

Definition at line 116 of file BassTreble.h.

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

wxTextCtrl* EffectBassTreble::mTrebleT
private

Definition at line 120 of file BassTreble.h.

Referenced by OnTrebleSlider(), and PopulateOrExchange().


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