Audacity  3.0.3
Public Member Functions | Static Public Attributes | Private Types | Private Member Functions | Private Attributes | Static Private Attributes | Friends | List of all members
EffectEqualization Class Reference

An Effect that modifies volume in different frequency bands. More...

#include <Equalization.h>

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

Public Member Functions

 EffectEqualization (int Options=kEqLegacy)
 
virtual ~EffectEqualization ()
 
ComponentInterfaceSymbol GetSymbol () override
 
TranslatableString GetDescription () override
 
ManualPageID ManualPage () override
 
EffectType GetType () override
 
bool DefineParams (ShuttleParams &S) override
 
bool GetAutomationParameters (CommandParameters &parms) override
 
bool SetAutomationParameters (CommandParameters &parms) override
 
bool LoadFactoryDefaults () override
 
RegistryPaths GetFactoryPresets () override
 
bool LoadFactoryPreset (int id) override
 
bool ValidateUI () override
 
bool Startup () override
 
bool Init () override
 
bool Process () override
 
bool CloseUI () override
 
void PopulateOrExchange (ShuttleGui &S) override
 
bool TransferDataToWindow () override
 
bool TransferDataFromWindow () override
 
- Public Member Functions inherited from Effect
 Effect ()
 
virtual ~Effect ()
 
PluginPath GetPath () override
 
VendorSymbol GetVendor () override
 
wxString GetVersion () 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 LoadUserPreset (const RegistryPath &name) override
 
bool SaveUserPreset (const RegistryPath &name) override
 
void SetHostUI (EffectUIHostInterface *host) override
 
bool PopulateUI (ShuttleGui &S) final
 
bool IsGraphicalUI () override
 
bool HideUI () 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 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 ()
 
- Public Member Functions inherited from XMLTagHandler
 XMLTagHandler ()
 
virtual ~XMLTagHandler ()
 
virtual void HandleXMLEndTag (const wxChar *WXUNUSED(tag))
 
virtual void HandleXMLContent (const wxString &WXUNUSED(content))
 
bool ReadXMLTag (const char *tag, const char **attrs)
 
void ReadXMLEndTag (const char *tag)
 
void ReadXMLContent (const char *s, int len)
 
XMLTagHandlerReadXMLChild (const char *tag)
 

Static Public Attributes

static const ComponentInterfaceSymbol Symbol { XO("Equalization") }
 
- 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 Types

enum  { loFreqI =20 }
 

Private Member Functions

wxString GetPrefsPrefix ()
 
bool ProcessOne (int count, WaveTrack *t, sampleCount start, sampleCount len)
 
bool CalcFilter ()
 
void Filter (size_t len, float *buffer)
 
void Flatten ()
 
void ForceRecalc ()
 
void EnvelopeUpdated ()
 
void EnvelopeUpdated (Envelope *env, bool lin)
 
bool IsLinear ()
 
void LoadCurves (const wxString &fileName={}, bool append=false)
 
void SaveCurves (const wxString &fileName={})
 
void UpdateDefaultCurves (bool updateAll=false)
 
void Select (int sel)
 
void setCurve (int currentCurve)
 
void setCurve (const wxString &curveName)
 
void setCurve (void)
 
bool GetDefaultFileName (wxFileName &fileName)
 
bool HandleXMLTag (const wxChar *tag, const wxChar **attrs) override
 
XMLTagHandlerHandleXMLChild (const wxChar *tag) override
 
void WriteXML (XMLWriter &xmlFile) const
 
void UpdateCurves ()
 
void UpdateDraw ()
 
void UpdateGraphic (void)
 
void EnvLogToLin (void)
 
void EnvLinToLog (void)
 
void ErrMin (void)
 
void GraphicEQ (Envelope *env)
 
void spline (double x[], double y[], size_t n, double y2[])
 
double splint (double x[], double y[], size_t n, double y2[], double xr)
 
void OnErase (wxEvent &event)
 
void OnSize (wxSizeEvent &event)
 
void OnSlider (wxCommandEvent &event)
 
void OnInterp (wxCommandEvent &event)
 
void OnSliderM (wxCommandEvent &event)
 
void OnSliderDBMAX (wxCommandEvent &event)
 
void OnSliderDBMIN (wxCommandEvent &event)
 
void OnDrawMode (wxCommandEvent &event)
 
void OnGraphicMode (wxCommandEvent &event)
 
void OnCurve (wxCommandEvent &event)
 
void OnManage (wxCommandEvent &event)
 
void OnClear (wxCommandEvent &event)
 
void OnInvert (wxCommandEvent &event)
 
void OnGridOnOff (wxCommandEvent &event)
 
void OnLinFreq (wxCommandEvent &event)
 

Private Attributes

int mOptions
 
HFFT hFFT
 
Floats mFFTBuffer
 
Floats mFilterFuncR
 
Floats mFilterFuncI
 
size_t mM
 
wxString mCurveName
 
bool mLin
 
float mdBMax
 
float mdBMin
 
bool mDrawMode
 
int mInterp
 
bool mDrawGrid
 
double mWhens [NUM_PTS]
 
double mWhenSliders [NUMBER_OF_BANDS+1]
 
size_t mBandsInUse
 
RulerPanelmdBRuler
 
RulerPanelmFreqRuler
 
bool mDisallowCustom
 
double mLoFreq
 
double mHiFreq
 
size_t mWindowSize
 
bool mDirty
 
int mSlidersOld [NUMBER_OF_BANDS]
 
double mEQVals [NUMBER_OF_BANDS+1]
 
EQCurveArray mCurves
 
std::unique_ptr< EnvelopemLogEnvelope
 
std::unique_ptr< EnvelopemLinEnvelope
 
EnvelopemEnvelope
 
wxSizer * szrC
 
wxSizer * szrG
 
wxSizer * szrV
 
wxSizer * szrH
 
wxSizer * szrI
 
wxSizer * szrL
 
wxSizer * szr1
 
wxSizer * szr2
 
wxSizer * szr3
 
wxSizer * szr4
 
wxSizer * szr5
 
wxSizerItem * mLeftSpacer
 
EqualizationPanelmPanel
 
wxRadioButton * mDraw
 
wxRadioButton * mGraphic
 
wxCheckBox * mLinFreq
 
wxCheckBox * mGridOnOff
 
wxChoice * mInterpChoice
 
wxChoice * mCurve
 
wxButton * mManage
 
wxStaticText * mMText
 
wxSlider * mMSlider
 
wxSlider * mdBMinSlider
 
wxSlider * mdBMaxSlider
 
wxSlider * mSliders [NUMBER_OF_BANDS]
 

Static Private Attributes

static const size_t windowSize = 16384u
 

Friends

class EqualizationPanel
 
class EditCurvesDialog
 

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

An Effect that modifies volume in different frequency bands.

Performs filtering, using an FFT to do a FIR filter. It lets the user draw an arbitrary envelope (using the same envelope editing code that is used to edit the track's amplitude envelope).

Also allows the curve to be specified with a series of 'graphic EQ' sliders.

The filter is applied using overlap/add of Hann windows.

Clone of the FFT Filter effect, no longer part of Audacity.

Definition at line 92 of file Equalization.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
private
Enumerator
loFreqI 

Definition at line 146 of file Equalization.h.

146 {loFreqI=20};

Constructor & Destructor Documentation

◆ EffectEqualization()

EffectEqualization::EffectEqualization ( int  Options = kEqLegacy)

◆ ~EffectEqualization()

EffectEqualization::~EffectEqualization ( )
virtual

Definition at line 332 of file Equalization.cpp.

333 {
334 }

Member Function Documentation

◆ CalcFilter()

bool EffectEqualization::CalcFilter ( )
private

Definition at line 1448 of file Equalization.cpp.

1449 {
1450  double loLog = log10(mLoFreq);
1451  double hiLog = log10(mHiFreq);
1452  double denom = hiLog - loLog;
1453 
1454  double delta = mHiFreq / ((double)(mWindowSize / 2.));
1455  double val0;
1456  double val1;
1457 
1458  if( IsLinear() )
1459  {
1460  val0 = mLinEnvelope->GetValue(0.0); //no scaling required - saved as dB
1461  val1 = mLinEnvelope->GetValue(1.0);
1462  }
1463  else
1464  {
1465  val0 = mLogEnvelope->GetValue(0.0); //no scaling required - saved as dB
1466  val1 = mLogEnvelope->GetValue(1.0);
1467  }
1468  mFilterFuncR[0] = val0;
1469  double freq = delta;
1470 
1471  for(size_t i = 1; i <= mWindowSize / 2; i++)
1472  {
1473  double when;
1474  if( IsLinear() )
1475  when = freq/mHiFreq;
1476  else
1477  when = (log10(freq) - loLog)/denom;
1478  if(when < 0.)
1479  {
1480  mFilterFuncR[i] = val0;
1481  }
1482  else if(when > 1.0)
1483  {
1484  mFilterFuncR[i] = val1;
1485  }
1486  else
1487  {
1488  if( IsLinear() )
1489  mFilterFuncR[i] = mLinEnvelope->GetValue(when);
1490  else
1491  mFilterFuncR[i] = mLogEnvelope->GetValue(when);
1492  }
1493  freq += delta;
1494  }
1495  mFilterFuncR[mWindowSize / 2] = val1;
1496 
1498 
1499  {
1500  size_t i = 1;
1501  for(; i < mWindowSize / 2; i++)
1502  {
1504  mFilterFuncR[mWindowSize - i] = mFilterFuncR[i]; //Fill entire array
1505  }
1506  mFilterFuncR[i] = DB_TO_LINEAR(mFilterFuncR[i]); //do last one
1507  }
1508 
1509  //transfer to time domain to do the padding and windowing
1510  Floats outr{ mWindowSize };
1511  Floats outi{ mWindowSize };
1512  InverseRealFFT(mWindowSize, mFilterFuncR.get(), NULL, outr.get()); // To time domain
1513 
1514  {
1515  size_t i = 0;
1516  for(; i <= (mM - 1) / 2; i++)
1517  { //Windowing - could give a choice, fixed for now - MJS
1518  // double mult=0.54-0.46*cos(2*M_PI*(i+(mM-1)/2.0)/(mM-1)); //Hamming
1519  //Blackman
1520  double mult =
1521  0.42 -
1522  0.5 * cos(2 * M_PI * (i + (mM - 1) / 2.0) / (mM - 1)) +
1523  .08 * cos(4 * M_PI * (i + (mM - 1) / 2.0) / (mM - 1));
1524  outr[i] *= mult;
1525  if(i != 0){
1526  outr[mWindowSize - i] *= mult;
1527  }
1528  }
1529  for(; i <= mWindowSize / 2; i++)
1530  { //Padding
1531  outr[i] = 0;
1532  outr[mWindowSize - i] = 0;
1533  }
1534  }
1535  Floats tempr{ mM };
1536  {
1537  size_t i = 0;
1538  for(; i < (mM - 1) / 2; i++)
1539  { //shift so that padding on right
1540  tempr[(mM - 1) / 2 + i] = outr[i];
1541  tempr[i] = outr[mWindowSize - (mM - 1) / 2 + i];
1542  }
1543  tempr[(mM - 1) / 2 + i] = outr[i];
1544  }
1545 
1546  for (size_t i = 0; i < mM; i++)
1547  { //and copy useful values back
1548  outr[i] = tempr[i];
1549  }
1550  for (size_t i = mM; i < mWindowSize; i++)
1551  { //rest is padding
1552  outr[i]=0.;
1553  }
1554 
1555  //Back to the frequency domain so we can use it
1556  RealFFT(mWindowSize, outr.get(), mFilterFuncR.get(), mFilterFuncI.get());
1557 
1558  return TRUE;
1559 }

References DB_TO_LINEAR(), InverseRealFFT(), IsLinear(), M_PI, mFilterFuncI, mFilterFuncR, mHiFreq, mLinEnvelope, mLoFreq, mLogEnvelope, mM, mWindowSize, and RealFFT().

Referenced by Init(), Process(), and EqualizationPanel::Recalc().

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

◆ CloseUI()

bool EffectEqualization::CloseUI ( )
overridevirtual

Reimplemented from Effect.

Definition at line 750 of file Equalization.cpp.

751 {
752  mCurve = NULL;
753  mPanel = NULL;
754 
755  return Effect::CloseUI();
756 }

References Effect::CloseUI(), mCurve, and mPanel.

Here is the call graph for this function:

◆ DefineParams()

bool EffectEqualization::DefineParams ( ShuttleParams S)
override

Definition at line 370 of file Equalization.cpp.

370  {
371  S.SHUTTLE_PARAM( mM, FilterLength );
372  //S.SHUTTLE_PARAM( mCurveName, CurveName);
373  S.SHUTTLE_PARAM( mLin, InterpLin);
374  S.SHUTTLE_ENUM_PARAM( mInterp, InterpMeth, kInterpStrings, nInterpolations );
375 
376  // if saving the preferences...
377  if( dynamic_cast<ShuttleGetAutomation*>(&S))
378  {
379  int numPoints = mCurves[ 0 ].points.size();
380  int point;
381  for( point = 0; point < numPoints; point++ )
382  {
383  const wxString nameFreq = wxString::Format("f%i",point);
384  const wxString nameVal = wxString::Format("v%i",point);
385  S.Define( mCurves[ 0 ].points[ point ].Freq, nameFreq, 0.0, 0.0, 0.0, 0.0 );
386  S.Define( mCurves[ 0 ].points[ point ].dB, nameVal, 0.0, 0.0, 0.0, 0.0 );
387  }
388 
389  }
390  else
391  {
392  mCurves[0].points.clear();
393 
394  for (int i = 0; i < 200; i++)
395  {
396  const wxString nameFreq = wxString::Format("f%i",i);
397  const wxString nameVal = wxString::Format("v%i",i);
398  double f = -1000.0;
399  double d = 0.0;
400  S.Define( f, nameFreq, 0.0, -10000.0, 1000000.0, 0.0 );
401  S.Define( d, nameVal, 0.0, -10000.0, 10000.0, 0.0 );
402  if( f <= 0.0 )
403  break;
404  mCurves[0].points.push_back( EQPoint( f,d ));
405  }
406  setCurve( 0 );
407  }
408 
409  return true;
410 }

References ShuttleParams::Define(), kInterpStrings, mCurves, mInterp, mLin, mM, nInterpolations, and setCurve().

Referenced by LoadFactoryPreset().

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

◆ EnvelopeUpdated() [1/2]

void EffectEqualization::EnvelopeUpdated ( )
private

Definition at line 2086 of file Equalization.cpp.

2087 {
2088  if (IsLinear())
2089  {
2090  EnvelopeUpdated(mLinEnvelope.get(), true);
2091  }
2092  else
2093  {
2094  EnvelopeUpdated(mLogEnvelope.get(), false);
2095  }
2096 }

References IsLinear(), mLinEnvelope, and mLogEnvelope.

Referenced by EnvLinToLog(), ErrMin(), Flatten(), OnInterp(), OnInvert(), EqualizationPanel::OnMouseEvent(), OnSlider(), and UpdateDraw().

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

◆ EnvelopeUpdated() [2/2]

void EffectEqualization::EnvelopeUpdated ( Envelope env,
bool  lin 
)
private

Definition at line 2098 of file Equalization.cpp.

2099 {
2100  // Allocate and populate point arrays
2101  size_t numPoints = env->GetNumberOfPoints();
2102  Doubles when{ numPoints };
2103  Doubles value{ numPoints };
2104  env->GetPoints( when.get(), value.get(), numPoints );
2105 
2106  // Clear the unnamed curve
2107  int curve = mCurves.size() - 1;
2108  mCurves[ curve ].points.clear();
2109 
2110  if(lin)
2111  {
2112  // Copy and convert points
2113  for (size_t point = 0; point < numPoints; point++)
2114  {
2115  double freq = when[ point ] * mHiFreq;
2116  double db = value[ point ];
2117 
2118  // Add it to the curve
2119  mCurves[ curve ].points.push_back( EQPoint( freq, db ) );
2120  }
2121  }
2122  else
2123  {
2124  double loLog = log10( 20. );
2125  double hiLog = log10( mHiFreq );
2126  double denom = hiLog - loLog;
2127 
2128  // Copy and convert points
2129  for (size_t point = 0; point < numPoints; point++)
2130  {
2131  double freq = pow( 10., ( ( when[ point ] * denom ) + loLog ));
2132  double db = value[ point ];
2133 
2134  // Add it to the curve
2135  mCurves[ curve ].points.push_back( EQPoint( freq, db ) );
2136  }
2137  }
2138  // Remember that we've updated the unnamed curve
2139  mDirty = true;
2140 
2141  // set 'unnamed' as the selected curve
2142  Select( (int) mCurves.size() - 1 );
2143 }

References Envelope::GetNumberOfPoints(), Envelope::GetPoints(), mCurves, mDirty, mHiFreq, and Select().

Here is the call graph for this function:

◆ EnvLinToLog()

void EffectEqualization::EnvLinToLog ( void  )
private

Definition at line 2517 of file Equalization.cpp.

2518 {
2519  size_t numPoints = mLinEnvelope->GetNumberOfPoints();
2520  if( numPoints == 0 )
2521  {
2522  return;
2523  }
2524 
2525  Doubles when{ numPoints };
2526  Doubles value{ numPoints };
2527 
2528  mLogEnvelope->Flatten(0.);
2529  mLogEnvelope->SetTrackLen(1.0);
2530  mLinEnvelope->GetPoints( when.get(), value.get(), numPoints );
2531  mLogEnvelope->Reassign(0., value[0]);
2532  double loLog = log10(20.);
2533  double hiLog = log10(mHiFreq);
2534  double denom = hiLog - loLog;
2535  bool changed = false;
2536 
2537  for (size_t i = 0; i < numPoints; i++)
2538  {
2539  if( when[i]*mHiFreq >= 20 )
2540  {
2541  // Caution: on Linux, when when == 20, the log calculation rounds
2542  // to just under zero, which causes an assert error.
2543  double flog = (log10(when[i]*mHiFreq)-loLog)/denom;
2544  mLogEnvelope->Insert(std::max(0.0, flog) , value[i]);
2545  }
2546  else
2547  { //get the first point as close as we can to the last point requested
2548  changed = true;
2549  double v = value[i];
2550  mLogEnvelope->Insert(0., v);
2551  }
2552  }
2553  mLogEnvelope->Reassign(1., value[numPoints - 1]);
2554 
2555  if(changed)
2556  EnvelopeUpdated(mLogEnvelope.get(), false);
2557 }

References EnvelopeUpdated(), mHiFreq, mLinEnvelope, and mLogEnvelope.

Referenced by OnInvert(), OnLinFreq(), and UpdateGraphic().

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

◆ EnvLogToLin()

void EffectEqualization::EnvLogToLin ( void  )
private

Definition at line 2493 of file Equalization.cpp.

2494 {
2495  size_t numPoints = mLogEnvelope->GetNumberOfPoints();
2496  if( numPoints == 0 )
2497  {
2498  return;
2499  }
2500 
2501  Doubles when{ numPoints };
2502  Doubles value{ numPoints };
2503 
2504  mLinEnvelope->Flatten(0.);
2505  mLinEnvelope->SetTrackLen(1.0);
2506  mLogEnvelope->GetPoints( when.get(), value.get(), numPoints );
2507  mLinEnvelope->Reassign(0., value[0]);
2508  double loLog = log10(20.);
2509  double hiLog = log10(mHiFreq);
2510  double denom = hiLog - loLog;
2511 
2512  for (size_t i = 0; i < numPoints; i++)
2513  mLinEnvelope->Insert(pow( 10., ((when[i] * denom) + loLog))/mHiFreq , value[i]);
2514  mLinEnvelope->Reassign(1., value[numPoints-1]);
2515 }

References mHiFreq, mLinEnvelope, and mLogEnvelope.

Referenced by OnInvert(), OnLinFreq(), and UpdateDraw().

Here is the caller graph for this function:

◆ ErrMin()

void EffectEqualization::ErrMin ( void  )
private

Definition at line 2559 of file Equalization.cpp.

2560 {
2561  double vals[NUM_PTS];
2562  double error = 0.0;
2563  double oldError = 0.0;
2564  double mEQValsOld = 0.0;
2565  double correction = 1.6;
2566  bool flag;
2567  size_t j=0;
2568  Envelope testEnvelope{ *mLogEnvelope };
2569 
2570  for(size_t i = 0; i < NUM_PTS; i++)
2571  vals[i] = testEnvelope.GetValue(mWhens[i]);
2572 
2573  // Do error minimisation
2574  error = 0.;
2575  GraphicEQ(&testEnvelope);
2576  for(size_t i = 0; i < NUM_PTS; i++) //calc initial error
2577  {
2578  double err = vals[i] - testEnvelope.GetValue(mWhens[i]);
2579  error += err*err;
2580  }
2581  oldError = error;
2582  while( j < mBandsInUse*12 ) //loop over the sliders a number of times
2583  {
2584  auto i = j % mBandsInUse; //use this slider
2585  if( (j > 0) & (i == 0) ) // if we've come back to the first slider again...
2586  {
2587  if( correction > 0 )
2588  correction = -correction; //go down
2589  else
2590  correction = -correction/2.; //go up half as much
2591  }
2592  flag = true; // check if we've hit the slider limit
2593  do
2594  {
2595  oldError = error;
2596  mEQValsOld = mEQVals[i];
2597  mEQVals[i] += correction; //move fader value
2598  if( mEQVals[i] > 20. )
2599  {
2600  mEQVals[i] = 20.;
2601  flag = false;
2602  }
2603  if( mEQVals[i] < -20. )
2604  {
2605  mEQVals[i] = -20.;
2606  flag = false;
2607  }
2608  GraphicEQ(&testEnvelope); //calculate envelope
2609  error = 0.;
2610  for(size_t k = 0; k < NUM_PTS; k++) //calculate error
2611  {
2612  double err = vals[k] - testEnvelope.GetValue(mWhens[k]);
2613  error += err*err;
2614  }
2615  }
2616  while( (error < oldError) && flag );
2617  if( error > oldError )
2618  {
2619  mEQVals[i] = mEQValsOld; //last one didn't work
2620  error = oldError;
2621  }
2622  else
2623  oldError = error;
2624  if( error < .0025 * mBandsInUse)
2625  break; // close enuff
2626  j++; //try next slider
2627  }
2628  if( error > .0025 * mBandsInUse ) // not within 0.05dB on each slider, on average
2629  {
2630  Select( (int) mCurves.size() - 1 );
2631  EnvelopeUpdated(&testEnvelope, false);
2632  }
2633 }

References EnvelopeUpdated(), flag, GraphicEQ(), mBandsInUse, mCurves, mEQVals, mLogEnvelope, mWhens, NUM_PTS, and Select().

Referenced by UpdateGraphic().

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

◆ Filter()

void EffectEqualization::Filter ( size_t  len,
float *  buffer 
)
private

Definition at line 1561 of file Equalization.cpp.

1562 {
1563  float re,im;
1564  // Apply FFT
1565  RealFFTf(buffer, hFFT.get());
1566  //FFT(len, false, inr, NULL, outr, outi);
1567 
1568  // Apply filter
1569  // DC component is purely real
1570  mFFTBuffer[0] = buffer[0] * mFilterFuncR[0];
1571  for(size_t i = 1; i < (len / 2); i++)
1572  {
1573  re=buffer[hFFT->BitReversed[i] ];
1574  im=buffer[hFFT->BitReversed[i]+1];
1575  mFFTBuffer[2*i ] = re*mFilterFuncR[i] - im*mFilterFuncI[i];
1576  mFFTBuffer[2*i+1] = re*mFilterFuncI[i] + im*mFilterFuncR[i];
1577  }
1578  // Fs/2 component is purely real
1579  mFFTBuffer[1] = buffer[1] * mFilterFuncR[len/2];
1580 
1581  // Inverse FFT and normalization
1582  InverseRealFFTf(mFFTBuffer.get(), hFFT.get());
1583  ReorderToTime(hFFT.get(), mFFTBuffer.get(), buffer);
1584 }

References hFFT, InverseRealFFTf(), mFFTBuffer, mFilterFuncI, mFilterFuncR, RealFFTf(), and ReorderToTime().

Referenced by ProcessOne().

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

◆ Flatten()

void EffectEqualization::Flatten ( )
private

Definition at line 2156 of file Equalization.cpp.

2157 {
2158  mLogEnvelope->Flatten(0.);
2159  mLogEnvelope->SetTrackLen(1.0);
2160  mLinEnvelope->Flatten(0.);
2161  mLinEnvelope->SetTrackLen(1.0);
2162  ForceRecalc();
2163  if( !mDrawMode )
2164  {
2165  for( size_t i = 0; i < mBandsInUse; i++)
2166  {
2167  mSliders[i]->SetValue(0);
2168  mSlidersOld[i] = 0;
2169  mEQVals[i] = 0.;
2170 
2171  wxString tip;
2172  if( kThirdOct[i] < 1000.)
2173  tip.Printf( wxT("%dHz\n%.1fdB"), (int)kThirdOct[i], 0. );
2174  else
2175  tip.Printf( wxT("%gkHz\n%.1fdB"), kThirdOct[i]/1000., 0. );
2176  mSliders[i]->SetToolTip(tip);
2177  }
2178  }
2179  EnvelopeUpdated();
2180 }

References EnvelopeUpdated(), ForceRecalc(), kThirdOct, mBandsInUse, mDrawMode, mEQVals, mLinEnvelope, mLogEnvelope, mSliders, and mSlidersOld.

Referenced by OnClear().

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

◆ ForceRecalc()

void EffectEqualization::ForceRecalc ( )
private

Definition at line 2075 of file Equalization.cpp.

2076 {
2077  if (mPanel)
2078  {
2079  mPanel->ForceRecalc();
2080  }
2081 }

References EqualizationPanel::ForceRecalc(), and mPanel.

Referenced by Flatten(), GraphicEQ(), OnInvert(), OnLinFreq(), OnSliderM(), PopulateOrExchange(), setCurve(), TransferDataFromWindow(), and UpdateDraw().

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

◆ GetAutomationParameters()

bool EffectEqualization::GetAutomationParameters ( CommandParameters parms)
overridevirtual

Reimplemented from Effect.

Definition at line 412 of file Equalization.cpp.

413 {
414  parms.Write(KEY_FilterLength, (unsigned long)mM);
415  //parms.Write(KEY_CurveName, mCurveName);
416  parms.Write(KEY_InterpLin, mLin);
417  parms.WriteEnum(KEY_InterpMeth, mInterp, kInterpStrings, nInterpolations);
418 
419  return true;
420 }

References kInterpStrings, mInterp, mLin, mM, nInterpolations, and CommandParameters::WriteEnum().

Here is the call graph for this function:

◆ GetDefaultFileName()

bool EffectEqualization::GetDefaultFileName ( wxFileName &  fileName)
private

Definition at line 1805 of file Equalization.cpp.

1806 {
1807  // look in data dir first, in case the user has their own defaults (maybe downloaded ones)
1808  fileName = wxFileName( FileNames::DataDir(), wxT("EQDefaultCurves.xml") );
1809  if( !fileName.FileExists() )
1810  { // Default file not found in the data dir. Fall back to Resources dir.
1811  // See http://docs.wxwidgets.org/trunk/classwx_standard_paths.html#5514bf6288ee9f5a0acaf065762ad95d
1812  fileName = wxFileName( FileNames::ResourcesDir(), wxT("EQDefaultCurves.xml") );
1813  }
1814  if( !fileName.FileExists() )
1815  {
1816  // LLL: Is there really a need for an error message at all???
1817  //auto errorMessage = XO("EQCurves.xml and EQDefaultCurves.xml were not found on your system.\nPlease press 'help' to visit the download page.\n\nSave the curves at %s")
1818  // .Format( FileNames::DataDir() );
1819  //BasicUI::ShowErrorDialog( wxWidgetsWindowPlacement{ mUIParent },
1820  // XO("EQCurves.xml and EQDefaultCurves.xml missing"),
1821  // errorMessage, wxT("http://wiki.audacityteam.org/wiki/EQCurvesDownload"), false);
1822 
1823  // Have another go at finding EQCurves.xml in the data dir, in case 'help' helped
1824  fileName = wxFileName( FileNames::DataDir(), wxT("EQDefaultCurves.xml") );
1825  }
1826  return (fileName.FileExists());
1827 }

References FileNames::DataDir(), and FileNames::ResourcesDir().

Referenced by LoadCurves().

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

◆ GetDescription()

TranslatableString EffectEqualization::GetDescription ( )
overridevirtual

Reimplemented from Effect.

Definition at line 347 of file Equalization.cpp.

348 {
349  return XO("Adjusts the volume levels of particular frequencies");
350 }

References XO.

◆ GetFactoryPresets()

RegistryPaths EffectEqualization::GetFactoryPresets ( )
overridevirtual

Reimplemented from Effect.

Definition at line 491 of file Equalization.cpp.

492 {
494 
495  for (size_t i = 0; i < WXSIZEOF(FactoryPresets); i++)
496  {
497  if ((mOptions == kEqOptionGraphic) && (FactoryPresets[i].bForBoth == false))
498  continue;
499  names.push_back(FactoryPresets[i].name.Translation());
500  }
501 
502  return names;
503 }

References FactoryPresets, kEqOptionGraphic, mOptions, name, names, and TranslatableString::Translation().

Here is the call graph for this function:

◆ GetPrefsPrefix()

wxString EffectEqualization::GetPrefsPrefix ( )
private

Definition at line 588 of file Equalization.cpp.

589 {
590  wxString base = wxT("/Effects/Equalization/");
591  if( mOptions == kEqOptionGraphic )
592  base = wxT("/Effects/GraphicEq/");
593  else if( mOptions == kEqOptionCurve )
594  base = wxT("/Effects/FilterCurve/");
595  return base;
596 }

References kEqOptionCurve, kEqOptionGraphic, and mOptions.

Referenced by LoadCurves(), Startup(), and UpdateDefaultCurves().

Here is the caller graph for this function:

◆ GetSymbol()

ComponentInterfaceSymbol EffectEqualization::GetSymbol ( )
overridevirtual

◆ GetType()

EffectType EffectEqualization::GetType ( )
overridevirtual

Reimplemented from Effect.

Definition at line 364 of file Equalization.cpp.

365 {
366  return EffectTypeProcess;
367 }

References EffectTypeProcess.

◆ GraphicEQ()

void EffectEqualization::GraphicEQ ( Envelope env)
private

Definition at line 2635 of file Equalization.cpp.

2636 {
2637  // JKC: 'value' is for height of curve.
2638  // The 0.0 initial value would only get used if NUM_PTS were 0.
2639  double value = 0.0;
2640  double dist, span, s;
2641 
2642  env->Flatten(0.);
2643  env->SetTrackLen(1.0);
2644 
2645  switch( mInterp )
2646  {
2647  case kBspline: // B-spline
2648  {
2649  int minF = 0;
2650  for(size_t i = 0; i < NUM_PTS; i++)
2651  {
2652  while( (mWhenSliders[minF] <= mWhens[i]) & (minF < (int)mBandsInUse) )
2653  minF++;
2654  minF--;
2655  if( minF < 0 ) //before first slider
2656  {
2657  dist = mWhens[i] - mWhenSliders[0];
2658  span = mWhenSliders[1] - mWhenSliders[0];
2659  s = dist/span;
2660  if( s < -1.5 )
2661  value = 0.;
2662  else if( s < -.5 )
2663  value = mEQVals[0]*(s + 1.5)*(s + 1.5)/2.;
2664  else
2665  value = mEQVals[0]*(.75 - s*s) + mEQVals[1]*(s + .5)*(s + .5)/2.;
2666  }
2667  else
2668  {
2669  if( mWhens[i] > mWhenSliders[mBandsInUse-1] ) //after last fader
2670  {
2671  dist = mWhens[i] - mWhenSliders[mBandsInUse-1];
2673  s = dist/span;
2674  if( s > 1.5 )
2675  value = 0.;
2676  else if( s > .5 )
2677  value = mEQVals[mBandsInUse-1]*(s - 1.5)*(s - 1.5)/2.;
2678  else
2679  value = mEQVals[mBandsInUse-1]*(.75 - s*s) +
2680  mEQVals[mBandsInUse-2]*(s - .5)*(s - .5)/2.;
2681  }
2682  else //normal case
2683  {
2684  dist = mWhens[i] - mWhenSliders[minF];
2685  span = mWhenSliders[minF+1] - mWhenSliders[minF];
2686  s = dist/span;
2687  if(s < .5 )
2688  {
2689  value = mEQVals[minF]*(0.75 - s*s);
2690  if( minF+1 < (int)mBandsInUse )
2691  value += mEQVals[minF+1]*(s+.5)*(s+.5)/2.;
2692  if( minF-1 >= 0 )
2693  value += mEQVals[minF-1]*(s-.5)*(s-.5)/2.;
2694  }
2695  else
2696  {
2697  value = mEQVals[minF]*(s-1.5)*(s-1.5)/2.;
2698  if( minF+1 < (int)mBandsInUse )
2699  value += mEQVals[minF+1]*(.75-(1.-s)*(1.-s));
2700  if( minF+2 < (int)mBandsInUse )
2701  value += mEQVals[minF+2]*(s-.5)*(s-.5)/2.;
2702  }
2703  }
2704  }
2705  if(mWhens[i]<=0.)
2706  env->Reassign(0., value);
2707  env->Insert( mWhens[i], value );
2708  }
2709  env->Reassign( 1., value );
2710  break;
2711  }
2712 
2713  case kCosine: // Cosine squared
2714  {
2715  int minF = 0;
2716  for(size_t i = 0; i < NUM_PTS; i++)
2717  {
2718  while( (mWhenSliders[minF] <= mWhens[i]) & (minF < (int)mBandsInUse) )
2719  minF++;
2720  minF--;
2721  if( minF < 0 ) //before first slider
2722  {
2723  dist = mWhenSliders[0] - mWhens[i];
2724  span = mWhenSliders[1] - mWhenSliders[0];
2725  if( dist < span )
2726  value = mEQVals[0]*(1. + cos(M_PI*dist/span))/2.;
2727  else
2728  value = 0.;
2729  }
2730  else
2731  {
2732  if( mWhens[i] > mWhenSliders[mBandsInUse-1] ) //after last fader
2733  {
2735  dist = mWhens[i] - mWhenSliders[mBandsInUse-1];
2736  if( dist < span )
2737  value = mEQVals[mBandsInUse-1]*(1. + cos(M_PI*dist/span))/2.;
2738  else
2739  value = 0.;
2740  }
2741  else //normal case
2742  {
2743  span = mWhenSliders[minF+1] - mWhenSliders[minF];
2744  dist = mWhenSliders[minF+1] - mWhens[i];
2745  value = mEQVals[minF]*(1. + cos(M_PI*(span-dist)/span))/2. +
2746  mEQVals[minF+1]*(1. + cos(M_PI*dist/span))/2.;
2747  }
2748  }
2749  if(mWhens[i]<=0.)
2750  env->Reassign(0., value);
2751  env->Insert( mWhens[i], value );
2752  }
2753  env->Reassign( 1., value );
2754  break;
2755  }
2756 
2757  case kCubic: // Cubic Spline
2758  {
2759  double y2[NUMBER_OF_BANDS+1];
2762  for(double xf=0; xf<1.; xf+=1./NUM_PTS)
2763  {
2764  env->Insert(xf, splint(mWhenSliders, mEQVals, mBandsInUse+1, y2, xf));
2765  }
2766  break;
2767  }
2768  }
2769 
2770  ForceRecalc();
2771 }

References Envelope::Flatten(), ForceRecalc(), Envelope::Insert(), kBspline, kCosine, kCubic, M_PI, mBandsInUse, mEQVals, mInterp, mWhens, mWhenSliders, NUM_PTS, NUMBER_OF_BANDS, Envelope::Reassign(), Envelope::SetTrackLen(), spline(), and splint().

Referenced by ErrMin(), OnInterp(), OnInvert(), OnSlider(), and UpdateGraphic().

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

◆ HandleXMLChild()

XMLTagHandler * EffectEqualization::HandleXMLChild ( const wxChar *  tag)
overrideprivatevirtual

Implements XMLTagHandler.

Definition at line 2286 of file Equalization.cpp.

2287 {
2288  if( !wxStrcmp( tag, wxT("equalizationeffect") ) )
2289  {
2290  return this;
2291  }
2292 
2293  if( !wxStrcmp( tag, wxT("curve") ) )
2294  {
2295  return this;
2296  }
2297 
2298  if( !wxStrcmp( tag, wxT("point") ) )
2299  {
2300  return this;
2301  }
2302 
2303  return NULL;
2304 }

◆ HandleXMLTag()

bool EffectEqualization::HandleXMLTag ( const wxChar *  tag,
const wxChar **  attrs 
)
overrideprivatevirtual

Implements XMLTagHandler.

Definition at line 2185 of file Equalization.cpp.

2186 {
2187  // May want to add a version strings...
2188  if( !wxStrcmp( tag, wxT("equalizationeffect") ) )
2189  {
2190  return true;
2191  }
2192 
2193  // Located a NEW curve
2194  if( !wxStrcmp(tag, wxT("curve") ) )
2195  {
2196  // Process the attributes
2197  while( *attrs )
2198  {
2199  // Cache attr/value and bump to next
2200  const wxChar *attr = *attrs++;
2201  const wxChar *value = *attrs++;
2202 
2203  // Create a NEW curve and name it
2204  if( !wxStrcmp( attr, wxT("name") ) )
2205  {
2206  const wxString strValue = value;
2207  if (!XMLValueChecker::IsGoodString(strValue))
2208  return false;
2209  // check for a duplicate name and add (n) if there is one
2210  int n = 0;
2211  wxString strValueTemp = strValue;
2212  bool exists;
2213  do
2214  {
2215  exists = false;
2216  for(size_t i = 0; i < mCurves.size(); i++)
2217  {
2218  if(n>0)
2219  strValueTemp.Printf(wxT("%s (%d)"),strValue,n);
2220  if(mCurves[i].Name == strValueTemp)
2221  {
2222  exists = true;
2223  break;
2224  }
2225  }
2226  n++;
2227  }
2228  while(exists == true);
2229 
2230  mCurves.push_back( EQCurve( strValueTemp ) );
2231  }
2232  }
2233 
2234  // Tell caller it was processed
2235  return true;
2236  }
2237 
2238  // Located a NEW point
2239  if( !wxStrcmp( tag, wxT("point") ) )
2240  {
2241  // Set defaults in case attributes are missing
2242  double f = 0.0;
2243  double d = 0.0;
2244 
2245  // Process the attributes
2246  double dblValue;
2247  while( *attrs )
2248  { // Cache attr/value and bump to next
2249  const wxChar *attr = *attrs++;
2250  const wxChar *value = *attrs++;
2251 
2252  const wxString strValue = value;
2253 
2254  // Get the frequency
2255  if( !wxStrcmp( attr, wxT("f") ) )
2256  {
2257  if (!XMLValueChecker::IsGoodString(strValue) ||
2258  !Internat::CompatibleToDouble(strValue, &dblValue))
2259  return false;
2260  f = dblValue;
2261  }
2262  // Get the dB
2263  else if( !wxStrcmp( attr, wxT("d") ) )
2264  {
2265  if (!XMLValueChecker::IsGoodString(strValue) ||
2266  !Internat::CompatibleToDouble(strValue, &dblValue))
2267  return false;
2268  d = dblValue;
2269  }
2270  }
2271 
2272  // Create a NEW point
2273  mCurves[ mCurves.size() - 1 ].points.push_back( EQPoint( f, d ) );
2274 
2275  // Tell caller it was processed
2276  return true;
2277  }
2278 
2279  // Tell caller we didn't understand the tag
2280  return false;
2281 }

References Internat::CompatibleToDouble(), XMLValueChecker::IsGoodString(), and mCurves.

Here is the call graph for this function:

◆ Init()

bool EffectEqualization::Init ( )
overridevirtual

Reimplemented from Effect.

Definition at line 658 of file Equalization.cpp.

659 {
660  int selcount = 0;
661  double rate = 0.0;
662 
663  auto trackRange =
664  TrackList::Get( *FindProject() ).Selected< const WaveTrack >();
665  if (trackRange) {
666  rate = (*(trackRange.first++)) -> GetRate();
667  ++selcount;
668 
669  for (auto track : trackRange) {
670  if (track->GetRate() != rate) {
672  XO(
673 "To apply Equalization, all selected tracks must have the same sample rate.") );
674  return(false);
675  }
676  ++selcount;
677  }
678  }
679 
680  mHiFreq = rate / 2.0;
681  // Unlikely, but better than crashing.
682  if (mHiFreq <= loFreqI) {
684  XO("Track sample rate is too low for this effect."),
685  wxOK | wxCENTRE,
686  XO("Effect Unavailable") );
687  return(false);
688  }
689 
690  mLoFreq = loFreqI;
691 
692  mBandsInUse = 0;
693  while (kThirdOct[mBandsInUse] <= mHiFreq) {
694  mBandsInUse++;
696  break;
697  }
698 
699  mEnvelope = (mLin ? mLinEnvelope : mLogEnvelope).get();
700 
702 
703  CalcFilter();
704 
705  return(true);
706 }

References CalcFilter(), Effect::FindProject(), TrackList::Get(), anonymous_namespace{TimeTrack.cpp}::GetRate(), kThirdOct, loFreqI, mBandsInUse, mCurveName, mEnvelope, Effect::MessageBox(), mHiFreq, mLin, mLinEnvelope, mLoFreq, mLogEnvelope, NUMBER_OF_BANDS, TrackList::Selected(), setCurve(), and XO.

Here is the call graph for this function:

◆ IsLinear()

bool EffectEqualization::IsLinear ( )
private

Definition at line 2148 of file Equalization.cpp.

2149 {
2150  return mDrawMode && mLin;
2151 }

References mDrawMode, and mLin.

Referenced by CalcFilter(), EnvelopeUpdated(), OnInvert(), OnLinFreq(), and EqualizationPanel::OnPaint().

Here is the caller graph for this function:

◆ LoadCurves()

void EffectEqualization::LoadCurves ( const wxString &  fileName = {},
bool  append = false 
)
private

Definition at line 1589 of file Equalization.cpp.

1590 {
1591 // We've disabled the XML management of curves.
1592 // Just going via .cfg files now.
1593 #if 1
1594  (void)fileName;
1595  (void)append;
1596  mCurves.clear();
1597  mCurves.push_back( wxT("unnamed") ); // we still need a default curve to use
1598 #else
1599  // Construct normal curve filename
1600  //
1601  // LLL: Wouldn't you know that as of WX 2.6.2, there is a conflict
1602  // between wxStandardPaths and wxConfig under Linux. The latter
1603  // creates a normal file as "$HOME/.audacity", while the former
1604  // expects the ".audacity" portion to be a directory.
1605  // MJS: I don't know what the above means, or if I have broken it.
1606  wxFileName fn;
1607 
1608  if(fileName.empty()) {
1609  // Check if presets are up to date.
1610  wxString eqCurvesCurrentVersion = wxString::Format(wxT("%d.%d"), EQCURVES_VERSION, EQCURVES_REVISION);
1611  wxString eqCurvesInstalledVersion;
1612  gPrefs->Read(GetPrefsPrefix() + "PresetVersion", &eqCurvesInstalledVersion, wxT(""));
1613 
1614  bool needUpdate = (eqCurvesCurrentVersion != eqCurvesInstalledVersion);
1615 
1616  // UpdateDefaultCurves allows us to import NEW factory presets only,
1617  // or update all factory preset curves.
1618  if (needUpdate)
1620  fn = wxFileName( FileNames::DataDir(), wxT("EQCurves.xml") );
1621  }
1622  else
1623  fn = fileName; // user is loading a specific set of curves
1624 
1625  // If requested file doesn't exist...
1626  if( !fn.FileExists() && !GetDefaultFileName(fn) ) {
1627  mCurves.clear();
1628  /* i18n-hint: name of the 'unnamed' custom curve */
1629  mCurves.push_back( _("unnamed") ); // we still need a default curve to use
1630  return;
1631  }
1632 
1633  EQCurve tempCustom(wxT("temp"));
1634  if( append == false ) // Start from scratch
1635  mCurves.clear();
1636  else // appending so copy and remove 'unnamed', to replace later
1637  {
1638  tempCustom.points = mCurves.back().points;
1639  mCurves.pop_back();
1640  }
1641 
1642  // Load the curves
1643  XMLFileReader reader;
1644  const wxString fullPath{ fn.GetFullPath() };
1645  if( !reader.Parse( this, fullPath ) )
1646  {
1647  /* i18n-hint: EQ stands for 'Equalization'.*/
1648  auto msg = XO("Error Loading EQ Curves from file:\n%s\nError message says:\n%s")
1649  .Format( fullPath, reader.GetErrorStr() );
1650  // Inform user of load failure
1652  msg,
1653  wxOK | wxCENTRE,
1654  XO("Error Loading EQ Curves") );
1655  mCurves.push_back( _("unnamed") ); // we always need a default curve to use
1656  return;
1657  }
1658 
1659  // Move "unnamed" to end, if it exists in current language.
1660  int numCurves = mCurves.size();
1661  int curve;
1662  EQCurve tempUnnamed(wxT("tempUnnamed"));
1663  for( curve = 0; curve < numCurves-1; curve++ )
1664  {
1665  if( mCurves[curve].Name == _("unnamed") )
1666  {
1667  tempUnnamed.points = mCurves[curve].points;
1668  mCurves.erase(mCurves.begin() + curve);
1669  mCurves.push_back( _("unnamed") ); // add 'unnamed' back at the end
1670  mCurves.back().points = tempUnnamed.points;
1671  }
1672  }
1673 
1674  if( mCurves.back().Name != _("unnamed") )
1675  mCurves.push_back( _("unnamed") ); // we always need a default curve to use
1676  if( append == true )
1677  {
1678  mCurves.back().points = tempCustom.points;
1679  }
1680 #endif
1681  return;
1682 }

References _, FileNames::DataDir(), EQCURVES_REVISION, EQCURVES_VERSION, fn, GetDefaultFileName(), XMLFileReader::GetErrorStr(), GetPrefsPrefix(), gPrefs, mCurves, Effect::MessageBox(), XMLFileReader::Parse(), EQCurve::points, UPDATE_ALL, UpdateDefaultCurves(), and XO.

Referenced by EditCurvesDialog::OnDefaults(), EditCurvesDialog::OnImport(), and EditCurvesDialog::OnOK().

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

◆ LoadFactoryDefaults()

bool EffectEqualization::LoadFactoryDefaults ( )
overridevirtual

Reimplemented from Effect.

Definition at line 448 of file Equalization.cpp.

449 {
450  mdBMin = DEF_dBMin;
451  mdBMax = DEF_dBMax;
452  mDrawMode = DEF_DrawMode;
453  mDrawGrid = DEF_DrawGrid;
454 
455  if( mOptions == kEqOptionCurve)
456  mDrawMode = true;
457  if( mOptions == kEqOptionGraphic)
458  mDrawMode = false;
459 
461 }

References kEqOptionCurve, kEqOptionGraphic, Effect::LoadFactoryDefaults(), mdBMax, mdBMin, mDrawGrid, mDrawMode, and mOptions.

Here is the call graph for this function:

◆ LoadFactoryPreset()

bool EffectEqualization::LoadFactoryPreset ( int  id)
overridevirtual

Reimplemented from Effect.

Definition at line 505 of file Equalization.cpp.

506 {
507  int index = -1;
508  for (size_t i = 0; i < WXSIZEOF(FactoryPresets); i++)
509  {
510  if ((mOptions == kEqOptionGraphic) && (FactoryPresets[i].bForBoth == false))
511  continue;
512  if (id-- == 0) {
513  index = i;
514  break;
515  }
516  }
517  if (index < 0)
518  return false;
519 
520  // mParams =
521  wxString params = FactoryPresets[index].values;
522 
525  S.SetForWriting( &eap );
526  DefineParams( S );
527 
528  if (mUIDialog)
529  {
531  }
532 
533  return true;
534 }

References DefineParams(), FactoryPresets, kEqOptionGraphic, mOptions, Effect::mUIDialog, params, ShuttleSetAutomation::SetForWriting(), and TransferDataToWindow().

Here is the call graph for this function:

◆ ManualPage()

ManualPageID EffectEqualization::ManualPage ( )
overridevirtual

Reimplemented from Effect.

Definition at line 352 of file Equalization.cpp.

353 {
354  // Bug 2509: Must use _ and not space in names.
355  if( mOptions == kEqOptionGraphic )
356  return L"Graphic_EQ";
357  if( mOptions == kEqOptionCurve )
358  return L"Filter_Curve_EQ";
359  return L"Equalization";
360 }

References kEqOptionCurve, kEqOptionGraphic, and mOptions.

◆ OnClear()

void EffectEqualization::OnClear ( wxCommandEvent &  event)
private

Definition at line 2930 of file Equalization.cpp.

2931 {
2932  Flatten();
2933 }

References Flatten().

Here is the call graph for this function:

◆ OnCurve()

void EffectEqualization::OnCurve ( wxCommandEvent &  event)
private

Definition at line 2906 of file Equalization.cpp.

2907 {
2908  // Select NEW curve
2909  wxASSERT( mCurve != NULL );
2910  setCurve( mCurve->GetCurrentSelection() );
2911  if( !mDrawMode )
2912  UpdateGraphic();
2913 }

References mCurve, mDrawMode, setCurve(), and UpdateGraphic().

Here is the call graph for this function:

◆ OnDrawMode()

void EffectEqualization::OnDrawMode ( wxCommandEvent &  event)
private

Definition at line 2875 of file Equalization.cpp.

2876 {
2877  mDrawMode = true;
2878  UpdateDraw();
2879 }

References mDrawMode, and UpdateDraw().

Here is the call graph for this function:

◆ OnErase()

void EffectEqualization::OnErase ( wxEvent &  event)
private

Definition at line 2816 of file Equalization.cpp.

2817 {
2818 }

Referenced by PopulateOrExchange().

Here is the caller graph for this function:

◆ OnGraphicMode()

void EffectEqualization::OnGraphicMode ( wxCommandEvent &  event)
private

Definition at line 2881 of file Equalization.cpp.

2882 {
2883  mDrawMode = false;
2884  UpdateGraphic();
2885 }

References mDrawMode, and UpdateGraphic().

Here is the call graph for this function:

◆ OnGridOnOff()

void EffectEqualization::OnGridOnOff ( wxCommandEvent &  event)
private

Definition at line 3003 of file Equalization.cpp.

3004 {
3005  mDrawGrid = mGridOnOff->IsChecked();
3006  mPanel->Refresh(false);
3007 }

References mDrawGrid, mGridOnOff, and mPanel.

◆ OnInterp()

void EffectEqualization::OnInterp ( wxCommandEvent &  event)
private

Definition at line 2864 of file Equalization.cpp.

2865 {
2866  bool bIsGraphic = !mDrawMode;
2867  if (bIsGraphic)
2868  {
2869  GraphicEQ(mLogEnvelope.get());
2870  EnvelopeUpdated();
2871  }
2872  mInterp = mInterpChoice->GetSelection();
2873 }

References EnvelopeUpdated(), GraphicEQ(), mDrawMode, mInterp, mInterpChoice, and mLogEnvelope.

Here is the call graph for this function:

◆ OnInvert()

void EffectEqualization::OnInvert ( wxCommandEvent &  event)
private

Definition at line 2935 of file Equalization.cpp.

2936 {
2937  if(!mDrawMode) // Graphic (Slider) mode. Invert the sliders.
2938  {
2939  for (size_t i = 0; i < mBandsInUse; i++)
2940  {
2941  mEQVals[i] = -mEQVals[i];
2942  int newPosn = (int)mEQVals[i];
2943  mSliders[i]->SetValue( newPosn );
2944  mSlidersOld[i] = newPosn;
2945 
2946  wxString tip;
2947  if( kThirdOct[i] < 1000.)
2948  tip.Printf( wxT("%dHz\n%.1fdB"), (int)kThirdOct[i], mEQVals[i] );
2949  else
2950  tip.Printf( wxT("%gkHz\n%.1fdB"), kThirdOct[i]/1000., mEQVals[i] );
2951  mSliders[i]->SetToolTip(tip);
2952  }
2953  GraphicEQ(mLogEnvelope.get());
2954  }
2955  else // Draw mode. Invert the points.
2956  {
2957  bool lin = IsLinear(); // refers to the 'log' or 'lin' of the frequency scale, not the amplitude
2958  size_t numPoints; // number of points in the curve/envelope
2959 
2960  // determine if log or lin curve is the current one
2961  // and find out how many points are in the curve
2962  if(lin) // lin freq scale and so envelope
2963  {
2964  numPoints = mLinEnvelope->GetNumberOfPoints();
2965  }
2966  else
2967  {
2968  numPoints = mLogEnvelope->GetNumberOfPoints();
2969  }
2970 
2971  if( numPoints == 0 )
2972  return;
2973 
2974  Doubles when{ numPoints };
2975  Doubles value{ numPoints };
2976 
2977  if(lin)
2978  mLinEnvelope->GetPoints( when.get(), value.get(), numPoints );
2979  else
2980  mLogEnvelope->GetPoints( when.get(), value.get(), numPoints );
2981 
2982  // invert the curve
2983  for (size_t i = 0; i < numPoints; i++)
2984  {
2985  if(lin)
2986  mLinEnvelope->Reassign(when[i] , -value[i]);
2987  else
2988  mLogEnvelope->Reassign(when[i] , -value[i]);
2989  }
2990 
2991  // copy it back to the other one (just in case)
2992  if(lin)
2993  EnvLinToLog();
2994  else
2995  EnvLogToLin();
2996  }
2997 
2998  // and update the display etc
2999  ForceRecalc();
3000  EnvelopeUpdated();
3001 }

References EnvelopeUpdated(), EnvLinToLog(), EnvLogToLin(), ForceRecalc(), GraphicEQ(), IsLinear(), kThirdOct, mBandsInUse, mDrawMode, mEQVals, mLinEnvelope, mLogEnvelope, mSliders, and mSlidersOld.

Here is the call graph for this function:

◆ OnLinFreq()

void EffectEqualization::OnLinFreq ( wxCommandEvent &  event)
private

Definition at line 3009 of file Equalization.cpp.

3010 {
3011  mLin = mLinFreq->IsChecked();
3012  if(IsLinear()) //going from log to lin freq scale
3013  {
3014  mFreqRuler->ruler.SetLog(false);
3016  EnvLogToLin();
3017  mEnvelope = mLinEnvelope.get();
3018  mLin = true;
3019  }
3020  else //going from lin to log freq scale
3021  {
3022  mFreqRuler->ruler.SetLog(true);
3024  EnvLinToLog();
3025  mEnvelope = mLogEnvelope.get();
3026  mLin = false;
3027  }
3028  mFreqRuler->Refresh(false);
3029  ForceRecalc();
3030 }

References EnvLinToLog(), EnvLogToLin(), ForceRecalc(), IsLinear(), mEnvelope, mFreqRuler, mHiFreq, mLin, mLinEnvelope, mLinFreq, mLoFreq, mLogEnvelope, RulerPanel::ruler, Ruler::SetLog(), and Ruler::SetRange().

Referenced by TransferDataToWindow().

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

◆ OnManage()

void EffectEqualization::OnManage ( wxCommandEvent &  event)
private

Definition at line 2918 of file Equalization.cpp.

2919 {
2920  EditCurvesDialog d(mUIParent, this, mCurve->GetSelection());
2921  d.ShowModal();
2922 
2923  // Reload the curve names
2924  UpdateCurves();
2925 
2926  // Allow control to resize
2927  mUIParent->Layout();
2928 }

References mCurve, Effect::mUIParent, and UpdateCurves().

Here is the call graph for this function:

◆ OnSize()

void EffectEqualization::OnSize ( wxSizeEvent &  event)
private

Definition at line 2820 of file Equalization.cpp.

2821 {
2822  mUIParent->Layout();
2823  event.Skip();
2824 }

References Effect::mUIParent.

◆ OnSlider()

void EffectEqualization::OnSlider ( wxCommandEvent &  event)
private

Definition at line 2826 of file Equalization.cpp.

2827 {
2828  wxSlider *s = (wxSlider *)event.GetEventObject();
2829  for (size_t i = 0; i < mBandsInUse; i++)
2830  {
2831  if( s == mSliders[i])
2832  {
2833  int posn = mSliders[i]->GetValue();
2834  if( wxGetKeyState(WXK_SHIFT) )
2835  {
2836  if( posn > mSlidersOld[i] )
2837  mEQVals[i] += (float).1;
2838  else
2839  if( posn < mSlidersOld[i] )
2840  mEQVals[i] -= .1f;
2841  }
2842  else
2843  mEQVals[i] += (posn - mSlidersOld[i]);
2844  if( mEQVals[i] > 20. )
2845  mEQVals[i] = 20.;
2846  if( mEQVals[i] < -20. )
2847  mEQVals[i] = -20.;
2848  int newPosn = (int)mEQVals[i];
2849  mSliders[i]->SetValue( newPosn );
2850  mSlidersOld[i] = newPosn;
2851  wxString tip;
2852  if( kThirdOct[i] < 1000.)
2853  tip.Printf( wxT("%dHz\n%.1fdB"), (int)kThirdOct[i], mEQVals[i] );
2854  else
2855  tip.Printf( wxT("%gkHz\n%.1fdB"), kThirdOct[i]/1000., mEQVals[i] );
2856  s->SetToolTip(tip);
2857  break;
2858  }
2859  }
2860  GraphicEQ(mLogEnvelope.get());
2861  EnvelopeUpdated();
2862 }

References EnvelopeUpdated(), GraphicEQ(), kThirdOct, mBandsInUse, mEQVals, mLogEnvelope, mSliders, and mSlidersOld.

Here is the call graph for this function:

◆ OnSliderDBMAX()

void EffectEqualization::OnSliderDBMAX ( wxCommandEvent &  event)
private

Definition at line 2898 of file Equalization.cpp.

2899 {
2901 }

References TransferDataFromWindow().

Here is the call graph for this function:

◆ OnSliderDBMIN()

void EffectEqualization::OnSliderDBMIN ( wxCommandEvent &  event)
private

Definition at line 2893 of file Equalization.cpp.

2894 {
2896 }

References TransferDataFromWindow().

Here is the call graph for this function:

◆ OnSliderM()

void EffectEqualization::OnSliderM ( wxCommandEvent &  event)
private

Definition at line 2887 of file Equalization.cpp.

2888 {
2890  ForceRecalc();
2891 }

References ForceRecalc(), and TransferDataFromWindow().

Here is the call graph for this function:

◆ PopulateOrExchange()

void EffectEqualization::PopulateOrExchange ( ShuttleGui S)
overridevirtual

Reimplemented from Effect.

Definition at line 758 of file Equalization.cpp.

759 {
760  if ( (S.GetMode() == eIsCreating ) && !IsBatchProcessing() )
762 
763  //LoadCurves();
764 
765 
766 
767  S.SetBorder(0);
768 
769  S.SetSizerProportion(1);
770  S.Prop(1).StartMultiColumn(1, wxEXPAND);
771  {
772  S.SetStretchyCol(0);
773  //S.SetStretchyRow(0); // The 5px Top border
774  S.SetStretchyRow(1); // The Graph
775  S.SetStretchyRow(2); // The EQ sliders
776  szrV = S.GetSizer();
777 
778  // -------------------------------------------------------------------
779  // ROW 0: Top border
780  // -------------------------------------------------------------------
781  S.AddSpace(5);
782 
783  // -------------------------------------------------------------------
784  // ROW 1: Equalization panel and sliders for vertical scale
785  // -------------------------------------------------------------------
786  S.SetSizerProportion(1);
787  S.Prop(1).StartMultiColumn(3, wxEXPAND);
788  {
789  S.SetStretchyCol(1);
790  S.SetStretchyRow(0);
791  szr1 = S.GetSizer();
792 
793  S.StartVerticalLay(wxEXPAND, 1);
794  {
796  S.GetParent(), wxID_ANY, wxVERTICAL,
797  wxSize{ 100, 100 }, // Ruler can't handle small sizes
798  RulerPanel::Range{ 60.0, -120.0 },
800  XO("dB"),
802  .LabelEdges(true)
803  .TicksAtExtremes(true)
804  .TickColour( { 0, 0, 0 } )
805  );
806 
807  S.Prop(0).AddSpace(0, 1);
808  S.Prop(1)
809  .Position(wxEXPAND)
811  S.AddSpace(0, 1);
812  }
813  S.EndVerticalLay();
814 
815  mPanel = safenew EqualizationPanel(S.GetParent(), wxID_ANY, this);
816  S.Prop(1)
817  .Position(wxEXPAND)
818  .MinSize( { wxDefaultCoord, wxDefaultCoord } )
819  .AddWindow(mPanel);
820 
821  S.SetBorder(5);
822  S.StartVerticalLay();
823  {
824  S.AddVariableText(XO("+ dB"), false, wxCENTER);
826  .Name(XO("Max dB"))
827  .Style(wxSL_VERTICAL | wxSL_INVERSE)
828  .AddSlider( {}, 30, 60, 0);
829 #if wxUSE_ACCESSIBILITY
830  mdBMaxSlider->SetAccessible(safenew SliderAx(mdBMaxSlider, XO("%d dB")));
831 #endif
832 
834  .Name(XO("Min dB"))
835  .Style(wxSL_VERTICAL | wxSL_INVERSE)
836  .AddSlider( {}, -30, -10, -120);
837  S.AddVariableText(XO("- dB"), false, wxCENTER);
838 #if wxUSE_ACCESSIBILITY
839  mdBMinSlider->SetAccessible(safenew SliderAx(mdBMinSlider, XO("%d dB")));
840 #endif
841  }
842  S.EndVerticalLay();
843  S.SetBorder(0);
844 
845  // -------------------------------------------------------------------
846  // Frequency ruler below graph
847  // -------------------------------------------------------------------
848 
849  // Column 1 is empty
850  S.AddSpace(1, 1);
851 
853  S.GetParent(), wxID_ANY, wxHORIZONTAL,
854  wxSize{ 100, 100 }, // Ruler can't handle small sizes
855  RulerPanel::Range{ mLoFreq, mHiFreq },
857  XO("Hz"),
859  .Log(true)
860  .Flip(true)
861  .LabelEdges(true)
862  .TicksAtExtremes(true)
863  .TickColour( { 0, 0, 0 } )
864  );
865 
866  S.SetBorder(1);
867  S.Prop(1)
868  .Position(wxEXPAND | wxALIGN_LEFT | wxALIGN_TOP | wxLEFT)
870  S.SetBorder(0);
871 
872  // Column 3 is empty
873  S.AddSpace(1, 1);
874  }
875  S.EndMultiColumn();
876 
877  // -------------------------------------------------------------------
878  // ROW 2: Graphic EQ
879  // -------------------------------------------------------------------
880  S.SetSizerProportion(1);
881  S.StartHorizontalLay(wxEXPAND, 1);
882  {
883  szrG = S.GetSizer();
884 
885  // Panel used to host the sliders since they will be positioned manually.
886  //mGraphicPanel = S.Prop(1)
887  //.Position(wxEXPAND)
888  //.Size( { -1, 150 } )
889  //.StartPanel();
890  wxWindow *pParent = S.GetParent();
891  S.AddSpace(15,0);
892  {
893 
894  // for (int i = 0; (i < NUMBER_OF_BANDS) && (kThirdOct[i] <= mHiFreq); ++i)
895  // May show more sliders than needed. Fixes Bug 2269
896  for (int i = 0; i < NUMBER_OF_BANDS; ++i)
897  {
898  TranslatableString freq = kThirdOct[i] < 1000.
899  ? XO("%d Hz").Format((int)kThirdOct[i])
900  : XO("%g kHz").Format(kThirdOct[i] / 1000.);
901  TranslatableString fNum = kThirdOct[i] < 1000.
902  ? Verbatim("%d").Format((int)kThirdOct[i])
903  /* i18n-hint k is SI abbreviation for x1,000. Usually unchanged in translation. */
904  : XO("%gk").Format(kThirdOct[i] / 1000.);
905  S.StartVerticalLay();
906  {
907  S.AddFixedText( fNum );
908  mSliders[i] = safenew wxSliderWrapper(pParent, ID_Slider + i, 0, -20, +20,
909  wxDefaultPosition, wxSize(-1,50), wxSL_VERTICAL | wxSL_INVERSE);
910 
911 #if wxUSE_ACCESSIBILITY
912  mSliders[i]->SetAccessible(safenew SliderAx(mSliders[i], XO("%d dB")));
913 #endif
914 
915  mSlidersOld[i] = 0;
916  mEQVals[i] = 0.;
917  S.Prop(1)
918  .Name(freq)
919  .ConnectRoot(
920  wxEVT_ERASE_BACKGROUND, &EffectEqualization::OnErase)
921  .Position(wxEXPAND)
922  .Size({ -1, 50 })
923  .AddWindow(mSliders[i]);
924  }
925  S.EndVerticalLay();
926  }
927  S.AddSpace(15,0);
928 
929  } //S.EndPanel();
930  }
931  S.EndHorizontalLay();
932 
933  // -------------------------------------------------------------------
934  // ROW 4: Various controls
935  // -------------------------------------------------------------------
936  S.SetSizerProportion(1);
937  S.Prop(1).StartMultiColumn(7, wxALIGN_CENTER_HORIZONTAL);
938  {
939  S.SetBorder(5);
940 
941  S.AddSpace(5, 5);
942 
943  if( mOptions == kEqLegacy )
944  {
945  S.StartHorizontalLay(wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
946  {
947  S.AddPrompt(XXO("&EQ Type:"));
948  }
949  S.EndHorizontalLay();
950 
951  S.StartHorizontalLay(wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL, 1);
952  {
953  S.StartHorizontalLay(wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL, 1);
954  {
955  mDraw = S.Id(ID_Draw)
956  .Name(XO("Draw Curves"))
957  .AddRadioButton(XXO("&Draw"));
958 
959  mGraphic = S.Id(ID_Graphic)
960  .Name(XO("Graphic EQ"))
961  .AddRadioButtonToGroup(XXO("&Graphic"));
962  }
963  S.EndHorizontalLay();
964  }
965  S.EndHorizontalLay();
966  }
967 
968  S.StartHorizontalLay(wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL, 0);
969  {
970  szrH = S.GetSizer();
971 
972  S.StartHorizontalLay(wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL, 1);
973  {
974  szrI = S.GetSizer();
975 
977  .Name(XO("Interpolation type"))
978  .AddChoice( {},
980 #if wxUSE_ACCESSIBILITY
981  // so that name can be set on a standard control
983 #endif
984  }
985  S.EndHorizontalLay();
986 
987  S.StartHorizontalLay(wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL, 1);
988  {
989  szrL = S.GetSizer();
990 
991  mLinFreq = S.Id(ID_Linear)
992  .Name(XO("Linear Frequency Scale"))
993  .AddCheckBox(XXO("Li&near Frequency Scale"), false);
994  }
995  S.EndHorizontalLay();
996  }
997  S.EndHorizontalLay();
998 
999  // -------------------------------------------------------------------
1000  // Filter length grouping
1001  // -------------------------------------------------------------------
1002 
1003  if( mOptions == kEqLegacy ){
1004  S.StartHorizontalLay(wxEXPAND, 0);
1005  {
1006  S.StartHorizontalLay(wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL, 0);
1007  {
1008  S.AddPrompt(XXO("Length of &Filter:"));
1009  }
1010  S.EndHorizontalLay();
1011 
1012  S.StartHorizontalLay(wxEXPAND, 1);
1013  {
1014  mMSlider = S.Id(ID_Length)
1015  .Name(XO("Length of Filter"))
1016  .Style(wxSL_HORIZONTAL)
1017  .AddSlider( {}, (mM - 1) / 2, 4095, 10);
1018  }
1019  S.EndHorizontalLay();
1020 
1021  S.StartHorizontalLay(wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL, 0);
1022  {
1023  wxString label;
1024  label.Printf(wxT("%ld"), mM);
1025  mMText = S.Name( Verbatim( label ) )
1026  // fix for bug 577 (NVDA/Narrator screen readers do not
1027  // read static text in dialogs)
1028  .AddVariableText( Verbatim( label ) );
1029  }
1030  S.EndHorizontalLay();
1031  }
1032  S.EndHorizontalLay();
1033 
1034  S.AddSpace(1, 1);
1035  }
1036 
1037  S.AddSpace(5, 5);
1038 
1039  if( mOptions == kEqLegacy ){
1040  S.AddSpace(5, 5);
1041  S.StartHorizontalLay(wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
1042  {
1043  S.AddPrompt(XXO("&Select Curve:"));
1044  }
1045  S.EndHorizontalLay();
1046 
1047  S.StartHorizontalLay(wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL, 1);
1048  {
1049  S.StartHorizontalLay(wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL, 1);
1050  {
1051  mCurve = S.Id(ID_Curve)
1052  .Name(XO("Select Curve"))
1053  .AddChoice( {},
1054  [this]{
1055  TranslatableStrings curves;
1056  for (const auto &curve : mCurves)
1057  curves.push_back( Verbatim( curve.Name ) );
1058  return curves;
1059  }()
1060  );
1061  }
1062  S.EndHorizontalLay();
1063  }
1064  S.EndHorizontalLay();
1065 
1066  S.Id(ID_Manage).AddButton(XXO("S&ave/Manage Curves..."));
1067  }
1068 
1069  S.StartHorizontalLay(wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL, 1);
1070  {
1071  S.Id(ID_Clear).AddButton(XXO("Fla&tten"));
1072  S.Id(ID_Invert).AddButton(XXO("&Invert"));
1073 
1074  mGridOnOff = S.Id(ID_Grid)
1075  .Name(XO("Show grid lines"))
1076  .AddCheckBox(XXO("Show g&rid lines"), false);
1077  }
1078  S.EndHorizontalLay();
1079 
1080  S.AddSpace(5, 5);
1081  }
1082  S.EndMultiColumn();
1083  }
1084  S.EndMultiColumn();
1085 
1086 #ifdef EXPERIMENTAL_EQ_SSE_THREADED
1087  if (mEffectEqualization48x)
1088  {
1089  // -------------------------------------------------------------------
1090  // ROW 6: Processing routine selection
1091  // -------------------------------------------------------------------
1092 
1093  // Column 1 is blank
1094  S.AddSpace(1, 1);
1095 
1096  S.StartHorizontalLay();
1097  {
1098  S.AddUnits(XO("&Processing: "));
1099 
1100  // update the control state
1101  int mathPath = EffectEqualization48x::GetMathPath();
1102  int value =
1103  (mathPath & MATH_FUNCTION_SSE)
1104  ? (mathPath & MATH_FUNCTION_THREADED)
1105  ? 2
1106  : 1
1107  : false // (mathPath & MATH_FUNCTION_AVX) // not implemented
1108  ? (mathPath & MATH_FUNCTION_THREADED)
1109  ? 4
1110  : 3
1111  : 0;
1112 
1113  mMathProcessingType[0] = S.Id(ID_DefaultMath)
1114  .AddRadioButton(XXO("D&efault"),
1115  0, value);
1116  mMathProcessingType[1] = S.Id(ID_SSE)
1117  .Disable(!EffectEqualization48x::GetMathCaps()->SSE)
1118  .AddRadioButtonToGroup(XXO("&SSE"),
1119  1, value);
1120  mMathProcessingType[2] = S.Id(ID_SSEThreaded)
1121  .Disable(!EffectEqualization48x::GetMathCaps()->SSE)
1122  .AddRadioButtonToGroup(XXO("SSE &Threaded"),
1123  2, value);
1124  mMathProcessingType[3] = S.Id(ID_AVX)
1125  // not implemented
1126  .Disable(true /* !EffectEqualization48x::GetMathCaps()->AVX */)
1127  .AddRadioButtonToGroup(XXO("A&VX"),
1128  3, value);
1129  mMathProcessingType[4] = S.Id(ID_AVXThreaded)
1130  // not implemented
1131  .Disable(true /* !EffectEqualization48x::GetMathCaps()->AVX */)
1132  .AddRadioButtonToGroup(XXO("AV&X Threaded"),
1133  4, value);
1134  S.Id(ID_Bench).AddButton(XXO("&Bench"));
1135  }
1136  S.EndHorizontalLay();
1137 
1138  // Column 3 is blank
1139  S.AddSpace(1, 1);
1140  }
1141 #endif
1142 
1143  mUIParent->SetAutoLayout(false);
1144  if( mOptions != kEqOptionGraphic)
1145  mUIParent->Layout();
1146 
1147  if( mOptions == kEqOptionCurve)
1148  mDrawMode = true;
1149  if( mOptions == kEqOptionGraphic)
1150  mDrawMode = false;
1151 
1152  // "show" settings for graphics mode before setting the size of the dialog
1153  // as this needs more space than draw mode
1154  szrV->Show(szrG,!mDrawMode); // eq sliders
1155  szrH->Show(szrI,true); // interpolation choice
1156  szrH->Show(szrL,false); // linear freq checkbox
1157 
1158  if( mOptions == kEqOptionGraphic){
1159  mPanel->Show( false );
1160  wxSize sz = szrV->GetMinSize();
1161  sz += wxSize( 30, 0);
1162  mUIParent->SetMinSize(sz);
1163  }
1164  else{
1165  mPanel->Show( true );
1166  szrV->Show(szr1, true);
1167  // This sizing calculation is hacky.
1168  // Rather than set the true minimum size we set a size we would
1169  // like to have.
1170  // This makes the default size of the dialog good, but has the
1171  // downside that the user can't adjust the dialog smaller.
1172  wxSize sz = szrV->GetMinSize();
1173  sz += wxSize( 400, 100);
1174  szrV->SetMinSize(sz);
1175  }
1176  ForceRecalc();
1177 
1178  return;
1179 }

References ShuttleGuiBase::AddButton(), ShuttleGuiBase::AddChoice(), ShuttleGuiBase::AddFixedText(), ShuttleGuiBase::AddPrompt(), ShuttleGuiBase::AddRadioButton(), ShuttleGuiBase::AddRadioButtonToGroup(), ShuttleGuiBase::AddSlider(), ShuttleGui::AddSpace(), ShuttleGuiBase::AddUnits(), ShuttleGuiBase::AddVariableText(), ShuttleGuiBase::AddWindow(), ShuttleGui::ConnectRoot(), ShuttleGui::Disable(), eIsCreating, ShuttleGuiBase::EndHorizontalLay(), ShuttleGuiBase::EndMultiColumn(), ShuttleGuiBase::EndVerticalLay(), EqualizationPanel, ForceRecalc(), TranslatableString::Format(), Effect::GetCurrentSettingsGroup(), ShuttleGui::GetMode(), ShuttleGuiBase::GetParent(), ShuttleGuiBase::GetSizer(), ShuttleGui::Id(), ID_Clear, ID_Curve, ID_dBMax, ID_dBMin, ID_Draw, ID_Graphic, ID_Grid, ID_Interp, ID_Invert, ID_Length, ID_Linear, ID_Manage, ID_Slider, Ruler::IntFormat, Effect::IsBatchProcessing(), kEqLegacy, kEqOptionCurve, kEqOptionGraphic, kInterpStrings, kThirdOct, label, RulerPanel::Options::LabelEdges(), Ruler::LinearDBFormat, Effect::LoadUserPreset(), RulerPanel::Options::Log(), mCurve, mCurves, mdBMaxSlider, mdBMinSlider, mdBRuler, mDraw, mDrawMode, mEQVals, mFreqRuler, mGraphic, mGridOnOff, ShuttleGui::MinSize(), mInterpChoice, mLinFreq, mM, mMSlider, mMText, mOptions, mPanel, Msgids(), mSliders, mSlidersOld, Effect::mUIParent, ShuttleGui::Name(), nInterpolations, NUMBER_OF_BANDS, OnErase(), ShuttleGui::Position(), ShuttleGui::Prop(), safenew, ShuttleGuiBase::SetBorder(), ShuttleGuiBase::SetSizerProportion(), ShuttleGuiBase::SetStretchyCol(), ShuttleGuiBase::SetStretchyRow(), ShuttleGuiBase::StartHorizontalLay(), ShuttleGuiBase::StartMultiColumn(), ShuttleGuiBase::StartVerticalLay(), ShuttleGui::Style(), szr1, szrG, szrH, szrI, szrL, szrV, Verbatim(), XO, and XXO.

Here is the call graph for this function:

◆ Process()

bool EffectEqualization::Process ( )
overridevirtual

Reimplemented from Effect.

Definition at line 708 of file Equalization.cpp.

709 {
710 #ifdef EXPERIMENTAL_EQ_SSE_THREADED
711  if(mEffectEqualization48x) {
712  if(mBench) {
713  mBench=false;
714  return mEffectEqualization48x->Benchmark(this);
715  }
716  else
717  return mEffectEqualization48x->Process(this);
718  }
719 #endif
720  this->CopyInputTracks(); // Set up mOutputTracks.
721  CalcFilter();
722  bool bGoodResult = true;
723 
724  int count = 0;
725  for( auto track : mOutputTracks->Selected< WaveTrack >() ) {
726  double trackStart = track->GetStartTime();
727  double trackEnd = track->GetEndTime();
728  double t0 = mT0 < trackStart? trackStart: mT0;
729  double t1 = mT1 > trackEnd? trackEnd: mT1;
730 
731  if (t1 > t0) {
732  auto start = track->TimeToLongSamples(t0);
733  auto end = track->TimeToLongSamples(t1);
734  auto len = end - start;
735 
736  if (!ProcessOne(count, track, start, len))
737  {
738  bGoodResult = false;
739  break;
740  }
741  }
742 
743  count++;
744  }
745 
746  this->ReplaceProcessedTracks(bGoodResult);
747  return bGoodResult;
748 }

References CalcFilter(), Effect::CopyInputTracks(), Effect::mOutputTracks, Effect::mT0, Effect::mT1, ProcessOne(), and Effect::ReplaceProcessedTracks().

Here is the call graph for this function:

◆ ProcessOne()

bool EffectEqualization::ProcessOne ( int  count,
WaveTrack t,
sampleCount  start,
sampleCount  len 
)
private

Definition at line 1299 of file Equalization.cpp.

1301 {
1302  // create a NEW WaveTrack to hold all of the output, including 'tails' each end
1303  auto output = t->EmptyCopy();
1305 
1306  wxASSERT(mM - 1 < windowSize);
1307  size_t L = windowSize - (mM - 1); //Process L samples at a go
1308  auto s = start;
1309  auto idealBlockLen = t->GetMaxBlockSize() * 4;
1310  if (idealBlockLen % L != 0)
1311  idealBlockLen += (L - (idealBlockLen % L));
1312 
1313  Floats buffer{ idealBlockLen };
1314 
1315  Floats window1{ windowSize };
1316  Floats window2{ windowSize };
1317  float *thisWindow = window1.get();
1318  float *lastWindow = window2.get();
1319 
1320  auto originalLen = len;
1321 
1322  for(size_t i = 0; i < windowSize; i++)
1323  lastWindow[i] = 0;
1324 
1325  TrackProgress(count, 0.);
1326  bool bLoopSuccess = true;
1327  size_t wcopy = 0;
1328  int offset = (mM - 1) / 2;
1329 
1330  while (len != 0)
1331  {
1332  auto block = limitSampleBufferSize( idealBlockLen, len );
1333 
1334  t->GetFloats(buffer.get(), s, block);
1335 
1336  for(size_t i = 0; i < block; i += L) //go through block in lumps of length L
1337  {
1338  wcopy = std::min <size_t> (L, block - i);
1339  for(size_t j = 0; j < wcopy; j++)
1340  thisWindow[j] = buffer[i+j]; //copy the L (or remaining) samples
1341  for(auto j = wcopy; j < windowSize; j++)
1342  thisWindow[j] = 0; //this includes the padding
1343 
1344  Filter(windowSize, thisWindow);
1345 
1346  // Overlap - Add
1347  for(size_t j = 0; (j < mM - 1) && (j < wcopy); j++)
1348  buffer[i+j] = thisWindow[j] + lastWindow[L + j];
1349  for(size_t j = mM - 1; j < wcopy; j++)
1350  buffer[i+j] = thisWindow[j];
1351 
1352  std::swap( thisWindow, lastWindow );
1353  } //next i, lump of this block
1354 
1355  output->Append((samplePtr)buffer.get(), floatSample, block);
1356  len -= block;
1357  s += block;
1358 
1359  if (TrackProgress(count, ( s - start ).as_double() /
1360  originalLen.as_double()))
1361  {
1362  bLoopSuccess = false;
1363  break;
1364  }
1365  }
1366 
1367  if(bLoopSuccess)
1368  {
1369  // mM-1 samples of 'tail' left in lastWindow, get them now
1370  if(wcopy < (mM - 1)) {
1371  // Still have some overlap left to process
1372  // (note that lastWindow and thisWindow have been exchanged at this point
1373  // so that 'thisWindow' is really the window prior to 'lastWindow')
1374  size_t j = 0;
1375  for(; j < mM - 1 - wcopy; j++)
1376  buffer[j] = lastWindow[wcopy + j] + thisWindow[L + wcopy + j];
1377  // And fill in the remainder after the overlap
1378  for( ; j < mM - 1; j++)
1379  buffer[j] = lastWindow[wcopy + j];
1380  } else {
1381  for(size_t j = 0; j < mM - 1; j++)
1382  buffer[j] = lastWindow[wcopy + j];
1383  }
1384  output->Append((samplePtr)buffer.get(), floatSample, mM - 1);
1385  output->Flush();
1386 
1387  // now move the appropriate bit of the output back to the track
1388  // (this could be enhanced in the future to use the tails)
1389  double offsetT0 = t->LongSamplesToTime(offset);
1390  double lenT = t->LongSamplesToTime(originalLen);
1391  // 'start' is the sample offset in 't', the passed in track
1392  // 'startT' is the equivalent time value
1393  // 'output' starts at zero
1394  double startT = t->LongSamplesToTime(start);
1395 
1396  //output has one waveclip for the total length, even though
1397  //t might have whitespace separating multiple clips
1398  //we want to maintain the original clip structure, so
1399  //only paste the intersections of the NEW clip.
1400 
1401  //Find the bits of clips that need replacing
1402  std::vector<std::pair<double, double> > clipStartEndTimes;
1403  std::vector<std::pair<double, double> > clipRealStartEndTimes; //the above may be truncated due to a clip being partially selected
1404  for (const auto &clip : t->GetClips())
1405  {
1406  double clipStartT;
1407  double clipEndT;
1408 
1409  clipStartT = clip->GetStartTime();
1410  clipEndT = clip->GetEndTime();
1411  if( clipEndT <= startT )
1412  continue; // clip is not within selection
1413  if( clipStartT >= startT + lenT )
1414  continue; // clip is not within selection
1415 
1416  //save the actual clip start/end so that we can rejoin them after we paste.
1417  clipRealStartEndTimes.push_back(std::pair<double,double>(clipStartT,clipEndT));
1418 
1419  if( clipStartT < startT ) // does selection cover the whole clip?
1420  clipStartT = startT; // don't copy all the NEW clip
1421  if( clipEndT > startT + lenT ) // does selection cover the whole clip?
1422  clipEndT = startT + lenT; // don't copy all the NEW clip
1423 
1424  //save them
1425  clipStartEndTimes.push_back(std::pair<double,double>(clipStartT,clipEndT));
1426  }
1427  //now go thru and replace the old clips with NEW
1428  for(unsigned int i = 0; i < clipStartEndTimes.size(); i++)
1429  {
1430  //remove the old audio and get the NEW
1431  t->Clear(clipStartEndTimes[i].first,clipStartEndTimes[i].second);
1432  auto toClipOutput = output->Copy(clipStartEndTimes[i].first-startT+offsetT0,clipStartEndTimes[i].second-startT+offsetT0);
1433  //put the processed audio in
1434  t->Paste(clipStartEndTimes[i].first, toClipOutput.get());
1435  //if the clip was only partially selected, the Paste will have created a split line. Join is needed to take care of this
1436  //This is not true when the selection is fully contained within one clip (second half of conditional)
1437  if( (clipRealStartEndTimes[i].first != clipStartEndTimes[i].first ||
1438  clipRealStartEndTimes[i].second != clipStartEndTimes[i].second) &&
1439  !(clipRealStartEndTimes[i].first <= startT &&
1440  clipRealStartEndTimes[i].second >= startT+lenT) )
1441  t->Join(clipRealStartEndTimes[i].first,clipRealStartEndTimes[i].second);
1442  }
1443  }
1444 
1445  return bLoopSuccess;
1446 }

References WaveTrack::Clear(), WaveTrack::ConvertToSampleFormat(), WaveTrack::EmptyCopy(), Filter(), floatSample, WaveTrack::GetClips(), WaveTrack::GetFloats(), WaveTrack::GetMaxBlockSize(), WaveTrack::Join(), limitSampleBufferSize(), WaveTrack::LongSamplesToTime(), mM, WaveTrack::Paste(), anonymous_namespace{NoteTrack.cpp}::swap(), Effect::TrackProgress(), and windowSize.

Referenced by Process().

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

◆ SaveCurves()

void EffectEqualization::SaveCurves ( const wxString &  fileName = {})
private

Definition at line 1833 of file Equalization.cpp.

1834 {
1835  wxFileName fn;
1836  if( fileName.empty() )
1837  {
1838  // Construct default curve filename
1839  //
1840  // LLL: Wouldn't you know that as of WX 2.6.2, there is a conflict
1841  // between wxStandardPaths and wxConfig under Linux. The latter
1842  // creates a normal file as "$HOME/.audacity", while the former
1843  // expects the ".audacity" portion to be a directory.
1844  fn = wxFileName( FileNames::DataDir(), wxT("EQCurves.xml") );
1845 
1846  // If the directory doesn't exist...
1847  if( !fn.DirExists() )
1848  {
1849  // Attempt to create it
1850  if( !fn.Mkdir( fn.GetPath(), 511, wxPATH_MKDIR_FULL ) )
1851  {
1852  // MkDir() will emit message
1853  return;
1854  }
1855  }
1856  }
1857  else
1858  fn = fileName;
1859 
1860  GuardedCall( [&] {
1861  // Create/Open the file
1862  const wxString fullPath{ fn.GetFullPath() };
1863  XMLFileWriter eqFile{ fullPath, XO("Error Saving Equalization Curves") };
1864 
1865  // Write the curves
1866  WriteXML( eqFile );
1867 
1868  eqFile.Commit();
1869  } );
1870 }

References FileNames::DataDir(), fn, GuardedCall(), WriteXML(), and XO.

Referenced by EditCurvesDialog::OnExport(), EditCurvesDialog::OnOK(), UpdateDefaultCurves(), and ValidateUI().

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

◆ Select()

void EffectEqualization::Select ( int  sel)
private

Definition at line 2062 of file Equalization.cpp.

2063 {
2064  // Set current choice
2065  if (mCurve)
2066  {
2067  mCurve->SetSelection( curve );
2068  mCurveName = mCurves[ curve ].Name;
2069  }
2070 }

References mCurve, mCurveName, and mCurves.

Referenced by EnvelopeUpdated(), ErrMin(), setCurve(), and ValidateUI().

Here is the caller graph for this function:

◆ SetAutomationParameters()

bool EffectEqualization::SetAutomationParameters ( CommandParameters parms)
overridevirtual

Reimplemented from Effect.

Definition at line 422 of file Equalization.cpp.

423 {
424  // Pretty sure the interpolation name shouldn't have been interpreted when
425  // specified in chains, but must keep it that way for compatibility.
426 
427  ReadAndVerifyInt(FilterLength);
428  //ReadAndVerifyString(CurveName);
429  ReadAndVerifyBool(InterpLin);
431 
432  mM = FilterLength;
433  //mCurveName = CurveName;
434  mLin = InterpLin;
435  mInterp = InterpMeth;
436 
437  if (InterpMeth >= nInterpolations)
438  {
439  InterpMeth -= nInterpolations;
440  }
441 
442  mEnvelope = (mLin ? mLinEnvelope : mLogEnvelope).get();
443 
444  return true;
445 }

References kInterpStrings, mEnvelope, mInterp, mLin, mLinEnvelope, mLogEnvelope, mM, nInterpolations, ReadAndVerifyBool, ReadAndVerifyEnum, and ReadAndVerifyInt.

◆ setCurve() [1/3]

void EffectEqualization::setCurve ( const wxString &  curveName)
private

Definition at line 2041 of file Equalization.cpp.

2042 {
2043  unsigned i = 0;
2044  for( i = 0; i < mCurves.size(); i++ )
2045  if( curveName == mCurves[ i ].Name )
2046  break;
2047  if( i == mCurves.size())
2048  {
2050  XO("Requested curve not found, using 'unnamed'"),
2051  wxOK|wxICON_ERROR,
2052  XO("Curve not found") );
2053  setCurve();
2054  }
2055  else
2056  setCurve( i );
2057 }

References mCurves, Effect::MessageBox(), setCurve(), and XO.

Here is the call graph for this function:

◆ setCurve() [2/3]

void EffectEqualization::setCurve ( int  currentCurve)
private

Definition at line 1875 of file Equalization.cpp.

1876 {
1877  // Set current choice
1878  wxASSERT( currentCurve < (int) mCurves.size() );
1879  Select(currentCurve);
1880 
1881  Envelope *env;
1882  int numPoints = (int) mCurves[currentCurve].points.size();
1883 
1884  if (mLin) { // linear freq mode
1885  env = mLinEnvelope.get();
1886  }
1887  else { // log freq mode
1888  env = mLogEnvelope.get();
1889  }
1890  env->Flatten(0.);
1891  env->SetTrackLen(1.0);
1892 
1893  // Handle special case of no points.
1894  if (numPoints == 0) {
1895  ForceRecalc();
1896  return;
1897  }
1898 
1899  double when, value;
1900 
1901  // Handle special case 1 point.
1902  if (numPoints == 1) {
1903  // only one point, so ensure it is in range then return.
1904  when = mCurves[currentCurve].points[0].Freq;
1905  if (mLin) {
1906  when = when / mHiFreq;
1907  }
1908  else { // log scale
1909  // We don't go below loFreqI (20 Hz) in log view.
1910  double loLog = log10((double)loFreqI);
1911  double hiLog = log10(mHiFreq);
1912  double denom = hiLog - loLog;
1913  when = (log10(std::max((double) loFreqI, when)) - loLog)/denom;
1914  }
1915  value = mCurves[currentCurve].points[0].dB;
1916  env->Insert(std::min(1.0, std::max(0.0, when)), value);
1917  ForceRecalc();
1918  return;
1919  }
1920 
1921  // We have at least two points, so ensure they are in frequency order.
1922  std::sort(mCurves[currentCurve].points.begin(),
1923  mCurves[currentCurve].points.end());
1924 
1925  if (mCurves[currentCurve].points[0].Freq < 0) {
1926  // Corrupt or invalid curve, so bail.
1927  ForceRecalc();
1928  return;
1929  }
1930 
1931  if(mLin) { // linear Hz scale
1932  for(int pointCount = 0; pointCount < numPoints; pointCount++) {
1933  when = mCurves[currentCurve].points[pointCount].Freq / mHiFreq;
1934  value = mCurves[currentCurve].points[pointCount].dB;
1935  if(when <= 1) {
1936  env->Insert(when, value);
1937  if (when == 1)
1938  break;
1939  }
1940  else {
1941  // There are more points at higher freqs,
1942  // so interpolate next one then stop.
1943  when = 1.0;
1944  double nextDB = mCurves[currentCurve].points[pointCount].dB;
1945  if (pointCount > 0) {
1946  double nextF = mCurves[currentCurve].points[pointCount].Freq;
1947  double lastF = mCurves[currentCurve].points[pointCount-1].Freq;
1948  double lastDB = mCurves[currentCurve].points[pointCount-1].dB;
1949  value = lastDB +
1950  ((nextDB - lastDB) *
1951  ((mHiFreq - lastF) / (nextF - lastF)));
1952  }
1953  else
1954  value = nextDB;
1955  env->Insert(when, value);
1956  break;
1957  }
1958  }
1959  }
1960  else { // log Hz scale
1961  double loLog = log10((double) loFreqI);
1962  double hiLog = log10(mHiFreq);
1963  double denom = hiLog - loLog;
1964  int firstAbove20Hz;
1965 
1966  // log scale EQ starts at 20 Hz (threshold of hearing).
1967  // so find the first point (if any) above 20 Hz.
1968  for (firstAbove20Hz = 0; firstAbove20Hz < numPoints; firstAbove20Hz++) {
1969  if (mCurves[currentCurve].points[firstAbove20Hz].Freq > loFreqI)
1970  break;
1971  }
1972 
1973  if (firstAbove20Hz == numPoints) {
1974  // All points below 20 Hz, so just use final point.
1975  when = 0.0;
1976  value = mCurves[currentCurve].points[numPoints-1].dB;
1977  env->Insert(when, value);
1978  ForceRecalc();
1979  return;
1980  }
1981 
1982  if (firstAbove20Hz > 0) {
1983  // At least one point is before 20 Hz and there are more
1984  // beyond 20 Hz, so interpolate the first
1985  double prevF = mCurves[currentCurve].points[firstAbove20Hz-1].Freq;
1986  prevF = log10(std::max(1.0, prevF)); // log zero is bad.
1987  double prevDB = mCurves[currentCurve].points[firstAbove20Hz-1].dB;
1988  double nextF = log10(mCurves[currentCurve].points[firstAbove20Hz].Freq);
1989  double nextDB = mCurves[currentCurve].points[firstAbove20Hz].dB;
1990  when = 0.0;
1991  value = nextDB - ((nextDB - prevDB) * ((nextF - loLog) / (nextF - prevF)));
1992  env->Insert(when, value);
1993  }
1994 
1995  // Now get the rest.
1996  for(int pointCount = firstAbove20Hz; pointCount < numPoints; pointCount++)
1997  {
1998  double flog = log10(mCurves[currentCurve].points[pointCount].Freq);
1999  wxASSERT(mCurves[currentCurve].points[pointCount].Freq >= loFreqI);
2000 
2001  when = (flog - loLog)/denom;
2002  value = mCurves[currentCurve].points[pointCount].dB;
2003  if(when <= 1.0) {
2004  env->Insert(when, value);
2005  }
2006  else {
2007  // This looks weird when adjusting curve in Draw mode if
2008  // there is a point off-screen.
2009 
2010  /*
2011  // we have a point beyond fs/2. Insert it so that env code can use it.
2012  // but just this one, we have no use for the rest
2013  env->SetTrackLen(when); // can't Insert if the envelope isn't long enough
2014  env->Insert(when, value);
2015  break;
2016  */
2017 
2018  // interpolate the final point instead
2019  when = 1.0;
2020  if (pointCount > 0) {
2021  double lastDB = mCurves[currentCurve].points[pointCount-1].dB;
2022  double logLastF =
2023  log10(mCurves[currentCurve].points[pointCount-1].Freq);
2024  value = lastDB +
2025  ((value - lastDB) *
2026  ((log10(mHiFreq) - logLastF) / (flog - logLastF)));
2027  }
2028  env->Insert(when, value);
2029  break;
2030  }
2031  }
2032  }
2033  ForceRecalc();
2034 }

References Envelope::Flatten(), ForceRecalc(), Envelope::Insert(), loFreqI, mCurves, mHiFreq, min(), mLin, mLinEnvelope, mLogEnvelope, Select(), and Envelope::SetTrackLen().

Referenced by EditCurvesDialog::OnOK().

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

◆ setCurve() [3/3]

void EffectEqualization::setCurve ( void  )
private

Definition at line 2036 of file Equalization.cpp.

2037 {
2038  setCurve((int) mCurves.size() - 1);
2039 }

References mCurves.

Referenced by DefineParams(), Init(), OnCurve(), setCurve(), and UpdateCurves().

Here is the caller graph for this function:

◆ spline()

void EffectEqualization::spline ( double  x[],
double  y[],
size_t  n,
double  y2[] 
)
private

Definition at line 2773 of file Equalization.cpp.

2774 {
2775  wxASSERT( n > 0 );
2776 
2777  double p, sig;
2778  Doubles u{ n };
2779 
2780  y2[0] = 0.; //
2781  u[0] = 0.; //'natural' boundary conditions
2782  for (size_t i = 1; i + 1 < n; i++)
2783  {
2784  sig = ( x[i] - x[i-1] ) / ( x[i+1] - x[i-1] );
2785  p = sig * y2[i-1] + 2.;
2786  y2[i] = (sig - 1.)/p;
2787  u[i] = ( y[i+1] - y[i] ) / ( x[i+1] - x[i] ) - ( y[i] - y[i-1] ) / ( x[i] - x[i-1] );
2788  u[i] = (6.*u[i]/( x[i+1] - x[i-1] ) - sig * u[i-1]) / p;
2789  }
2790  y2[n - 1] = 0.;
2791  for (size_t i = n - 1; i--;)
2792  y2[i] = y2[i]*y2[i+1] + u[i];
2793 }

Referenced by GraphicEQ().

Here is the caller graph for this function:

◆ splint()

double EffectEqualization::splint ( double  x[],
double  y[],
size_t  n,
double  y2[],
double  xr 
)
private

Definition at line 2795 of file Equalization.cpp.

2796 {
2797  wxASSERT( n > 1 );
2798 
2799  double a, b, h;
2800  static double xlast = 0.; // remember last x value requested
2801  static size_t k = 0; // and which interval we were in
2802 
2803  if( xr < xlast )
2804  k = 0; // gone back to start, (or somewhere to the left)
2805  xlast = xr;
2806  while( (x[k] <= xr) && (k + 1 < n) )
2807  k++;
2808  wxASSERT( k > 0 );
2809  k--;
2810  h = x[k+1] - x[k];
2811  a = ( x[k+1] - xr )/h;
2812  b = (xr - x[k])/h;
2813  return( a*y[k]+b*y[k+1]+((a*a*a-a)*y2[k]+(b*b*b-b)*y2[k+1])*h*h/6.);
2814 }

Referenced by GraphicEQ().

Here is the caller graph for this function:

◆ Startup()

bool EffectEqualization::Startup ( )
overridevirtual

Reimplemented from Effect.

Definition at line 599 of file Equalization.cpp.

600 {
601  wxString base = GetPrefsPrefix();
602 
603  // Migrate settings from 2.1.0 or before
604 
605  // Already migrated, so bail
606  if (gPrefs->Exists(base + wxT("Migrated")))
607  {
608  return true;
609  }
610 
611  // Load the old "current" settings
612  if (gPrefs->Exists(base))
613  {
614  // These get saved to the current preset
615  int filterLength;
616  gPrefs->Read(base + wxT("FilterLength"), &filterLength, 4001);
617  mM = std::max(0, filterLength);
618  if ((mM < 21) || (mM > 8191)) { // corrupted Prefs?
619  mM = 4001; //default
620  }
621  gPrefs->Read(base + wxT("CurveName"), &mCurveName, wxT("unnamed"));
622  gPrefs->Read(base + wxT("Lin"), &mLin, false);
623  gPrefs->Read(base + wxT("Interp"), &mInterp, 0);
624 
626 
627  // These persist across preset changes
628  double dBMin;
629  gPrefs->Read(base + wxT("dBMin"), &dBMin, -30.0);
630  if ((dBMin < -120) || (dBMin > -10)) { // corrupted Prefs?
631  dBMin = -30; //default
632  }
633  mdBMin = dBMin;
635 
636  double dBMax;
637  gPrefs->Read(base + wxT("dBMax"), &dBMax, 30.);
638  if ((dBMax < 0) || (dBMax > 60)) { // corrupted Prefs?
639  dBMax = 30; //default
640  }
641  mdBMax = dBMax;
643 
644  gPrefs->Read(base + wxT("DrawMode"), &mDrawMode, true);
646 
647  gPrefs->Read(base + wxT("DrawGrid"), &mDrawGrid, true);
649 
650  // Do not migrate again
651  gPrefs->Write(base + wxT("Migrated"), true);
652  gPrefs->Flush();
653  }
654 
655  return true;
656 }

References FileConfig::Flush(), Effect::GetCurrentSettingsGroup(), GetPrefsPrefix(), gPrefs, mCurveName, mdBMax, mdBMin, mDrawGrid, mDrawMode, mInterp, mLin, mM, Effect::SaveUserPreset(), and Effect::SetPrivateConfig().

Here is the call graph for this function:

◆ TransferDataFromWindow()

bool EffectEqualization::TransferDataFromWindow ( )
overridevirtual

Reimplemented from Effect.

Definition at line 1240 of file Equalization.cpp.

1241 {
1242  wxString tip;
1243 
1244  bool rr = false;
1245  float dB = (float) mdBMinSlider->GetValue();
1246  if (dB != mdBMin) {
1247  rr = true;
1248  mdBMin = dB;
1249  tip.Printf(_("%d dB"), (int)mdBMin);
1250  mdBMinSlider->SetToolTip(tip);
1251  }
1252 
1253  dB = (float) mdBMaxSlider->GetValue();
1254  if (dB != mdBMax) {
1255  rr = true;
1256  mdBMax = dB;
1257  tip.Printf(_("%d dB"), (int)mdBMax);
1258  mdBMaxSlider->SetToolTip(tip);
1259  }
1260 
1261  // Refresh ruler if values have changed
1262  if (rr) {
1263  int w1, w2, h;
1264  mdBRuler->ruler.GetMaxSize(&w1, &h);
1266  mdBRuler->ruler.GetMaxSize(&w2, &h);
1267  if( w1 != w2 ) // Reduces flicker
1268  {
1269  mdBRuler->SetSize(wxSize(w2,h));
1270  mFreqRuler->Refresh(false);
1271  }
1272  mdBRuler->Refresh(false);
1273 
1274  mPanel->Refresh(false);
1275  }
1276 
1277  size_t m = DEF_FilterLength; // m must be odd.
1278  if (mMSlider )
1279  m = 2* mMSlider->GetValue()+1;
1280  wxASSERT( (m & 1) ==1 );
1281  if (m != mM) {
1282  mM = m;
1283  ForceRecalc();
1284 
1285  if( mMSlider)
1286  {
1287  tip.Printf(wxT("%d"), (int)mM);
1288  mMText->SetLabel(tip);
1289  mMText->SetName(mMText->GetLabel()); // fix for bug 577 (NVDA/Narrator screen readers do not read static text in dialogs)
1290  mMSlider->SetToolTip(tip);
1291  }
1292  }
1293 
1294  return true;
1295 }

References _, ForceRecalc(), Ruler::GetMaxSize(), mdBMax, mdBMaxSlider, mdBMin, mdBMinSlider, mdBRuler, mFreqRuler, mM, mMSlider, mMText, mPanel, RulerPanel::ruler, and Ruler::SetRange().

Referenced by OnSliderDBMAX(), OnSliderDBMIN(), OnSliderM(), and TransferDataToWindow().

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

◆ TransferDataToWindow()

bool EffectEqualization::TransferDataToWindow ( )
overridevirtual

Reimplemented from Effect.

Definition at line 1184 of file Equalization.cpp.

1185 {
1186  // Set log or lin freq scale (affects interpolation as well)
1187  mLinFreq->SetValue( mLin );
1188  wxCommandEvent dummyEvent;
1189  OnLinFreq(dummyEvent); // causes a CalcFilter
1190 
1191  mGridOnOff->SetValue( mDrawGrid ); // checks/unchecks the box on the interface
1192 
1193  if( mMSlider )
1194  mMSlider->SetValue((mM - 1) / 2);
1195  mM = 0; // force refresh in TransferDataFromWindow()
1196 
1197  mdBMinSlider->SetValue((int)mdBMin);
1198  mdBMin = 0; // force refresh in TransferDataFromWindow()
1199 
1200  mdBMaxSlider->SetValue((int)mdBMax);
1201  mdBMax = 0; // force refresh in TransferDataFromWindow()
1202 
1203  // Reload the curve names
1204  UpdateCurves();
1205 
1206  // Set graphic interpolation mode
1207  mInterpChoice->SetSelection(mInterp);
1208 
1209  // Override draw mode, if we're not displaying the radio buttons.
1210  if( mOptions == kEqOptionCurve)
1211  mDrawMode = true;
1212  if( mOptions == kEqOptionGraphic)
1213  mDrawMode = false;
1214 
1215  if( mDraw )
1216  mDraw->SetValue(mDrawMode);
1217  szrV->Show(szr1,mOptions != kEqOptionGraphic); // Graph
1218  szrV->Show(szrG,!mDrawMode); // eq sliders
1219  szrH->Show(szrI,mOptions == kEqLegacy ); // interpolation choice
1220  szrH->Show(szrL, mDrawMode); // linear freq checkbox
1221  if( mGraphic)
1222  mGraphic->SetValue(!mDrawMode);
1223  mGridOnOff->Show( mDrawMode );
1224 
1225  // Set Graphic (Fader) or Draw mode
1226  if (!mDrawMode)
1227  UpdateGraphic();
1228 
1230 
1231  mUIParent->Layout();
1232  wxGetTopLevelParent(mUIParent)->Layout();
1233 
1234  return true;
1235 }

References kEqLegacy, kEqOptionCurve, kEqOptionGraphic, mdBMax, mdBMaxSlider, mdBMin, mdBMinSlider, mDraw, mDrawGrid, mDrawMode, mGraphic, mGridOnOff, mInterp, mInterpChoice, mLin, mLinFreq, mM, mMSlider, mOptions, Effect::mUIParent, OnLinFreq(), szr1, szrG, szrH, szrI, szrL, szrV, TransferDataFromWindow(), UpdateCurves(), and UpdateGraphic().

Referenced by LoadFactoryPreset().

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

◆ UpdateCurves()

void EffectEqualization::UpdateCurves ( )
private

Definition at line 2351 of file Equalization.cpp.

2352 {
2353 
2354  // Reload the curve names
2355  if( mCurve )
2356  mCurve->Clear();
2357  bool selectedCurveExists = false;
2358  for (size_t i = 0, cnt = mCurves.size(); i < cnt; i++)
2359  {
2360  if (mCurveName == mCurves[ i ].Name)
2361  selectedCurveExists = true;
2362  if( mCurve )
2363  mCurve->Append(mCurves[ i ].Name);
2364  }
2365  // In rare circumstances, mCurveName may not exist (bug 1891)
2366  if (!selectedCurveExists)
2367  mCurveName = mCurves[ (int)mCurves.size() - 1 ].Name;
2368  if( mCurve )
2369  mCurve->SetStringSelection(mCurveName);
2370 
2371  // Allow the control to resize
2372  if( mCurve )
2373  mCurve->SetMinSize({-1, -1});
2374 
2375  // Set initial curve
2376  setCurve( mCurveName );
2377 }

References mCurve, mCurveName, mCurves, and setCurve().

Referenced by OnManage(), and TransferDataToWindow().

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

◆ UpdateDefaultCurves()

void EffectEqualization::UpdateDefaultCurves ( bool  updateAll = false)
private

Definition at line 1687 of file Equalization.cpp.

1688 {
1689  if (mCurves.size() == 0)
1690  return;
1691 
1692  wxString unnamed = wxT("unnamed");
1693 
1694  // Save the "unnamed" curve and remove it so we can add it back as the final curve.
1695  EQCurve userUnnamed(wxT("temp"));
1696  userUnnamed = mCurves.back();
1697  mCurves.pop_back();
1698 
1699  EQCurveArray userCurves = mCurves;
1700  mCurves.clear();
1701  // We only wamt to look for the shipped EQDefaultCurves.xml
1702  wxFileName fn = wxFileName(FileNames::ResourcesDir(), wxT("EQDefaultCurves.xml"));
1703  wxLogDebug(wxT("Attempting to load EQDefaultCurves.xml from %s"),fn.GetFullPath());
1704  XMLFileReader reader;
1705 
1706  if(!reader.Parse(this, fn.GetFullPath())) {
1707  wxLogError(wxT("EQDefaultCurves.xml could not be read."));
1708  return;
1709  }
1710  else {
1711  wxLogDebug(wxT("Loading EQDefaultCurves.xml successful."));
1712  }
1713 
1714  EQCurveArray defaultCurves = mCurves;
1715  mCurves.clear(); // clear now so that we can sort then add back.
1716 
1717  // Remove "unnamed" if it exists.
1718  if (defaultCurves.back().Name == unnamed) {
1719  defaultCurves.pop_back();
1720  }
1721  else {
1722  wxLogError(wxT("Error in EQDefaultCurves.xml"));
1723  }
1724 
1725  int numUserCurves = userCurves.size();
1726  int numDefaultCurves = defaultCurves.size();
1727  EQCurve tempCurve(wxT("test"));
1728 
1729  if (updateAll) {
1730  // Update all factory preset curves.
1731  // Sort and add factory defaults first;
1732  mCurves = defaultCurves;
1733  std::sort(mCurves.begin(), mCurves.end());
1734  // then add remaining user curves:
1735  for (int curveCount = 0; curveCount < numUserCurves; curveCount++) {
1736  bool isCustom = true;
1737  tempCurve = userCurves[curveCount];
1738  // is the name in the default set?
1739  for (int defCurveCount = 0; defCurveCount < numDefaultCurves; defCurveCount++) {
1740  if (tempCurve.Name == mCurves[defCurveCount].Name) {
1741  isCustom = false;
1742  break;
1743  }
1744  }
1745  // if tempCurve is not in the default set, add it to mCurves.
1746  if (isCustom) {
1747  mCurves.push_back(tempCurve);
1748  }
1749  }
1750  }
1751  else {
1752  // Import NEW factory defaults but retain all user modified curves.
1753  for (int defCurveCount = 0; defCurveCount < numDefaultCurves; defCurveCount++) {
1754  bool isUserCurve = false;
1755  // Add if the curve is in the user's set (preserve user's copy)
1756  for (int userCurveCount = 0; userCurveCount < numUserCurves; userCurveCount++) {
1757  if (userCurves[userCurveCount].Name == defaultCurves[defCurveCount].Name) {
1758  isUserCurve = true;
1759  mCurves.push_back(userCurves[userCurveCount]);
1760  break;
1761  }
1762  }
1763  if (!isUserCurve) {
1764  mCurves.push_back(defaultCurves[defCurveCount]);
1765  }
1766  }
1767  std::sort(mCurves.begin(), mCurves.end());
1768  // now add the rest of the user's curves.
1769  for (int userCurveCount = 0; userCurveCount < numUserCurves; userCurveCount++) {
1770  bool isDefaultCurve = false;
1771  tempCurve = userCurves[userCurveCount];
1772  for (int defCurveCount = 0; defCurveCount < numDefaultCurves; defCurveCount++) {
1773  if (tempCurve.Name == defaultCurves[defCurveCount].Name) {
1774  isDefaultCurve = true;
1775  break;
1776  }
1777  }
1778  if (!isDefaultCurve) {
1779  mCurves.push_back(tempCurve);
1780  }
1781  }
1782  }
1783  defaultCurves.clear();
1784  userCurves.clear();
1785 
1786  // Add back old "unnamed"
1787  if(userUnnamed.Name == unnamed) {
1788  mCurves.push_back( userUnnamed ); // we always need a default curve to use
1789  }
1790 
1791  SaveCurves();
1792 
1793  // Write current EqCurve version number
1794  // TODO: Probably better if we used pluginregistry.cfg
1795  wxString eqCurvesCurrentVersion = wxString::Format(wxT("%d.%d"), EQCURVES_VERSION, EQCURVES_REVISION);
1796  gPrefs->Write(GetPrefsPrefix()+"PresetVersion", eqCurvesCurrentVersion);
1797  gPrefs->Flush();
1798 
1799  return;
1800 }

References EQCURVES_REVISION, EQCURVES_VERSION, FileConfig::Flush(), fn, GetPrefsPrefix(), gPrefs, mCurves, EQCurve::Name, XMLFileReader::Parse(), FileNames::ResourcesDir(), and SaveCurves().

Referenced by LoadCurves().

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

◆ UpdateDraw()

void EffectEqualization::UpdateDraw ( )
private

Definition at line 2379 of file Equalization.cpp.

2380 {
2381  size_t numPoints = mLogEnvelope->GetNumberOfPoints();
2382  Doubles when{ numPoints };
2383  Doubles value{ numPoints };
2384  double deltadB = 0.1;
2385  double dx, dy, dx1, dy1, err;
2386 
2387  mLogEnvelope->GetPoints( when.get(), value.get(), numPoints );
2388 
2389  // set 'unnamed' as the selected curve
2390  EnvelopeUpdated();
2391 
2392  bool flag = true;
2393  while (flag)
2394  {
2395  flag = false;
2396  int numDeleted = 0;
2397  mLogEnvelope->GetPoints( when.get(), value.get(), numPoints );
2398  for (size_t j = 0; j + 2 < numPoints; j++)
2399  {
2400  dx = when[j+2+numDeleted] - when[j+numDeleted];
2401  dy = value[j+2+numDeleted] - value[j+numDeleted];
2402  dx1 = when[j+numDeleted+1] - when[j+numDeleted];
2403  dy1 = dy * dx1 / dx;
2404  err = fabs(value[j+numDeleted+1] - (value[j+numDeleted] + dy1));
2405  if( err < deltadB )
2406  { // within < deltadB dB?
2407  mLogEnvelope->Delete(j+1);
2408  numPoints--;
2409  numDeleted++;
2410  flag = true;
2411  }
2412  }
2413  }
2414 
2415  if(mLin) // do not use IsLinear() here
2416  {
2417  EnvLogToLin();
2418  mEnvelope = mLinEnvelope.get();
2419  mFreqRuler->ruler.SetLog(false);
2421  }
2422 
2423  szrV->Show(szrG,false);
2424  szrH->Show(szrI,false);
2425  szrH->Show(szrL,true);
2426 
2427  mUIParent->Layout();
2428  wxGetTopLevelParent(mUIParent)->Layout();
2429  ForceRecalc(); // it may have changed slightly due to the deletion of points
2430 }

References EnvelopeUpdated(), EnvLogToLin(), flag, ForceRecalc(), mEnvelope, mFreqRuler, mHiFreq, mLin, mLinEnvelope, mLogEnvelope, Effect::mUIParent, RulerPanel::ruler, Ruler::SetLog(), Ruler::SetRange(), szrG, szrH, szrI, szrL, and szrV.

Referenced by OnDrawMode().

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

◆ UpdateGraphic()

void EffectEqualization::UpdateGraphic ( void  )
private

Definition at line 2432 of file Equalization.cpp.

2433 {
2434  double loLog = log10(mLoFreq);
2435  double hiLog = log10(mHiFreq);
2436  double denom = hiLog - loLog;
2437 
2438  if(mLin) //going from lin to log freq scale - do not use IsLinear() here
2439  { // add some extra points to the linear envelope for the graphic to follow
2440  double step = pow(2., 1./12.); // twelve steps per octave
2441  double when,value;
2442  for(double freq=10.; freq<mHiFreq; freq*=step)
2443  {
2444  when = freq/mHiFreq;
2445  value = mLinEnvelope->GetValue(when);
2446  mLinEnvelope->Insert(when, value);
2447  }
2448 
2449  EnvLinToLog();
2450  mEnvelope = mLogEnvelope.get();
2451  mFreqRuler->ruler.SetLog(true);
2453  }
2454 
2455  for (size_t i = 0; i < mBandsInUse; i++)
2456  {
2457  if( kThirdOct[i] == mLoFreq )
2458  mWhenSliders[i] = 0.;
2459  else
2460  mWhenSliders[i] = (log10(kThirdOct[i])-loLog)/denom;
2461  mEQVals[i] = mLogEnvelope->GetValue(mWhenSliders[i]); //set initial values of sliders
2462  if( mEQVals[i] > 20.)
2463  mEQVals[i] = 20.;
2464  if( mEQVals[i] < -20.)
2465  mEQVals[i] = -20.;
2466  }
2467  ErrMin(); //move sliders to minimise error
2468  for (size_t i = 0; i < mBandsInUse; i++)
2469  {
2470  mSliders[i]->SetValue(lrint(mEQVals[i])); //actually set slider positions
2471  mSlidersOld[i] = mSliders[i]->GetValue();
2472  wxString tip;
2473  if( kThirdOct[i] < 1000.)
2474  tip.Printf( wxT("%dHz\n%.1fdB"), (int)kThirdOct[i], mEQVals[i] );
2475  else
2476  tip.Printf( wxT("%gkHz\n%.1fdB"), kThirdOct[i]/1000., mEQVals[i] );
2477  mSliders[i]->SetToolTip(tip);
2478  }
2479 
2480  szrV->Show(szrG,true); // eq sliders
2481  szrH->Show(szrI,mOptions == kEqLegacy ); // interpolation choice
2482  szrH->Show(szrL,false); // linear freq checkbox
2483 
2484  mUIParent->Layout();
2485  wxGetTopLevelParent(mUIParent)->Layout();
2486  mUIParent->Layout();
2487  wxGetTopLevelParent(mUIParent)->Layout();
2488 
2489  GraphicEQ(mLogEnvelope.get());
2490  mDrawMode = false;
2491 }

References EnvLinToLog(), ErrMin(), GraphicEQ(), kEqLegacy, kThirdOct, lrint, mBandsInUse, mDrawMode, mEnvelope, mEQVals, mFreqRuler, mHiFreq, mLin, mLinEnvelope, mLoFreq, mLogEnvelope, mOptions, mSliders, mSlidersOld, Effect::mUIParent, mWhenSliders, RulerPanel::ruler, Ruler::SetLog(), Ruler::SetRange(), szrG, szrH, szrI, szrL, and szrV.

Referenced by OnCurve(), OnGraphicMode(), and TransferDataToWindow().

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

◆ ValidateUI()

bool EffectEqualization::ValidateUI ( )
overridevirtual

Reimplemented from Effect.

Definition at line 540 of file Equalization.cpp.

541 {
542  // If editing a macro, we don't want to be using the unnamed curve so
543  // we offer to save it.
544 
545  if (mDisallowCustom && mCurveName == wxT("unnamed"))
546  {
547  // PRL: This is unreachable. mDisallowCustom is always false.
548 
550  XO("To use this filter curve in a macro, please choose a new name for it.\nChoose the 'Save/Manage Curves...' button and rename the 'unnamed' curve, then use that one."),
551  wxOK | wxCENTRE,
552  XO("Filter Curve EQ needs a different name") );
553  return false;
554  }
555 
556  // Update unnamed curve (so it's there for next time)
557  //(done in a hurry, may not be the neatest -MJS)
558  if (mDirty && !mDrawMode)
559  {
560  size_t numPoints = mLogEnvelope->GetNumberOfPoints();
561  Doubles when{ numPoints };
562  Doubles value{ numPoints };
563  mLogEnvelope->GetPoints(when.get(), value.get(), numPoints);
564  for (size_t i = 0, j = 0; j + 2 < numPoints; i++, j++)
565  {
566  if ((value[i] < value[i + 1] + .05) && (value[i] > value[i + 1] - .05) &&
567  (value[i + 1] < value[i + 2] + .05) && (value[i + 1] > value[i + 2] - .05))
568  { // within < 0.05 dB?
569  mLogEnvelope->Delete(j + 1);
570  numPoints--;
571  j--;
572  }
573  }
574  Select((int) mCurves.size() - 1);
575  }
576  SaveCurves();
577 
582 
583  return true;
584 }

References Effect::GetCurrentSettingsGroup(), mCurveName, mCurves, mdBMax, mdBMin, mDirty, mDisallowCustom, mDrawGrid, mDrawMode, Effect::MessageBox(), mLogEnvelope, SaveCurves(), Select(), Effect::SetPrivateConfig(), and XO.

Here is the call graph for this function:

◆ WriteXML()

void EffectEqualization::WriteXML ( XMLWriter xmlFile) const
private

Definition at line 2309 of file Equalization.cpp.

2311 {
2312  // Start our hierarchy
2313  xmlFile.StartTag( wxT( "equalizationeffect" ) );
2314 
2315  // Write all curves
2316  int numCurves = mCurves.size();
2317  int curve;
2318  for( curve = 0; curve < numCurves; curve++ )
2319  {
2320  // Start a NEW curve
2321  xmlFile.StartTag( wxT( "curve" ) );
2322  xmlFile.WriteAttr( wxT( "name" ), mCurves[ curve ].Name );
2323 
2324  // Write all points
2325  int numPoints = mCurves[ curve ].points.size();
2326  int point;
2327  for( point = 0; point < numPoints; point++ )
2328  {
2329  // Write NEW point
2330  xmlFile.StartTag( wxT( "point" ) );
2331  xmlFile.WriteAttr( wxT( "f" ), mCurves[ curve ].points[ point ].Freq, 12 );
2332  xmlFile.WriteAttr( wxT( "d" ), mCurves[ curve ].points[ point ].dB, 12 );
2333  xmlFile.EndTag( wxT( "point" ) );
2334  }
2335 
2336  // Terminate curve
2337  xmlFile.EndTag( wxT( "curve" ) );
2338  }
2339 
2340  // Terminate our hierarchy
2341  xmlFile.EndTag( wxT( "equalizationeffect" ) );
2342 }

Referenced by SaveCurves().

Here is the caller graph for this function:

Friends And Related Function Documentation

◆ EditCurvesDialog

friend class EditCurvesDialog
friend

Definition at line 281 of file Equalization.h.

◆ EqualizationPanel

friend class EqualizationPanel
friend

Definition at line 280 of file Equalization.h.

Referenced by PopulateOrExchange().

Member Data Documentation

◆ hFFT

HFFT EffectEqualization::hFFT
private

Definition at line 208 of file Equalization.h.

Referenced by Filter().

◆ mBandsInUse

size_t EffectEqualization::mBandsInUse
private

Definition at line 221 of file Equalization.h.

Referenced by ErrMin(), Flatten(), GraphicEQ(), Init(), OnInvert(), OnSlider(), and UpdateGraphic().

◆ mCurve

wxChoice* EffectEqualization::mCurve
private

Definition at line 265 of file Equalization.h.

Referenced by CloseUI(), OnCurve(), OnManage(), PopulateOrExchange(), Select(), and UpdateCurves().

◆ mCurveName

wxString EffectEqualization::mCurveName
private

Definition at line 211 of file Equalization.h.

Referenced by Init(), Select(), Startup(), UpdateCurves(), and ValidateUI().

◆ mCurves

EQCurveArray EffectEqualization::mCurves
private

◆ mdBMax

float EffectEqualization::mdBMax
private

◆ mdBMaxSlider

wxSlider* EffectEqualization::mdBMaxSlider
private

◆ mdBMin

float EffectEqualization::mdBMin
private

◆ mdBMinSlider

wxSlider* EffectEqualization::mdBMinSlider
private

◆ mdBRuler

RulerPanel* EffectEqualization::mdBRuler
private

◆ mDirty

bool EffectEqualization::mDirty
private

Definition at line 229 of file Equalization.h.

Referenced by EnvelopeUpdated(), and ValidateUI().

◆ mDisallowCustom

bool EffectEqualization::mDisallowCustom
private

Definition at line 225 of file Equalization.h.

Referenced by ValidateUI().

◆ mDraw

wxRadioButton* EffectEqualization::mDraw
private

Definition at line 260 of file Equalization.h.

Referenced by PopulateOrExchange(), and TransferDataToWindow().

◆ mDrawGrid

bool EffectEqualization::mDrawGrid
private

◆ mDrawMode

bool EffectEqualization::mDrawMode
private

◆ mEnvelope

Envelope* EffectEqualization::mEnvelope
private

◆ mEQVals

double EffectEqualization::mEQVals[NUMBER_OF_BANDS+1]
private

◆ mFFTBuffer

Floats EffectEqualization::mFFTBuffer
private

Definition at line 209 of file Equalization.h.

Referenced by Filter().

◆ mFilterFuncI

Floats EffectEqualization::mFilterFuncI
private

◆ mFilterFuncR

Floats EffectEqualization::mFilterFuncR
private

◆ mFreqRuler

RulerPanel* EffectEqualization::mFreqRuler
private

◆ mGraphic

wxRadioButton* EffectEqualization::mGraphic
private

Definition at line 261 of file Equalization.h.

Referenced by PopulateOrExchange(), and TransferDataToWindow().

◆ mGridOnOff

wxCheckBox* EffectEqualization::mGridOnOff
private

Definition at line 263 of file Equalization.h.

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

◆ mHiFreq

double EffectEqualization::mHiFreq
private

◆ mInterp

int EffectEqualization::mInterp
private

◆ mInterpChoice

wxChoice* EffectEqualization::mInterpChoice
private

Definition at line 264 of file Equalization.h.

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

◆ mLeftSpacer

wxSizerItem* EffectEqualization::mLeftSpacer
private

Definition at line 256 of file Equalization.h.

◆ mLin

bool EffectEqualization::mLin
private

◆ mLinEnvelope

std::unique_ptr<Envelope> EffectEqualization::mLinEnvelope
private

◆ mLinFreq

wxCheckBox* EffectEqualization::mLinFreq
private

Definition at line 262 of file Equalization.h.

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

◆ mLoFreq

double EffectEqualization::mLoFreq
private

◆ mLogEnvelope

std::unique_ptr<Envelope> EffectEqualization::mLogEnvelope
private

◆ mM

size_t EffectEqualization::mM
private

◆ mManage

wxButton* EffectEqualization::mManage
private

Definition at line 266 of file Equalization.h.

◆ mMSlider

wxSlider* EffectEqualization::mMSlider
private

◆ mMText

wxStaticText* EffectEqualization::mMText
private

Definition at line 267 of file Equalization.h.

Referenced by PopulateOrExchange(), and TransferDataFromWindow().

◆ mOptions

int EffectEqualization::mOptions
private

◆ mPanel

EqualizationPanel* EffectEqualization::mPanel
private

◆ mSliders

wxSlider* EffectEqualization::mSliders[NUMBER_OF_BANDS]
private

Definition at line 271 of file Equalization.h.

Referenced by Flatten(), OnInvert(), OnSlider(), PopulateOrExchange(), and UpdateGraphic().

◆ mSlidersOld

int EffectEqualization::mSlidersOld[NUMBER_OF_BANDS]
private

Definition at line 230 of file Equalization.h.

Referenced by Flatten(), OnInvert(), OnSlider(), PopulateOrExchange(), and UpdateGraphic().

◆ mWhens

double EffectEqualization::mWhens[NUM_PTS]
private

Definition at line 219 of file Equalization.h.

Referenced by ErrMin(), and GraphicEQ().

◆ mWhenSliders

double EffectEqualization::mWhenSliders[NUMBER_OF_BANDS+1]
private

Definition at line 220 of file Equalization.h.

Referenced by GraphicEQ(), and UpdateGraphic().

◆ mWindowSize

size_t EffectEqualization::mWindowSize
private

◆ Symbol

const ComponentInterfaceSymbol EffectEqualization::Symbol { XO("Equalization") }
static

Definition at line 96 of file Equalization.h.

Referenced by GetSymbol().

◆ szr1

wxSizer* EffectEqualization::szr1
private

Definition at line 250 of file Equalization.h.

Referenced by PopulateOrExchange(), and TransferDataToWindow().

◆ szr2

wxSizer* EffectEqualization::szr2
private

Definition at line 251 of file Equalization.h.

◆ szr3

wxSizer* EffectEqualization::szr3
private

Definition at line 252 of file Equalization.h.

◆ szr4

wxSizer* EffectEqualization::szr4
private

Definition at line 253 of file Equalization.h.

◆ szr5

wxSizer* EffectEqualization::szr5
private

Definition at line 254 of file Equalization.h.

◆ szrC

wxSizer* EffectEqualization::szrC
private

Definition at line 244 of file Equalization.h.

◆ szrG

wxSizer* EffectEqualization::szrG
private

◆ szrH

wxSizer* EffectEqualization::szrH
private

◆ szrI

wxSizer* EffectEqualization::szrI
private

◆ szrL

wxSizer* EffectEqualization::szrL
private

◆ szrV

wxSizer* EffectEqualization::szrV
private

◆ windowSize

const size_t EffectEqualization::windowSize = 16384u
staticprivate

Definition at line 142 of file Equalization.h.

Referenced by ProcessOne().


The documentation for this class was generated from the following files:
FileNames::ResourcesDir
FILES_API FilePath ResourcesDir()
XMLWriter::EndTag
virtual void EndTag(const wxString &name)
Definition: XMLWriter.cpp:99
EqualizationPanel::ForceRecalc
void ForceRecalc()
Definition: Equalization.cpp:3097
ShuttleSetAutomation
Shuttle that sets parameters to a value (from a string)
Definition: Shuttle.h:106
TranslatableString
Holds a msgid for the translation catalog; may also bind format arguments.
Definition: TranslatableString.h:32
EffectEqualization::mLogEnvelope
std::unique_ptr< Envelope > mLogEnvelope
Definition: Equalization.h:235
CommandParameters
CommandParameters, derived from wxFileConfig, is essentially doing the same things as the Shuttle cla...
Definition: EffectAutomationParameters.h:67
eIsCreating
@ eIsCreating
Definition: ShuttleGui.h:38
ID_Curve
@ ID_Curve
Definition: Equalization.cpp:135
ShuttleGuiBase::AddChoice
wxChoice * AddChoice(const TranslatableString &Prompt, const TranslatableStrings &choices, int Selected=-1)
Definition: ShuttleGui.cpp:398
kEqOptionGraphic
const int kEqOptionGraphic
Definition: Equalization.h:24
Effect::FindProject
const AudacityProject * FindProject() const
Definition: Effect.cpp:2272
ShuttleGuiBase::StartVerticalLay
void StartVerticalLay(int iProp=1)
Definition: ShuttleGui.cpp:1184
WaveTrack
A Track that contains audio waveform data.
Definition: WaveTrack.h:69
CommandParameters::WriteEnum
bool WriteEnum(const wxString &key, int value, const EnumValueSymbol choices[], size_t nChoices)
Definition: EffectAutomationParameters.h:202
GuardedCall
R GuardedCall(const F1 &body, const F2 &handler=F2::Default(), std::function< void(AudacityException *)> delayedHandler=DefaultDelayedHandlerAction{})
Execute some code on any thread; catch any AudacityException; enqueue error report on the main thread...
Definition: AudacityException.h:202
EffectTypeProcess
@ EffectTypeProcess
Definition: EffectInterface.h:59
wxSliderWrapper
wxSlider wxSliderWrapper
Definition: ShuttleGui.h:105
DB_TO_LINEAR
const double MIN_Threshold_Linear DB_TO_LINEAR(MIN_Threshold_dB)
Effect::mUIDialog
wxDialog * mUIDialog
Definition: Effect.h:477
EffectEqualization::mGraphic
wxRadioButton * mGraphic
Definition: Equalization.h:261
EQCURVES_REVISION
#define EQCURVES_REVISION
Definition: Equalization.cpp:159
RulerPanel
RulerPanel class allows you to work with a Ruler like any other wxWindow.
Definition: Ruler.h:228
Effect::CloseUI
bool CloseUI() override
Definition: Effect.cpp:652
Ruler::LinearDBFormat
@ LinearDBFormat
Definition: Ruler.h:34
fn
static const auto fn
Definition: WaveformView.cpp:1113
ID_Draw
@ ID_Draw
Definition: Equalization.cpp:130
EffectEqualization::mdBMin
float mdBMin
Definition: Equalization.h:214
flag
static std::once_flag flag
Definition: WaveformView.cpp:1124
gPrefs
FileConfig * gPrefs
Definition: Prefs.cpp:70
EffectEqualization::WriteXML
void WriteXML(XMLWriter &xmlFile) const
Definition: Equalization.cpp:2309
TranslatableStrings
std::vector< TranslatableString > TranslatableStrings
Definition: TranslatableString.h:295
Effect::MessageBox
int MessageBox(const TranslatableString &message, long style=DefaultMessageBoxStyle, const TranslatableString &titleStr={})
Definition: Effect.cpp:2482
Effect::CopyInputTracks
void CopyInputTracks(bool allSyncLockSelected=false)
Definition: Effect.cpp:2071
RegistryPaths
std::vector< RegistryPath > RegistryPaths
Definition: Identifier.h:219
EffectEqualization::mWindowSize
size_t mWindowSize
Definition: Equalization.h:228
EffectEqualization::mMText
wxStaticText * mMText
Definition: Equalization.h:267
EffectEqualization::GraphicEQ
void GraphicEQ(Envelope *env)
Definition: Equalization.cpp:2635
EffectEqualization::TransferDataFromWindow
bool TransferDataFromWindow() override
Definition: Equalization.cpp:1240
Envelope::Insert
void Insert(int point, const EnvPoint &p)
insert a point
Definition: Envelope.cpp:365
ShuttleGuiBase::AddRadioButtonToGroup
wxRadioButton * AddRadioButtonToGroup(const TranslatableString &Prompt, int selector=1, int initValue=0)
Definition: ShuttleGui.cpp:574
Ruler::SetLog
void SetLog(bool log)
Definition: Ruler.cpp:142
RealFFTf
void RealFFTf(fft_type *buffer, const FFTParam *h)
Definition: RealFFTf.cpp:162
EffectEqualization::hFFT
HFFT hFFT
Definition: Equalization.h:208
Envelope
Piecewise linear or piecewise exponential function from double to double.
Definition: Envelope.h:71
EffectEqualizationGraphic::Symbol
static const ComponentInterfaceSymbol Symbol
Definition: Equalization.h:295
ID_Clear
@ ID_Clear
Definition: Equalization.cpp:127
ID_Graphic
@ ID_Graphic
Definition: Equalization.cpp:131
kInterpStrings
static const EnumValueSymbol kInterpStrings[nInterpolations]
Definition: Equalization.cpp:162
Effect::mT1
double mT1
Definition: Effect.h:467
Effect::LoadUserPreset
bool LoadUserPreset(const RegistryPath &name) override
Definition: Effect.cpp:554
EffectEqualization::mLoFreq
double mLoFreq
Definition: Equalization.h:226
ID_Linear
@ ID_Linear
Definition: Equalization.cpp:133
ID_Grid
@ ID_Grid
Definition: Equalization.cpp:134
Envelope::GetPoints
void GetPoints(double *bufferWhen, double *bufferValue, int bufferLen) const
Returns the sets of when and value pairs.
Definition: Envelope.cpp:698
ShuttleGui::AddSpace
wxSizerItem * AddSpace(int width, int height, int prop=0)
Definition: ShuttleGui.cpp:2459
Envelope::SetTrackLen
void SetTrackLen(double trackLen, double sampleDur=0.0)
Definition: Envelope.cpp:791
ShuttleGui::MinSize
ShuttleGui & MinSize()
Definition: ShuttleGui.h:733
XO
#define XO(s)
Definition: Internat.h:31
EffectEqualization::mEQVals
double mEQVals[NUMBER_OF_BANDS+1]
Definition: Equalization.h:231
EffectEqualization::mdBMax
float mdBMax
Definition: Equalization.h:213
EffectEqualization::DefineParams
bool DefineParams(ShuttleParams &S) override
Definition: Equalization.cpp:370
Effect::SetPrivateConfig
bool SetPrivateConfig(const RegistryPath &group, const RegistryPath &key, const wxString &value) override
Definition: Effect.cpp:987
Envelope::Reassign
int Reassign(double when, double value)
Move a point at when to value.
Definition: Envelope.cpp:673
ShuttleGuiBase::EndMultiColumn
void EndMultiColumn()
Definition: ShuttleGui.cpp:1238
Effect::IsBatchProcessing
virtual bool IsBatchProcessing()
Definition: Effect.cpp:1190
kThirdOct
static const double kThirdOct[]
Definition: Equalization.cpp:172
EffectEqualization::mBandsInUse
size_t mBandsInUse
Definition: Equalization.h:221
EffectEqualization::EqualizationPanel
friend class EqualizationPanel
Definition: Equalization.h:280
EffectEqualization::UpdateGraphic
void UpdateGraphic(void)
Definition: Equalization.cpp:2432
EffectEqualization::mWhenSliders
double mWhenSliders[NUMBER_OF_BANDS+1]
Definition: Equalization.h:220
Effect::SaveUserPreset
bool SaveUserPreset(const RegistryPath &name) override
Definition: Effect.cpp:570
RealFFT
void RealFFT(size_t NumSamples, const float *RealIn, float *RealOut, float *ImagOut)
Definition: FFT.cpp:230
EffectEqualization::mdBMinSlider
wxSlider * mdBMinSlider
Definition: Equalization.h:269
WaveTrack::EmptyCopy
Holder EmptyCopy(const SampleBlockFactoryPtr &pFactory={}) const
Definition: WaveTrack.cpp:666
nInterpolations
@ nInterpolations
Definition: Equalization.cpp:154
XMLValueChecker::IsGoodString
static bool IsGoodString(const wxString &str)
Definition: XMLTagHandler.cpp:38
EffectEqualization::mSlidersOld
int mSlidersOld[NUMBER_OF_BANDS]
Definition: Equalization.h:230
EffectEqualization::loFreqI
@ loFreqI
Definition: Equalization.h:146
EffectEqualization::SaveCurves
void SaveCurves(const wxString &fileName={})
Definition: Equalization.cpp:1833
ShuttleGui::Id
ShuttleGui & Id(int id)
Definition: ShuttleGui.cpp:2274
EffectEqualization::szr1
wxSizer * szr1
Definition: Equalization.h:250
ID_Length
@ ID_Length
Definition: Equalization.cpp:124
EditCurvesDialog
Definition: Equalization.h:353
XMLFileReader::Parse
bool Parse(XMLTagHandler *baseHandler, const FilePath &fname)
Definition: XMLFileReader.cpp:42
ReorderToTime
void ReorderToTime(const FFTParam *hFFT, const fft_type *buffer, fft_type *TimeOut)
Definition: RealFFTf.cpp:361
EffectEqualization::mLin
bool mLin
Definition: Equalization.h:212
Ruler::GetMaxSize
void GetMaxSize(wxCoord *width, wxCoord *height)
Definition: Ruler.cpp:1603
EffectEqualization::mFilterFuncR
Floats mFilterFuncR
Definition: Equalization.h:209
FileNames::DataDir
FILES_API FilePath DataDir()
Audacity user data directory.
floatSample
@ floatSample
Definition: SampleFormat.h:34
RulerPanel::Range
std::pair< double, double > Range
Definition: Ruler.h:232
EffectEqualization::szrI
wxSizer * szrI
Definition: Equalization.h:248
ShuttleGui::Style
ShuttleGui & Style(long iStyle)
Definition: ShuttleGui.h:727
ID_Manage
@ ID_Manage
Definition: Equalization.cpp:136
EQPoint
EQPoint is used with EQCurve and hence EffectEqualization.
Definition: Equalization.h:50
ReadAndVerifyEnum
#define ReadAndVerifyEnum(name, list, listSize)
Definition: Effect.h:621
ShuttleGuiBase::SetSizerProportion
void SetSizerProportion(int iProp)
Definition: ShuttleGui.h:491
EffectEqualization::Flatten
void Flatten()
Definition: Equalization.cpp:2156
EffectEqualization::mLinEnvelope
std::unique_ptr< Envelope > mLinEnvelope
Definition: Equalization.h:235
ReadAndVerifyInt
#define ReadAndVerifyInt(name)
Definition: Effect.h:632
EffectEqualization::mPanel
EqualizationPanel * mPanel
Definition: Equalization.h:258
kBspline
@ kBspline
Definition: Equalization.cpp:151
XXO
#define XXO(s)
Definition: Internat.h:44
WaveTrack::ConvertToSampleFormat
void ConvertToSampleFormat(sampleFormat format, const std::function< void(size_t)> &progressReport={})
Definition: WaveTrack.cpp:547
WaveTrack::Clear
void Clear(double t0, double t1) override
Definition: WaveTrack.cpp:751
EffectEqualization::spline
void spline(double x[], double y[], size_t n, double y2[])
Definition: Equalization.cpp:2773
ShuttleGuiBase::EndHorizontalLay
void EndHorizontalLay()
Definition: ShuttleGui.cpp:1177
XMLFileReader::GetErrorStr
const TranslatableString & GetErrorStr() const
Definition: XMLFileReader.cpp:178
Effect::mT0
double mT0
Definition: Effect.h:466
EQCURVES_VERSION
#define EQCURVES_VERSION
Definition: Equalization.cpp:158
name
const TranslatableString name
Definition: Equalization.cpp:471
ShuttleGetAutomation
Shuttle that gets parameter values into a string.
Definition: Shuttle.h:88
EffectEqualization::mMSlider
wxSlider * mMSlider
Definition: Equalization.h:268
EffectEqualization::Select
void Select(int sel)
Definition: Equalization.cpp:2062
label
TranslatableString label
Definition: Tags.cpp:756
ShuttleGuiBase::StartHorizontalLay
void StartHorizontalLay(int PositionFlags=wxALIGN_CENTRE, int iProp=1)
Definition: ShuttleGui.cpp:1167
InverseRealFFT
void InverseRealFFT(size_t NumSamples, const float *RealIn, const float *ImagIn, float *RealOut)
Definition: FFT.cpp:268
WaveTrack::LongSamplesToTime
double LongSamplesToTime(sampleCount pos) const
Convert correctly between a number of samples and an (absolute) time in seconds.
Definition: WaveTrack.cpp:1870
EffectEqualization::UpdateCurves
void UpdateCurves()
Definition: Equalization.cpp:2351
EffectEqualization::mM
size_t mM
Definition: Equalization.h:210
FactoryPresets
static const struct @1 FactoryPresets[]
EffectEqualization::mOptions
int mOptions
Definition: Equalization.h:207
ShuttleGui::Disable
ShuttleGui & Disable(bool disabled=true)
Definition: ShuttleGui.h:650
ShuttleGuiBase::StartMultiColumn
void StartMultiColumn(int nCols, int PositionFlags=wxALIGN_LEFT)
Definition: ShuttleGui.cpp:1229
ShuttleGuiBase::EndVerticalLay
void EndVerticalLay()
Definition: ShuttleGui.cpp:1203
EffectEqualization::setCurve
void setCurve(void)
Definition: Equalization.cpp:2036
Effect::LoadFactoryDefaults
bool LoadFactoryDefaults() override
Definition: Effect.cpp:606
EffectEqualization::mCurves
EQCurveArray mCurves
Definition: Equalization.h:233
ShuttleGuiBase::AddUnits
void AddUnits(const TranslatableString &Prompt, int wrapWidth=0)
Left aligned text string.
Definition: ShuttleGui.cpp:263
ShuttleGuiBase::AddFixedText
void AddFixedText(const TranslatableString &Str, bool bCenter=false, int wrapWidth=0)
Definition: ShuttleGui.cpp:440
WaveTrack::GetClips
WaveClipHolders & GetClips()
Definition: WaveTrack.h:370
EffectEqualization::OnLinFreq
void OnLinFreq(wxCommandEvent &event)
Definition: Equalization.cpp:3009
anonymous_namespace{TimeTrack.cpp}::GetRate
double GetRate()
Definition: TimeTrack.cpp:175
Effect::ReplaceProcessedTracks
void ReplaceProcessedTracks(const bool bGoodResult)
Definition: Effect.cpp:2193
WaveTrack::Paste
void Paste(double t0, const Track *src) override
Definition: WaveTrack.cpp:1259
EffectEqualization::szrG
wxSizer * szrG
Definition: Equalization.h:245
ID_dBMax
@ ID_dBMax
Definition: Equalization.cpp:125
ShuttleGuiBase::GetParent
wxWindow * GetParent()
Definition: ShuttleGui.h:496
kCubic
@ kCubic
Definition: Equalization.cpp:153
ShuttleGuiBase::AddWindow
wxWindow * AddWindow(wxWindow *pWindow, int PositionFlags=wxALIGN_CENTRE)
Definition: ShuttleGui.cpp:299
kEqLegacy
const int kEqLegacy
Definition: Equalization.h:27
Ruler::SetRange
void SetRange(double min, double max)
Definition: Ruler.cpp:188
WindowAccessible
An alternative to using wxWindowAccessible, which in wxWidgets 3.1.1 contained GetParent() which was ...
Ruler::IntFormat
@ IntFormat
Definition: Ruler.h:30
EffectEqualization::splint
double splint(double x[], double y[], size_t n, double y2[], double xr)
Definition: Equalization.cpp:2795
anonymous_namespace{NoteTrack.cpp}::swap
void swap(std::unique_ptr< Alg_seq > &a, std::unique_ptr< Alg_seq > &b)
Definition: NoteTrack.cpp:735
ShuttleGuiBase::AddRadioButton
wxRadioButton * AddRadioButton(const TranslatableString &Prompt, int selector=0, int initValue=0)
Definition: ShuttleGui.cpp:568
EffectEqualization::mLinFreq
wxCheckBox * mLinFreq
Definition: Equalization.h:262
InverseRealFFTf
void InverseRealFFTf(fft_type *buffer, const FFTParam *h)
Definition: RealFFTf.cpp:264
EffectEqualization::mDirty
bool mDirty
Definition: Equalization.h:229
EffectEqualization::mInterp
int mInterp
Definition: Equalization.h:216
Effect::mOutputTracks
std::shared_ptr< TrackList > mOutputTracks
Definition: Effect.h:465
Msgids
TranslatableStrings Msgids(const EnumValueSymbol strings[], size_t nStrings)
Convenience function often useful when adding choice controls.
Definition: ShuttleGui.cpp:2522
NUMBER_OF_BANDS
#define NUMBER_OF_BANDS
Definition: Equalization.h:14
ID_Interp
@ ID_Interp
Definition: Equalization.cpp:132
ShuttleGui::Prop
ShuttleGui & Prop(int iProp)
Definition: ShuttleGui.h:725
ShuttleGuiBase::AddSlider
wxSlider * AddSlider(const TranslatableString &Prompt, int pos, int Max, int Min=0)
Definition: ShuttleGui.cpp:589
RulerPanel::Options::LabelEdges
Options & LabelEdges(bool l)
Definition: Ruler.h:250
EffectEqualization::EnvLogToLin
void EnvLogToLin(void)
Definition: Equalization.cpp:2493
EffectEqualization::ProcessOne
bool ProcessOne(int count, WaveTrack *t, sampleCount start, sampleCount len)
Definition: Equalization.cpp:1299
Effect::GetCurrentSettingsGroup
RegistryPath GetCurrentSettingsGroup() override
Definition: Effect.cpp:866
ShuttleGuiBase::AddButton
wxButton * AddButton(const TranslatableString &Text, int PositionFlags=wxALIGN_CENTRE, bool setDefault=false)
Definition: ShuttleGui.cpp:360
EffectEqualization::IsLinear
bool IsLinear()
Definition: Equalization.cpp:2148
samplePtr
char * samplePtr
Definition: SampleFormat.h:49
min
int min(int a, int b)
Definition: CompareAudioCommand.cpp:106
WaveTrack::GetMaxBlockSize
size_t GetMaxBlockSize() const
Definition: WaveTrack.cpp:1669
EffectEqualization::mdBMaxSlider
wxSlider * mdBMaxSlider
Definition: Equalization.h:270
ShuttleGui::Name
ShuttleGui & Name(const TranslatableString &name)
Definition: ShuttleGui.h:663
kEqOptionCurve
const int kEqOptionCurve
Definition: Equalization.h:25
EffectEqualization::szrH
wxSizer * szrH
Definition: Equalization.h:247
WaveTrack::Join
void Join(double t0, double t1)
Definition: WaveTrack.cpp:1576
FileConfig::Flush
virtual bool Flush(bool bCurrentOnly=false) wxOVERRIDE
Definition: FileConfig.cpp:143
EffectEqualization::EnvLinToLog
void EnvLinToLog(void)
Definition: Equalization.cpp:2517
TrackList::Get
static TrackList & Get(AudacityProject &project)
Definition: Track.cpp:506
EffectEqualization::mDisallowCustom
bool mDisallowCustom
Definition: Equalization.h:225
XMLFileReader
Reads a file and passes the results through an XMLTagHandler.
Definition: XMLFileReader.h:18
ShuttleGui::Position
ShuttleGui & Position(int flags)
Definition: ShuttleGui.h:712
ShuttleGuiBase::GetSizer
wxSizer * GetSizer()
Definition: ShuttleGui.h:506
Effect::mUIParent
wxWindow * mUIParent
Definition: Effect.h:478
names
static TranslatableStrings names
Definition: Tags.cpp:744
_
#define _(s)
Definition: Internat.h:75
EffectEqualization::Symbol
static const ComponentInterfaceSymbol Symbol
Definition: Equalization.h:96
ShuttleGui::ConnectRoot
auto ConnectRoot(wxEventTypeTag< Tag > eventType, void(Handler::*func)(Argument &)) -> typename std::enable_if< std::is_base_of< Argument, Tag >::value, ShuttleGui & >::type
Definition: ShuttleGui.h:699
EffectEqualization::mGridOnOff
wxCheckBox * mGridOnOff
Definition: Equalization.h:263
XMLFileWriter
Wrapper to output XML data to files.
Definition: XMLWriter.h:81
EffectEqualization::ForceRecalc
void ForceRecalc()
Definition: Equalization.cpp:2075
EffectEqualization::szrL
wxSizer * szrL
Definition: Equalization.h:249
EffectEqualization::GetDefaultFileName
bool GetDefaultFileName(wxFileName &fileName)
Definition: Equalization.cpp:1805
EffectEqualization::mCurveName
wxString mCurveName
Definition: Equalization.h:211
EffectEqualization::mDrawMode
bool mDrawMode
Definition: Equalization.h:215
XMLWriter::WriteAttr
void WriteAttr(const wxString &name, const Identifier &value)
Definition: XMLWriter.h:34
EffectEqualization::mWhens
double mWhens[NUM_PTS]
Definition: Equalization.h:219
EffectEqualization::EnvelopeUpdated
void EnvelopeUpdated()
Definition: Equalization.cpp:2086
RulerPanel::Options
Definition: Ruler.h:234
EffectEqualization::GetPrefsPrefix
wxString GetPrefsPrefix()
Definition: Equalization.cpp:588
EQCurveArray
std::vector< EQCurve > EQCurveArray
Definition: Equalization.h:86
EffectEqualization::TransferDataToWindow
bool TransferDataToWindow() override
Definition: Equalization.cpp:1184
EffectEqualization::Filter
void Filter(size_t len, float *buffer)
Definition: Equalization.cpp:1561
Verbatim
TranslatableString Verbatim(wxString str)
Require calls to the one-argument constructor to go through this distinct global function name.
Definition: TranslatableString.h:321
RulerPanel::ruler
Ruler ruler
Definition: Ruler.h:288
Envelope::Flatten
void Flatten(double value)
Definition: Envelope.cpp:134
EffectEqualization::mFreqRuler
RulerPanel * mFreqRuler
Definition: Equalization.h:223
M_PI
#define M_PI
Definition: Distortion.cpp:29
EffectEqualization::szrV
wxSizer * szrV
Definition: Equalization.h:246
EQCurve
EQCurve is used with EffectEqualization.
Definition: Equalization.h:72
EffectEqualization::mFFTBuffer
Floats mFFTBuffer
Definition: Equalization.h:209
EffectEqualization::UpdateDraw
void UpdateDraw()
Definition: Equalization.cpp:2379
EffectEqualization::mHiFreq
double mHiFreq
Definition: Equalization.h:227
ShuttleGui::GetMode
teShuttleMode GetMode()
Definition: ShuttleGui.h:752
EffectEqualization::mEnvelope
Envelope * mEnvelope
Definition: Equalization.h:236
EffectEqualization::CalcFilter
bool CalcFilter()
Definition: Equalization.cpp:1448
kCosine
@ kCosine
Definition: Equalization.cpp:152
EffectEqualization::mdBRuler
RulerPanel * mdBRuler
Definition: Equalization.h:222
params
EffectDistortion::Params params
Definition: Distortion.cpp:99
ShuttleGuiBase::AddPrompt
void AddPrompt(const TranslatableString &Prompt, int wrapWidth=0)
Right aligned text string.
Definition: ShuttleGui.cpp:238
NUM_PTS
#define NUM_PTS
Definition: Equalization.h:15
TranslatableString::Translation
wxString Translation() const
Definition: TranslatableString.h:79
ShuttleGuiBase::SetBorder
void SetBorder(int Border)
Definition: ShuttleGui.h:489
ShuttleParams::Define
virtual void Define(bool &var, const wxChar *key, const bool vdefault, const bool vmin=false, const bool vmax=false, const bool vscl=false)
Definition: Shuttle.cpp:332
EffectEqualization::mFilterFuncI
Floats mFilterFuncI
Definition: Equalization.h:209
UPDATE_ALL
#define UPDATE_ALL
Definition: Equalization.cpp:160
TranslatableString::Format
TranslatableString & Format(Args &&...args) &
Capture variadic format arguments (by copy) when there is no plural.
Definition: TranslatableString.h:103
ShuttleGuiBase::AddVariableText
wxStaticText * AddVariableText(const TranslatableString &Str, bool bCenter=false, int PositionFlags=0, int wrapWidth=0)
Definition: ShuttleGui.cpp:463
EffectEqualization::mDrawGrid
bool mDrawGrid
Definition: Equalization.h:217
safenew
#define safenew
Definition: MemoryX.h:10
EffectEqualization::OnErase
void OnErase(wxEvent &event)
Definition: Equalization.cpp:2816
lrint
#define lrint(dbl)
Definition: float_cast.h:169
ShuttleGuiBase::SetStretchyCol
void SetStretchyCol(int i)
Used to modify an already placed FlexGridSizer to make a column stretchy.
Definition: ShuttleGui.cpp:202
EffectEqualization::mInterpChoice
wxChoice * mInterpChoice
Definition: Equalization.h:264
EffectEqualizationCurve::Symbol
static const ComponentInterfaceSymbol Symbol
Definition: Equalization.h:287
limitSampleBufferSize
size_t limitSampleBufferSize(size_t bufferSize, sampleCount limit)
Definition: SampleCount.cpp:23
WaveTrack::GetFloats
bool GetFloats(float *buffer, sampleCount start, size_t len, fillFormat fill=fillZero, bool mayThrow=true, sampleCount *pNumWithinClips=nullptr) const
Retrieve samples from a track in floating-point format, regardless of the storage format.
Definition: WaveTrack.h:265
TrackList::Selected
auto Selected() -> TrackIterRange< TrackType >
Definition: Track.h:1388
ID_Invert
@ ID_Invert
Definition: Equalization.cpp:128
ShuttleGuiBase::SetStretchyRow
void SetStretchyRow(int i)
Used to modify an already placed FlexGridSizer to make a row stretchy.
Definition: ShuttleGui.cpp:212
Effect::TrackProgress
bool TrackProgress(int whichTrack, double frac, const TranslatableString &={})
Definition: Effect.cpp:2025
ArrayOf< float >
ShuttleSetAutomation::SetForWriting
void SetForWriting(CommandParameters *pEap)
Definition: Shuttle.h:114
XMLWriter::StartTag
virtual void StartTag(const wxString &name)
Definition: XMLWriter.cpp:76
EffectEqualization::mSliders
wxSlider * mSliders[NUMBER_OF_BANDS]
Definition: Equalization.h:271
ID_dBMin
@ ID_dBMin
Definition: Equalization.cpp:126
ID_Slider
@ ID_Slider
Definition: Equalization.cpp:146
RulerPanel::Options::Log
Options & Log(bool l)
Definition: Ruler.h:244
ReadAndVerifyBool
#define ReadAndVerifyBool(name)
Definition: Effect.h:635
Envelope::GetNumberOfPoints
size_t GetNumberOfPoints() const
Return number of points.
Definition: Envelope.cpp:693
EffectEqualization::mDraw
wxRadioButton * mDraw
Definition: Equalization.h:260
EffectEqualization::UpdateDefaultCurves
void UpdateDefaultCurves(bool updateAll=false)
Definition: Equalization.cpp:1687
Internat::CompatibleToDouble
static bool CompatibleToDouble(const wxString &stringToConvert, double *result)
Convert a string to a number.
Definition: Internat.cpp:134
EffectEqualization::mCurve
wxChoice * mCurve
Definition: Equalization.h:265
EffectEqualization::ErrMin
void ErrMin(void)
Definition: Equalization.cpp:2559
EffectEqualization::windowSize
static const size_t windowSize
Definition: Equalization.h:142