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
 
wxString 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 wxString 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 331 of file Equalization.cpp.

332 {
333 }

Member Function Documentation

◆ CalcFilter()

bool EffectEqualization::CalcFilter ( )
private

Definition at line 1455 of file Equalization.cpp.

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

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 749 of file Equalization.cpp.

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

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

Here is the call graph for this function:

◆ DefineParams()

bool EffectEqualization::DefineParams ( ShuttleParams S)
override

Definition at line 369 of file Equalization.cpp.

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

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 2092 of file Equalization.cpp.

2093 {
2094  if (IsLinear())
2095  {
2096  EnvelopeUpdated(mLinEnvelope.get(), true);
2097  }
2098  else
2099  {
2100  EnvelopeUpdated(mLogEnvelope.get(), false);
2101  }
2102 }

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 2104 of file Equalization.cpp.

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

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 2523 of file Equalization.cpp.

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

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 2499 of file Equalization.cpp.

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

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 2565 of file Equalization.cpp.

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

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 1568 of file Equalization.cpp.

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

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 2162 of file Equalization.cpp.

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

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 2081 of file Equalization.cpp.

2082 {
2083  if (mPanel)
2084  {
2085  mPanel->ForceRecalc();
2086  }
2087 }

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 411 of file Equalization.cpp.

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

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 1812 of file Equalization.cpp.

1813 {
1814  // look in data dir first, in case the user has their own defaults (maybe downloaded ones)
1815  fileName = wxFileName( FileNames::DataDir(), wxT("EQDefaultCurves.xml") );
1816  if( !fileName.FileExists() )
1817  { // Default file not found in the data dir. Fall back to Resources dir.
1818  // See http://docs.wxwidgets.org/trunk/classwx_standard_paths.html#5514bf6288ee9f5a0acaf065762ad95d
1819  fileName = wxFileName( FileNames::ResourcesDir(), wxT("EQDefaultCurves.xml") );
1820  }
1821  if( !fileName.FileExists() )
1822  {
1823  // LLL: Is there really a need for an error message at all???
1824  //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")
1825  // .Format( FileNames::DataDir() );
1826  //ShowErrorDialog(mUIParent, XO("EQCurves.xml and EQDefaultCurves.xml missing"),
1827  // errorMessage, wxT("http://wiki.audacityteam.org/wiki/EQCurvesDownload"), false);
1828 
1829  // Have another go at finding EQCurves.xml in the data dir, in case 'help' helped
1830  fileName = wxFileName( FileNames::DataDir(), wxT("EQDefaultCurves.xml") );
1831  }
1832  return (fileName.FileExists());
1833 }

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 346 of file Equalization.cpp.

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

References XO.

◆ GetFactoryPresets()

RegistryPaths EffectEqualization::GetFactoryPresets ( )
overridevirtual

Reimplemented from Effect.

Definition at line 490 of file Equalization.cpp.

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

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 587 of file Equalization.cpp.

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

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 363 of file Equalization.cpp.

364 {
365  return EffectTypeProcess;
366 }

References EffectTypeProcess.

◆ GraphicEQ()

void EffectEqualization::GraphicEQ ( Envelope env)
private

Definition at line 2641 of file Equalization.cpp.

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

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 2292 of file Equalization.cpp.

2293 {
2294  if( !wxStrcmp( tag, wxT("equalizationeffect") ) )
2295  {
2296  return this;
2297  }
2298 
2299  if( !wxStrcmp( tag, wxT("curve") ) )
2300  {
2301  return this;
2302  }
2303 
2304  if( !wxStrcmp( tag, wxT("point") ) )
2305  {
2306  return this;
2307  }
2308 
2309  return NULL;
2310 }

◆ HandleXMLTag()

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

Implements XMLTagHandler.

Definition at line 2191 of file Equalization.cpp.

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

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 657 of file Equalization.cpp.

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

References CalcFilter(), Effect::FindProject(), TrackList::Get(), 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 2154 of file Equalization.cpp.

2155 {
2156  return mDrawMode && mLin;
2157 }

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 1596 of file Equalization.cpp.

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

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 447 of file Equalization.cpp.

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

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

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

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

Here is the call graph for this function:

◆ ManualPage()

wxString EffectEqualization::ManualPage ( )
overridevirtual

Reimplemented from Effect.

Definition at line 351 of file Equalization.cpp.

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

References kEqOptionCurve, kEqOptionGraphic, and mOptions.

◆ OnClear()

void EffectEqualization::OnClear ( wxCommandEvent &  event)
private

Definition at line 2936 of file Equalization.cpp.

2937 {
2938  Flatten();
2939 }

References Flatten().

Here is the call graph for this function:

◆ OnCurve()

void EffectEqualization::OnCurve ( wxCommandEvent &  event)
private

Definition at line 2912 of file Equalization.cpp.

2913 {
2914  // Select NEW curve
2915  wxASSERT( mCurve != NULL );
2916  setCurve( mCurve->GetCurrentSelection() );
2917  if( !mDrawMode )
2918  UpdateGraphic();
2919 }

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

Here is the call graph for this function:

◆ OnDrawMode()

void EffectEqualization::OnDrawMode ( wxCommandEvent &  event)
private

Definition at line 2881 of file Equalization.cpp.

2882 {
2883  mDrawMode = true;
2884  UpdateDraw();
2885 }

References mDrawMode, and UpdateDraw().

Here is the call graph for this function:

◆ OnErase()

void EffectEqualization::OnErase ( wxEvent &  event)
private

Definition at line 2822 of file Equalization.cpp.

2823 {
2824 }

Referenced by PopulateOrExchange().

Here is the caller graph for this function:

◆ OnGraphicMode()

void EffectEqualization::OnGraphicMode ( wxCommandEvent &  event)
private

Definition at line 2887 of file Equalization.cpp.

2888 {
2889  mDrawMode = false;
2890  UpdateGraphic();
2891 }

References mDrawMode, and UpdateGraphic().

Here is the call graph for this function:

◆ OnGridOnOff()

void EffectEqualization::OnGridOnOff ( wxCommandEvent &  event)
private

Definition at line 3009 of file Equalization.cpp.

3010 {
3011  mDrawGrid = mGridOnOff->IsChecked();
3012  mPanel->Refresh(false);
3013 }

References mDrawGrid, mGridOnOff, and mPanel.

◆ OnInterp()

void EffectEqualization::OnInterp ( wxCommandEvent &  event)
private

Definition at line 2870 of file Equalization.cpp.

2871 {
2872  bool bIsGraphic = !mDrawMode;
2873  if (bIsGraphic)
2874  {
2875  GraphicEQ(mLogEnvelope.get());
2876  EnvelopeUpdated();
2877  }
2878  mInterp = mInterpChoice->GetSelection();
2879 }

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 2941 of file Equalization.cpp.

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

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 3015 of file Equalization.cpp.

3016 {
3017  mLin = mLinFreq->IsChecked();
3018  if(IsLinear()) //going from log to lin freq scale
3019  {
3020  mFreqRuler->ruler.SetLog(false);
3022  EnvLogToLin();
3023  mEnvelope = mLinEnvelope.get();
3024  mLin = true;
3025  }
3026  else //going from lin to log freq scale
3027  {
3028  mFreqRuler->ruler.SetLog(true);
3030  EnvLinToLog();
3031  mEnvelope = mLogEnvelope.get();
3032  mLin = false;
3033  }
3034  mFreqRuler->Refresh(false);
3035  ForceRecalc();
3036 }

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 2924 of file Equalization.cpp.

2925 {
2926  EditCurvesDialog d(mUIParent, this, mCurve->GetSelection());
2927  d.ShowModal();
2928 
2929  // Reload the curve names
2930  UpdateCurves();
2931 
2932  // Allow control to resize
2933  mUIParent->Layout();
2934 }

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

Here is the call graph for this function:

◆ OnSize()

void EffectEqualization::OnSize ( wxSizeEvent &  event)
private

Definition at line 2826 of file Equalization.cpp.

2827 {
2828  mUIParent->Layout();
2829  event.Skip();
2830 }

References Effect::mUIParent.

◆ OnSlider()

void EffectEqualization::OnSlider ( wxCommandEvent &  event)
private

Definition at line 2832 of file Equalization.cpp.

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

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 2904 of file Equalization.cpp.

2905 {
2907 }

References TransferDataFromWindow().

Here is the call graph for this function:

◆ OnSliderDBMIN()

void EffectEqualization::OnSliderDBMIN ( wxCommandEvent &  event)
private

Definition at line 2899 of file Equalization.cpp.

2900 {
2902 }

References TransferDataFromWindow().

Here is the call graph for this function:

◆ OnSliderM()

void EffectEqualization::OnSliderM ( wxCommandEvent &  event)
private

Definition at line 2893 of file Equalization.cpp.

2894 {
2896  ForceRecalc();
2897 }

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 757 of file Equalization.cpp.

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

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 707 of file Equalization.cpp.

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

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 1291 of file Equalization.cpp.

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

References WaveTrack::Clear(), WaveTrack::ConvertToSampleFormat(), WaveTrack::EmptyCopy(), Filter(), floatSample, WaveTrack::Get(), WaveTrack::GetClipAtTime(), WaveTrack::GetClips(), WaveClip::GetEnvelope(), WaveTrack::GetMaxBlockSize(), Envelope::Insert(), 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 1839 of file Equalization.cpp.

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

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 2068 of file Equalization.cpp.

2069 {
2070  // Set current choice
2071  if (mCurve)
2072  {
2073  mCurve->SetSelection( curve );
2074  mCurveName = mCurves[ curve ].Name;
2075  }
2076 }

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 421 of file Equalization.cpp.

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

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 2047 of file Equalization.cpp.

2048 {
2049  unsigned i = 0;
2050  for( i = 0; i < mCurves.size(); i++ )
2051  if( curveName == mCurves[ i ].Name )
2052  break;
2053  if( i == mCurves.size())
2054  {
2056  XO("Requested curve not found, using 'unnamed'"),
2057  wxOK|wxICON_ERROR,
2058  XO("Curve not found") );
2059  setCurve();
2060  }
2061  else
2062  setCurve( i );
2063 }

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 1881 of file Equalization.cpp.

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

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 2042 of file Equalization.cpp.

2043 {
2044  setCurve((int) mCurves.size() - 1);
2045 }

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 2779 of file Equalization.cpp.

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

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 2801 of file Equalization.cpp.

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

Referenced by GraphicEQ().

Here is the caller graph for this function:

◆ Startup()

bool EffectEqualization::Startup ( )
overridevirtual

Reimplemented from Effect.

Definition at line 598 of file Equalization.cpp.

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

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 1232 of file Equalization.cpp.

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

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 1176 of file Equalization.cpp.

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

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 2357 of file Equalization.cpp.

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

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 1694 of file Equalization.cpp.

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

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 2385 of file Equalization.cpp.

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

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 2438 of file Equalization.cpp.

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

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 539 of file Equalization.cpp.

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

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 2315 of file Equalization.cpp.

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

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:
XMLWriter::EndTag
virtual void EndTag(const wxString &name)
Definition: XMLWriter.cpp:100
RegistryPaths
std::vector< RegistryPath > RegistryPaths
Definition: Types.h:262
EqualizationPanel::ForceRecalc
void ForceRecalc()
Definition: Equalization.cpp:3103
ID_Graphic
@ ID_Graphic
Definition: Equalization.cpp:130
ShuttleSetAutomation
Shuttle that sets parameters to a value (from a string)
Definition: Shuttle.h:105
TranslatableString
Definition: Types.h:290
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:36
ID_Invert
@ ID_Invert
Definition: Equalization.cpp:127
ShuttleGuiBase::AddChoice
wxChoice * AddChoice(const TranslatableString &Prompt, const TranslatableStrings &choices, int Selected=-1)
Definition: ShuttleGui.cpp:391
kEqOptionGraphic
const int kEqOptionGraphic
Definition: Equalization.h:24
Effect::FindProject
const AudacityProject * FindProject() const
Definition: Effect.cpp:2271
ShuttleGuiBase::StartVerticalLay
void StartVerticalLay(int iProp=1)
Definition: ShuttleGui.cpp:1177
WaveTrack
A Track that contains audio waveform data.
Definition: WaveTrack.h:68
CommandParameters::WriteEnum
bool WriteEnum(const wxString &key, int value, const EnumValueSymbol choices[], size_t nChoices)
Definition: EffectAutomationParameters.h:203
EffectTypeProcess
@ EffectTypeProcess
Definition: EffectInterface.h:59
wxSliderWrapper
wxSlider wxSliderWrapper
Definition: ShuttleGui.h:103
DB_TO_LINEAR
const double MIN_Threshold_Linear DB_TO_LINEAR(MIN_Threshold_dB)
Effect::mUIDialog
wxDialog * mUIDialog
Definition: Effect.h:476
EffectEqualization::mGraphic
wxRadioButton * mGraphic
Definition: Equalization.h:261
EQCURVES_REVISION
#define EQCURVES_REVISION
Definition: Equalization.cpp:158
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:651
Ruler::LinearDBFormat
@ LinearDBFormat
Definition: Ruler.h:34
fn
static const auto fn
Definition: WaveformView.cpp:1102
EffectEqualization::mdBMin
float mdBMin
Definition: Equalization.h:214
flag
static std::once_flag flag
Definition: WaveformView.cpp:1113
gPrefs
FileConfig * gPrefs
Definition: Prefs.cpp:67
EffectEqualization::WriteXML
void WriteXML(XMLWriter &xmlFile) const
Definition: Equalization.cpp:2315
Effect::MessageBox
int MessageBox(const TranslatableString &message, long style=DefaultMessageBoxStyle, const TranslatableString &titleStr={})
Definition: Effect.cpp:2478
WaveClip::GetEnvelope
Envelope * GetEnvelope()
Definition: WaveClip.h:242
ID_dBMin
@ ID_dBMin
Definition: Equalization.cpp:125
Effect::CopyInputTracks
void CopyInputTracks(bool allSyncLockSelected=false)
Definition: Effect.cpp:2070
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:2641
EffectEqualization::TransferDataFromWindow
bool TransferDataFromWindow() override
Definition: Equalization.cpp:1232
Envelope::Insert
void Insert(int point, const EnvPoint &p)
insert a point
Definition: Envelope.cpp:364
ShuttleGuiBase::AddRadioButtonToGroup
wxRadioButton * AddRadioButtonToGroup(const TranslatableString &Prompt, int selector=1, int initValue=0)
Definition: ShuttleGui.cpp:567
Ruler::SetLog
void SetLog(bool log)
Definition: Ruler.cpp:142
RealFFTf
void RealFFTf(fft_type *buffer, const FFTParam *h)
Definition: RealFFTf.cpp:165
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
kInterpStrings
static const EnumValueSymbol kInterpStrings[nInterpolations]
Definition: Equalization.cpp:161
ID_Manage
@ ID_Manage
Definition: Equalization.cpp:135
Effect::mT1
double mT1
Definition: Effect.h:466
Effect::LoadUserPreset
bool LoadUserPreset(const RegistryPath &name) override
Definition: Effect.cpp:553
EffectEqualization::mLoFreq
double mLoFreq
Definition: Equalization.h:226
FileNames::DataDir
AUDACITY_DLL_API FilePath DataDir()
Audacity user data directory.
Envelope::GetPoints
void GetPoints(double *bufferWhen, double *bufferValue, int bufferLen) const
Returns the sets of when and value pairs.
Definition: Envelope.cpp:697
ShuttleGui::AddSpace
wxSizerItem * AddSpace(int width, int height, int prop=0)
Definition: ShuttleGui.cpp:2421
Envelope::SetTrackLen
void SetTrackLen(double trackLen, double sampleDur=0.0)
Definition: Envelope.cpp:790
ShuttleGui::MinSize
ShuttleGui & MinSize()
Definition: ShuttleGui.h:740
XO
#define XO(s)
Definition: Internat.h:32
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:369
Effect::SetPrivateConfig
bool SetPrivateConfig(const RegistryPath &group, const RegistryPath &key, const wxString &value) override
Definition: Effect.cpp:986
Envelope::Reassign
int Reassign(double when, double value)
Move a point at when to value.
Definition: Envelope.cpp:672
ID_Length
@ ID_Length
Definition: Equalization.cpp:123
ShuttleGuiBase::EndMultiColumn
void EndMultiColumn()
Definition: ShuttleGui.cpp:1212
Effect::IsBatchProcessing
virtual bool IsBatchProcessing()
Definition: Effect.cpp:1189
kThirdOct
static const double kThirdOct[]
Definition: Equalization.cpp:171
floatSample
@ floatSample
Definition: Types.h:722
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:2438
EffectEqualization::mWhenSliders
double mWhenSliders[NUMBER_OF_BANDS+1]
Definition: Equalization.h:220
Effect::SaveUserPreset
bool SaveUserPreset(const RegistryPath &name) override
Definition: Effect.cpp:569
RealFFT
void RealFFT(size_t NumSamples, const float *RealIn, float *RealOut, float *ImagOut)
Definition: FFT.cpp:231
ID_Curve
@ ID_Curve
Definition: Equalization.cpp:134
EffectEqualization::mdBMinSlider
wxSlider * mdBMinSlider
Definition: Equalization.h:269
WaveTrack::EmptyCopy
Holder EmptyCopy(const SampleBlockFactoryPtr &pFactory={}) const
Definition: WaveTrack.cpp:574
nInterpolations
@ nInterpolations
Definition: Equalization.cpp:153
XMLValueChecker::IsGoodString
static bool IsGoodString(const wxString &str)
Definition: XMLTagHandler.cpp:39
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:1839
ShuttleGui::Id
ShuttleGui & Id(int id)
Definition: ShuttleGui.cpp:2248
EffectEqualization::szr1
wxSizer * szr1
Definition: Equalization.h:250
WaveTrack::Get
bool Get(samplePtr buffer, sampleFormat format, sampleCount start, size_t len, fillFormat fill=fillZero, bool mayThrow=true, sampleCount *pNumWithinClips=nullptr) const
Definition: WaveTrack.cpp:1895
EditCurvesDialog
Definition: Equalization.h:353
XMLFileReader::Parse
bool Parse(XMLTagHandler *baseHandler, const FilePath &fname)
Definition: XMLFileReader.cpp:41
limitSampleBufferSize
size_t limitSampleBufferSize(size_t bufferSize, sampleCount limit)
Definition: Types.h:706
ReorderToTime
void ReorderToTime(const FFTParam *hFFT, const fft_type *buffer, fft_type *TimeOut)
Definition: RealFFTf.cpp:364
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
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:734
WaveClip
This allows multiple clips to be a part of one WaveTrack.
Definition: WaveClip.h:172
EQPoint
EQPoint is used with EQCurve and hence EffectEqualization.
Definition: Equalization.h:50
TranslatableStrings
std::vector< TranslatableString > TranslatableStrings
Definition: Types.h:555
ReadAndVerifyEnum
#define ReadAndVerifyEnum(name, list, listSize)
Definition: Effect.h:620
ShuttleGuiBase::SetSizerProportion
void SetSizerProportion(int iProp)
Definition: ShuttleGui.h:498
EffectEqualization::Flatten
void Flatten()
Definition: Equalization.cpp:2162
EffectEqualization::mLinEnvelope
std::unique_ptr< Envelope > mLinEnvelope
Definition: Equalization.h:235
ReadAndVerifyInt
#define ReadAndVerifyInt(name)
Definition: Effect.h:631
samplePtr
char * samplePtr
Definition: Types.h:737
EffectEqualization::mPanel
EqualizationPanel * mPanel
Definition: Equalization.h:258
kBspline
@ kBspline
Definition: Equalization.cpp:150
XXO
#define XXO(s)
Definition: Internat.h:45
WaveTrack::ConvertToSampleFormat
void ConvertToSampleFormat(sampleFormat format, const std::function< void(size_t)> &progressReport={})
Definition: WaveTrack.cpp:455
WaveTrack::Clear
void Clear(double t0, double t1) override
Definition: WaveTrack.cpp:654
EffectEqualization::spline
void spline(double x[], double y[], size_t n, double y2[])
Definition: Equalization.cpp:2779
ShuttleGuiBase::EndHorizontalLay
void EndHorizontalLay()
Definition: ShuttleGui.cpp:1170
XMLFileReader::GetErrorStr
const TranslatableString & GetErrorStr() const
Definition: XMLFileReader.cpp:177
Effect::mT0
double mT0
Definition: Effect.h:465
EQCURVES_VERSION
#define EQCURVES_VERSION
Definition: Equalization.cpp:157
name
const TranslatableString name
Definition: Equalization.cpp:470
ShuttleGetAutomation
Shuttle that gets parameter values into a string.
Definition: Shuttle.h:87
EffectEqualization::mMSlider
wxSlider * mMSlider
Definition: Equalization.h:268
EffectEqualization::Select
void Select(int sel)
Definition: Equalization.cpp:2068
label
TranslatableString label
Definition: Tags.cpp:755
ShuttleGuiBase::StartHorizontalLay
void StartHorizontalLay(int PositionFlags=wxALIGN_CENTRE, int iProp=1)
Definition: ShuttleGui.cpp:1160
InverseRealFFT
void InverseRealFFT(size_t NumSamples, const float *RealIn, const float *ImagIn, float *RealOut)
Definition: FFT.cpp:269
WaveTrack::LongSamplesToTime
double LongSamplesToTime(sampleCount pos) const
Convert correctly between a number of samples and an (absolute) time in seconds.
Definition: WaveTrack.cpp:1772
EffectEqualization::UpdateCurves
void UpdateCurves()
Definition: Equalization.cpp:2357
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:657
ShuttleGuiBase::StartMultiColumn
void StartMultiColumn(int nCols, int PositionFlags=wxALIGN_LEFT)
Definition: ShuttleGui.cpp:1203
ID_Draw
@ ID_Draw
Definition: Equalization.cpp:129
ShuttleGuiBase::EndVerticalLay
void EndVerticalLay()
Definition: ShuttleGui.cpp:1196
EffectEqualization::setCurve
void setCurve(void)
Definition: Equalization.cpp:2042
Effect::LoadFactoryDefaults
bool LoadFactoryDefaults() override
Definition: Effect.cpp:605
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:256
ShuttleGuiBase::AddFixedText
void AddFixedText(const TranslatableString &Str, bool bCenter=false, int wrapWidth=0)
Definition: ShuttleGui.cpp:433
WaveTrack::GetClips
WaveClipHolders & GetClips()
Definition: WaveTrack.h:339
EffectEqualization::OnLinFreq
void OnLinFreq(wxCommandEvent &event)
Definition: Equalization.cpp:3015
ID_Slider
@ ID_Slider
Definition: Equalization.cpp:145
Effect::ReplaceProcessedTracks
void ReplaceProcessedTracks(const bool bGoodResult)
Definition: Effect.cpp:2192
Msgids
TranslatableStrings Msgids(const EnumValueSymbol strings[], size_t nStrings)
Definition: Internat.cpp:267
WaveTrack::Paste
void Paste(double t0, const Track *src) override
Definition: WaveTrack.cpp:1171
EffectEqualization::szrG
wxSizer * szrG
Definition: Equalization.h:245
ShuttleGuiBase::GetParent
wxWindow * GetParent()
Definition: ShuttleGui.h:503
kCubic
@ kCubic
Definition: Equalization.cpp:152
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:2801
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:561
EffectEqualization::mLinFreq
wxCheckBox * mLinFreq
Definition: Equalization.h:262
InverseRealFFTf
void InverseRealFFTf(fft_type *buffer, const FFTParam *h)
Definition: RealFFTf.cpp:267
EffectEqualization::mDirty
bool mDirty
Definition: Equalization.h:229
ID_dBMax
@ ID_dBMax
Definition: Equalization.cpp:124
EffectEqualization::mInterp
int mInterp
Definition: Equalization.h:216
WaveTrack::GetClipAtTime
WaveClip * GetClipAtTime(double time)
Definition: WaveTrack.cpp:2102
Effect::mOutputTracks
std::shared_ptr< TrackList > mOutputTracks
Definition: Effect.h:464
ID_Grid
@ ID_Grid
Definition: Equalization.cpp:133
NUMBER_OF_BANDS
#define NUMBER_OF_BANDS
Definition: Equalization.h:14
FileNames::ResourcesDir
AUDACITY_DLL_API FilePath ResourcesDir()
ShuttleGui::Prop
ShuttleGui & Prop(int iProp)
Definition: ShuttleGui.h:732
ShuttleGuiBase::AddSlider
wxSlider * AddSlider(const TranslatableString &Prompt, int pos, int Max, int Min=0)
Definition: ShuttleGui.cpp:582
RulerPanel::Options::LabelEdges
Options & LabelEdges(bool l)
Definition: Ruler.h:250
EffectEqualization::EnvLogToLin
void EnvLogToLin(void)
Definition: Equalization.cpp:2499
EffectEqualization::ProcessOne
bool ProcessOne(int count, WaveTrack *t, sampleCount start, sampleCount len)
Definition: Equalization.cpp:1291
Effect::GetCurrentSettingsGroup
RegistryPath GetCurrentSettingsGroup() override
Definition: Effect.cpp:865
ShuttleGuiBase::AddButton
wxButton * AddButton(const TranslatableString &Text, int PositionFlags=wxALIGN_CENTRE, bool setDefault=false)
Definition: ShuttleGui.cpp:353
EffectEqualization::IsLinear
bool IsLinear()
Definition: Equalization.cpp:2154
min
int min(int a, int b)
Definition: CompareAudioCommand.cpp:106
WaveTrack::GetMaxBlockSize
size_t GetMaxBlockSize() const
Definition: WaveTrack.cpp:1578
EffectEqualization::mdBMaxSlider
wxSlider * mdBMaxSlider
Definition: Equalization.h:270
ShuttleGui::Name
ShuttleGui & Name(const TranslatableString &name)
Definition: ShuttleGui.h:670
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:1485
ShuttleGuiBase::AddWindow
wxWindow * AddWindow(wxWindow *pWindow)
Definition: ShuttleGui.cpp:292
FileConfig::Flush
virtual bool Flush(bool bCurrentOnly=false) wxOVERRIDE
Definition: FileConfig.cpp:151
EffectEqualization::EnvLinToLog
void EnvLinToLog(void)
Definition: Equalization.cpp:2523
ID_Linear
@ ID_Linear
Definition: Equalization.cpp:132
TrackList::Get
static TrackList & Get(AudacityProject &project)
Definition: Track.cpp:495
EffectEqualization::mDisallowCustom
bool mDisallowCustom
Definition: Equalization.h:225
XMLFileReader
Reads a file and passes the results through an XMLTagHandler.
Definition: XMLFileReader.h:20
ShuttleGui::Position
ShuttleGui & Position(int flags)
Definition: ShuttleGui.h:719
ShuttleGuiBase::GetSizer
wxSizer * GetSizer()
Definition: ShuttleGui.h:513
Effect::mUIParent
wxWindow * mUIParent
Definition: Effect.h:477
names
static TranslatableStrings names
Definition: Tags.cpp:743
_
#define _(s)
Definition: Internat.h:76
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:706
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:2081
Verbatim
TranslatableString Verbatim(wxString str)
Definition: Types.h:581
EffectEqualization::szrL
wxSizer * szrL
Definition: Equalization.h:249
GuardedCall
R GuardedCall(const F1 &body, const F2 &handler=F2::Default(), const F3 &delayedHandler={})
Execute some code on any thread; catch any AudacityException; enqueue error report on the main thread...
Definition: AudacityException.h:189
EffectEqualization::GetDefaultFileName
bool GetDefaultFileName(wxFileName &fileName)
Definition: Equalization.cpp:1812
EffectEqualization::mCurveName
wxString mCurveName
Definition: Equalization.h:211
ID_Interp
@ ID_Interp
Definition: Equalization.cpp:131
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:2092
RulerPanel::Options
Definition: Ruler.h:234
EffectEqualization::GetPrefsPrefix
wxString GetPrefsPrefix()
Definition: Equalization.cpp:587
EQCurveArray
std::vector< EQCurve > EQCurveArray
Definition: Equalization.h:86
EffectEqualization::TransferDataToWindow
bool TransferDataToWindow() override
Definition: Equalization.cpp:1176
EffectEqualization::Filter
void Filter(size_t len, float *buffer)
Definition: Equalization.cpp:1568
RulerPanel::ruler
Ruler ruler
Definition: Ruler.h:288
Envelope::Flatten
void Flatten(double value)
Definition: Envelope.cpp:133
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:2385
EffectEqualization::mHiFreq
double mHiFreq
Definition: Equalization.h:227
ShuttleGui::GetMode
teShuttleMode GetMode()
Definition: ShuttleGui.h:759
EffectEqualization::mEnvelope
Envelope * mEnvelope
Definition: Equalization.h:236
EffectEqualization::CalcFilter
bool CalcFilter()
Definition: Equalization.cpp:1455
kCosine
@ kCosine
Definition: Equalization.cpp:151
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:231
NUM_PTS
#define NUM_PTS
Definition: Equalization.h:15
TranslatableString::Translation
wxString Translation() const
Definition: Types.h:337
ShuttleGuiBase::SetBorder
void SetBorder(int Border)
Definition: ShuttleGui.h:497
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:159
TranslatableString::Format
TranslatableString & Format(Args &&...args) &
Definition: Types.h:363
ShuttleGuiBase::AddVariableText
wxStaticText * AddVariableText(const TranslatableString &Str, bool bCenter=false, int PositionFlags=0, int wrapWidth=0)
Definition: ShuttleGui.cpp:456
ID_Clear
@ ID_Clear
Definition: Equalization.cpp:126
EffectEqualization::mDrawGrid
bool mDrawGrid
Definition: Equalization.h:217
safenew
#define safenew
Definition: MemoryX.h:8
EffectEqualization::OnErase
void OnErase(wxEvent &event)
Definition: Equalization.cpp:2822
lrint
#define lrint(dbl)
Definition: float_cast.h:148
ShuttleGuiBase::SetStretchyCol
void SetStretchyCol(int i)
Used to modify an already placed FlexGridSizer to make a column stretchy.
Definition: ShuttleGui.cpp:195
EffectEqualization::mInterpChoice
wxChoice * mInterpChoice
Definition: Equalization.h:264
EffectEqualizationCurve::Symbol
static const ComponentInterfaceSymbol Symbol
Definition: Equalization.h:287
TrackList::Selected
auto Selected() -> TrackIterRange< TrackType >
Definition: Track.h:1371
ShuttleGuiBase::SetStretchyRow
void SetStretchyRow(int i)
Used to modify an already placed FlexGridSizer to make a row stretchy.
Definition: ShuttleGui.cpp:205
Effect::TrackProgress
bool TrackProgress(int whichTrack, double frac, const TranslatableString &={})
Definition: Effect.cpp:2024
ArrayOf< float >
ShuttleSetAutomation::SetForWriting
void SetForWriting(CommandParameters *pEap)
Definition: Shuttle.h:113
XMLWriter::StartTag
virtual void StartTag(const wxString &name)
Definition: XMLWriter.cpp:77
EffectEqualization::mSliders
wxSlider * mSliders[NUMBER_OF_BANDS]
Definition: Equalization.h:271
RulerPanel::Options::Log
Options & Log(bool l)
Definition: Ruler.h:244
ReadAndVerifyBool
#define ReadAndVerifyBool(name)
Definition: Effect.h:634
Envelope::GetNumberOfPoints
size_t GetNumberOfPoints() const
Return number of points.
Definition: Envelope.cpp:692
EffectEqualization::mDraw
wxRadioButton * mDraw
Definition: Equalization.h:260
EffectEqualization::UpdateDefaultCurves
void UpdateDefaultCurves(bool updateAll=false)
Definition: Equalization.cpp:1694
Internat::CompatibleToDouble
static bool CompatibleToDouble(const wxString &stringToConvert, double *result)
Convert a string to a number.
Definition: Internat.cpp:139
EffectEqualization::mCurve
wxChoice * mCurve
Definition: Equalization.h:265
EffectEqualization::ErrMin
void ErrMin(void)
Definition: Equalization.cpp:2565
EffectEqualization::windowSize
static const size_t windowSize
Definition: Equalization.h:142