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

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

#include <Equalization.h>

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

Public Member Functions

 EffectEqualization (int Options=kEqLegacy)
 
virtual ~EffectEqualization ()
 
ComponentInterfaceSymbol GetSymbol () override
 
TranslatableString GetDescription () override
 
ManualPageID ManualPage () override
 Name of a page in the Audacity alpha manual, default is empty. More...
 
bool DefineParams (ShuttleParams &S) override
 
EffectType GetType () override
 Type determines how it behaves. More...
 
bool GetAutomationParameters (CommandParameters &parms) override
 Save current settings into parms. More...
 
bool SetAutomationParameters (CommandParameters &parms) override
 Change settings to those stored in parms. More...
 
bool LoadFactoryDefaults () override
 Change settings back to "factory default". More...
 
RegistryPaths GetFactoryPresets () override
 Report names of factory presets. More...
 
bool LoadFactoryPreset (int id) override
 Change settings to the preset whose name is GetFactoryPresets()[id] More...
 
bool 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
 Report identifier and user-visible name of the effect protocol. More...
 
bool IsInteractive () override
 Whether the effect needs a dialog for entry of settings. More...
 
bool IsDefault () override
 Whether the effect sorts "above the line" in the menus. More...
 
bool IsLegacy () override
 
bool SupportsRealtime () override
 Whether the effect supports realtime previewing (while audio is playing). More...
 
bool SupportsAutomation () override
 Whether the effect can be used without the UI, in a macro. More...
 
bool LoadUserPreset (const RegistryPath &name) override
 Change settings to a user-named preset. More...
 
bool SaveUserPreset (const RegistryPath &name) override
 Save current settings as a user-named preset. More...
 
bool SetHost (EffectHostInterface *host) override
 
unsigned GetAudioInCount () override
 
unsigned GetAudioOutCount () override
 
int GetMidiInCount () override
 
int GetMidiOutCount () override
 
sampleCount GetLatency () override
 Called for destructive, non-realtime effect computation. More...
 
size_t GetTailSize () override
 
void SetSampleRate (double rate) override
 
size_t SetBlockSize (size_t maxBlockSize) override
 
size_t GetBlockSize () const override
 
bool ProcessInitialize (sampleCount totalLen, ChannelNames chanMap=NULL) override
 Called for destructive, non-realtime effect computation. More...
 
bool ProcessFinalize () override
 Called for destructive, non-realtime effect computation. More...
 
size_t ProcessBlock (float **inBlock, float **outBlock, size_t blockLen) override
 Called for destructive, non-realtime effect computation. More...
 
bool RealtimeInitialize () override
 
bool RealtimeAddProcessor (unsigned numChannels, float sampleRate) override
 
bool RealtimeFinalize () override
 
bool RealtimeSuspend () override
 
bool RealtimeResume () noexcept override
 
bool RealtimeProcessStart () override
 
size_t RealtimeProcess (int group, float **inbuf, float **outbuf, size_t numSamples) override
 
bool RealtimeProcessEnd () noexcept override
 
int ShowClientInterface (wxWindow &parent, wxDialog &dialog, bool forceModal=false) override
 
bool PopulateUI (ShuttleGui &S) final
 Adds controls to a panel that is given as the parent window of S More...
 
bool IsGraphicalUI () override
 
bool HideUI () override
 
bool CanExportPresets () override
 
void ExportPresets () override
 
void ImportPresets () override
 
bool HasOptions () override
 
void ShowOptions () override
 
EffectDefinitionInterfaceGetDefinition () override
 
double GetDuration () override
 
NumericFormatSymbol GetDurationFormat () override
 
virtual NumericFormatSymbol GetSelectionFormat ()
 
void SetDuration (double duration) override
 
RegistryPath GetUserPresetsGroup (const RegistryPath &name) override
 
RegistryPath GetCurrentSettingsGroup () override
 
RegistryPath GetFactoryDefaultsGroup () override
 
virtual wxString GetSavedStateGroup ()
 
int ShowHostInterface (wxWindow &parent, const EffectDialogFactory &factory, bool forceModal=false) override
 
unsigned TestUIFlags (unsigned mask)
 
void SetPresetParameters (const wxArrayString *Names, const wxArrayString *Values)
 
virtual bool Startup (EffectUIClientInterface *client)
 
virtual bool GetAutomationParametersAsString (wxString &parms)
 
virtual bool SetAutomationParametersFromString (const wxString &parms)
 
virtual bool IsBatchProcessing ()
 
virtual void SetBatchProcessing (bool start)
 
bool DoEffect (double projectRate, TrackList *list, WaveTrackFactory *factory, NotifyingSelectedRegion &selectedRegion, unsigned flags, wxWindow *pParent=nullptr, const EffectDialogFactory &dialogFactory={})
 
bool Delegate (Effect &delegate, wxWindow &parent, const EffectDialogFactory &factory)
 
int MessageBox (const TranslatableString &message, long style=DefaultMessageBoxStyle, const TranslatableString &titleStr={})
 
- Public Member Functions inherited from EffectUIClientInterface
virtual ~EffectUIClientInterface ()
 
- Public Member Functions inherited from EffectProcessor
virtual ~EffectProcessor ()
 
- Public Member Functions inherited from EffectDefinitionInterface
virtual ~EffectDefinitionInterface ()
 
virtual EffectType GetClassification ()
 Determines which menu it appears in; default same as GetType(). More...
 
virtual bool EnablesDebug ()
 Whether the effect dialog should have a Debug button; default, always false. More...
 
virtual FilePath HelpPage ()
 Fully qualified local help file name, default is empty. More...
 
virtual bool IsHiddenFromMenus ()
 Default is false. More...
 
- Public Member Functions inherited from ComponentInterface
virtual ~ComponentInterface ()
 
TranslatableString GetName ()
 
virtual bool DefineParams (ShuttleParams &WXUNUSED(S))
 
- Public Member Functions inherited from EffectUIHostInterface
virtual ~EffectUIHostInterface ()
 
- Public Member Functions inherited from EffectHostInterface
virtual ~EffectHostInterface ()
 
- Public Member Functions inherited from XMLTagHandler
 XMLTagHandler ()
 
virtual ~XMLTagHandler ()
 
virtual void HandleXMLEndTag (const std::string_view &WXUNUSED(tag))
 
virtual void HandleXMLContent (const std::string_view &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 std::string_view &tag, const AttributesList &attrs) override
 
XMLTagHandlerHandleXMLChild (const std::string_view &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 }
 
- Static Public Member Functions inherited from Effect
static void IncEffectCounter ()
 
- Static Public Member Functions inherited from EffectDefinitionInterface
static Identifier GetSquashedName (const Identifier &ident)
 A utility that strips spaces and CamelCases a name. More...
 
- Protected Member Functions inherited from Effect
bool EnableApply (bool enable=true)
 
bool EnablePreview (bool enable=true)
 
virtual bool CheckWhetherSkipEffect ()
 
virtual bool ProcessPass ()
 
virtual bool InitPass1 ()
 
virtual bool InitPass2 ()
 
virtual void End ()
 
virtual double CalcPreviewInputLength (double previewLength)
 
virtual void Preview (bool dryOnly)
 
bool TotalProgress (double frac, const TranslatableString &={})
 
bool TrackProgress (int whichTrack, double frac, const TranslatableString &={})
 
bool TrackGroupProgress (int whichGroup, double frac, const TranslatableString &={})
 
int GetNumWaveTracks ()
 
int GetNumWaveGroups ()
 
void GetBounds (const WaveTrack &track, const WaveTrack *pRight, sampleCount *start, sampleCount *len)
 
void SetLinearEffectFlag (bool linearEffectFlag)
 
void SetPreviewFullSelectionFlag (bool previewDurationFlag)
 
bool IsPreviewing ()
 
void IncludeNotSelectedPreviewTracks (bool includeNotSelected)
 
void CopyInputTracks (bool allSyncLockSelected=false)
 
std::shared_ptr< AddedAnalysisTrackAddAnalysisTrack (const wxString &name=wxString())
 
ModifiedAnalysisTrack ModifyAnalysisTrack (const LabelTrack *pOrigTrack, const wxString &name=wxString())
 
void ReplaceProcessedTracks (const bool bGoodResult)
 
TrackAddToOutputTracks (const std::shared_ptr< Track > &t)
 
const TrackListinputTracks () const
 
const AudacityProjectFindProject () const
 
- Protected Attributes inherited from Effect
BasicUI::ProgressDialogmProgress = nullptr
 
double mProjectRate
 
double mSampleRate
 
WaveTrackFactorymFactory
 
std::shared_ptr< TrackListmOutputTracks
 
double mT0
 
double mT1
 
wxArrayString mPresetNames
 
wxArrayString mPresetValues
 
int mPass
 
wxWeakRef< wxDialog > mHostUIDialog
 This smart pointer tracks the lifetime of the dialog. More...
 
wxWeakRef< wxDialog > mUIDialog
 This weak pointer may be the same as the above, or null. More...
 
wxWindow * mUIParent
 
unsigned mUIFlags { 0 }
 
sampleCount mSampleCnt
 
- Static Protected Attributes inherited from Effect
static int nEffectsDone =0
 

Detailed Description

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 94 of file Equalization.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
private
Enumerator
loFreqI 

Definition at line 145 of file Equalization.h.

145 {loFreqI=20};

Constructor & Destructor Documentation

◆ EffectEqualization()

EffectEqualization::EffectEqualization ( int  Options = kEqLegacy)

◆ ~EffectEqualization()

EffectEqualization::~EffectEqualization ( )
virtual

Definition at line 336 of file Equalization.cpp.

337 {
338 }

Member Function Documentation

◆ CalcFilter()

bool EffectEqualization::CalcFilter ( )
private

Definition at line 1460 of file Equalization.cpp.

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

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

763 {
764  mCurve = NULL;
765  mPanel = NULL;
766 
767  return Effect::CloseUI();
768 }

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

Here is the call graph for this function:

◆ DefineParams()

bool EffectEqualization::DefineParams ( ShuttleParams S)
override

Definition at line 374 of file Equalization.cpp.

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

References kInterpStrings, mCurves, mInterp, mLin, mM, nInterpolations, S, 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 2098 of file Equalization.cpp.

2099 {
2100  if (IsLinear())
2101  {
2102  EnvelopeUpdated(mLinEnvelope.get(), true);
2103  }
2104  else
2105  {
2106  EnvelopeUpdated(mLogEnvelope.get(), false);
2107  }
2108 }

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

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

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

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

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

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

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

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

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

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

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

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

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

2088 {
2089  if (mPanel)
2090  {
2091  mPanel->ForceRecalc();
2092  }
2093 }

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

Save current settings into parms.

Reimplemented from Effect.

Definition at line 416 of file Equalization.cpp.

417 {
418  parms.Write(KEY_FilterLength, (unsigned long)mM);
419  //parms.Write(KEY_CurveName, mCurveName);
420  parms.Write(KEY_InterpLin, mLin);
421  parms.WriteEnum(KEY_InterpMeth, mInterp, kInterpStrings, nInterpolations);
422 
423  return true;
424 }

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

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

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

352 {
353  return XO("Adjusts the volume levels of particular frequencies");
354 }

References XO.

◆ GetFactoryPresets()

RegistryPaths EffectEqualization::GetFactoryPresets ( )
overridevirtual

Report names of factory presets.

Reimplemented from Effect.

Definition at line 495 of file Equalization.cpp.

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

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

597 {
598  wxString base = wxT("/Effects/Equalization/");
599  if( mOptions == kEqOptionGraphic )
600  base = wxT("/Effects/GraphicEq/");
601  else if( mOptions == kEqOptionCurve )
602  base = wxT("/Effects/FilterCurve/");
603  return base;
604 }

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

Type determines how it behaves.

Reimplemented from Effect.

Definition at line 368 of file Equalization.cpp.

369 {
370  return EffectTypeProcess;
371 }

References EffectTypeProcess.

◆ GraphicEQ()

void EffectEqualization::GraphicEQ ( Envelope env)
private

Definition at line 2640 of file Equalization.cpp.

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

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 std::string_view &  tag)
overrideprivatevirtual

Implements XMLTagHandler.

Definition at line 2291 of file Equalization.cpp.

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

◆ HandleXMLTag()

bool EffectEqualization::HandleXMLTag ( const std::string_view &  tag,
const AttributesList attrs 
)
overrideprivatevirtual

Implements XMLTagHandler.

Definition at line 2197 of file Equalization.cpp.

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

References mCurves.

◆ Init()

bool EffectEqualization::Init ( )
overridevirtual

Reimplemented from Effect.

Definition at line 670 of file Equalization.cpp.

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

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

Here is the call graph for this function:

◆ IsLinear()

bool EffectEqualization::IsLinear ( )
private

Definition at line 2160 of file Equalization.cpp.

2161 {
2162  return mDrawMode && mLin;
2163 }

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

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

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

Change settings back to "factory default".

Reimplemented from Effect.

Definition at line 452 of file Equalization.cpp.

453 {
454  mdBMin = DEF_dBMin;
455  mdBMax = DEF_dBMax;
456  mDrawMode = DEF_DrawMode;
457  mDrawGrid = DEF_DrawGrid;
458 
459  if( mOptions == kEqOptionCurve)
460  mDrawMode = true;
461  if( mOptions == kEqOptionGraphic)
462  mDrawMode = false;
463 
465 }

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

Change settings to the preset whose name is GetFactoryPresets()[id]

Reimplemented from Effect.

Definition at line 509 of file Equalization.cpp.

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

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

Here is the call graph for this function:

◆ ManualPage()

ManualPageID EffectEqualization::ManualPage ( )
overridevirtual

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

Reimplemented from EffectDefinitionInterface.

Definition at line 356 of file Equalization.cpp.

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

References kEqOptionCurve, kEqOptionGraphic, and mOptions.

◆ OnClear()

void EffectEqualization::OnClear ( wxCommandEvent &  event)
private

Definition at line 2935 of file Equalization.cpp.

2936 {
2937  Flatten();
2938 }

References Flatten().

Here is the call graph for this function:

◆ OnCurve()

void EffectEqualization::OnCurve ( wxCommandEvent &  event)
private

Definition at line 2911 of file Equalization.cpp.

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

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

Here is the call graph for this function:

◆ OnDrawMode()

void EffectEqualization::OnDrawMode ( wxCommandEvent &  event)
private

Definition at line 2880 of file Equalization.cpp.

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

References mDrawMode, and UpdateDraw().

Here is the call graph for this function:

◆ OnErase()

void EffectEqualization::OnErase ( wxEvent &  event)
private

Definition at line 2821 of file Equalization.cpp.

2822 {
2823 }

Referenced by PopulateOrExchange().

Here is the caller graph for this function:

◆ OnGraphicMode()

void EffectEqualization::OnGraphicMode ( wxCommandEvent &  event)
private

Definition at line 2886 of file Equalization.cpp.

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

References mDrawMode, and UpdateGraphic().

Here is the call graph for this function:

◆ OnGridOnOff()

void EffectEqualization::OnGridOnOff ( wxCommandEvent &  event)
private

Definition at line 3008 of file Equalization.cpp.

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

References mDrawGrid, mGridOnOff, and mPanel.

◆ OnInterp()

void EffectEqualization::OnInterp ( wxCommandEvent &  event)
private

Definition at line 2869 of file Equalization.cpp.

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

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

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

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

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

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

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

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

Here is the call graph for this function:

◆ OnSize()

void EffectEqualization::OnSize ( wxSizeEvent &  event)
private

Definition at line 2825 of file Equalization.cpp.

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

References Effect::mUIParent.

◆ OnSlider()

void EffectEqualization::OnSlider ( wxCommandEvent &  event)
private

Definition at line 2831 of file Equalization.cpp.

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

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

2904 {
2906 }

References TransferDataFromWindow().

Here is the call graph for this function:

◆ OnSliderDBMIN()

void EffectEqualization::OnSliderDBMIN ( wxCommandEvent &  event)
private

Definition at line 2898 of file Equalization.cpp.

2899 {
2901 }

References TransferDataFromWindow().

Here is the call graph for this function:

◆ OnSliderM()

void EffectEqualization::OnSliderM ( wxCommandEvent &  event)
private

Definition at line 2892 of file Equalization.cpp.

2893 {
2895  ForceRecalc();
2896 }

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

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

References eIsCreating, EqualizationPanel, ForceRecalc(), TranslatableString::Format(), Effect::GetCurrentSettingsGroup(), 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, mInterpChoice, mLinFreq, mM, mMSlider, mMText, mOptions, mPanel, Msgids(), mSliders, mSlidersOld, Effect::mUIParent, nInterpolations, NUMBER_OF_BANDS, OnErase(), S, safenew, szr1, szrG, szrH, szrI, szrL, szrV, Verbatim(), XO, and XXO.

Here is the call graph for this function:

◆ Process()

bool EffectEqualization::Process ( )
overridevirtual

If Process() is not overridden, it uses ProcessInitialize(), ProcessBlock(), and ProcessFinalize() methods of EffectProcessor, and also GetLatency() to determine how many leading output samples to discard and how many extra samples to produce.

Reimplemented from Effect.

Definition at line 720 of file Equalization.cpp.

721 {
722 #ifdef EXPERIMENTAL_EQ_SSE_THREADED
723  if(mEffectEqualization48x) {
724  if(mBench) {
725  mBench=false;
726  return mEffectEqualization48x->Benchmark(this);
727  }
728  else
729  return mEffectEqualization48x->Process(this);
730  }
731 #endif
732  this->CopyInputTracks(); // Set up mOutputTracks.
733  CalcFilter();
734  bool bGoodResult = true;
735 
736  int count = 0;
737  for( auto track : mOutputTracks->Selected< WaveTrack >() ) {
738  double trackStart = track->GetStartTime();
739  double trackEnd = track->GetEndTime();
740  double t0 = mT0 < trackStart? trackStart: mT0;
741  double t1 = mT1 > trackEnd? trackEnd: mT1;
742 
743  if (t1 > t0) {
744  auto start = track->TimeToLongSamples(t0);
745  auto end = track->TimeToLongSamples(t1);
746  auto len = end - start;
747 
748  if (!ProcessOne(count, track, start, len))
749  {
750  bGoodResult = false;
751  break;
752  }
753  }
754 
755  count++;
756  }
757 
758  this->ReplaceProcessedTracks(bGoodResult);
759  return bGoodResult;
760 }

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

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

References WaveTrack::Clear(), WaveTrack::ConvertToSampleFormat(), WaveTrack::EmptyCopy(), Filter(), floatSample, WaveTrack::GetClips(), SampleTrack::GetFloats(), WaveTrack::GetMaxBlockSize(), WaveTrack::Join(), limitSampleBufferSize(), SampleTrack::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 1845 of file Equalization.cpp.

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

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

2075 {
2076  // Set current choice
2077  if (mCurve)
2078  {
2079  mCurve->SetSelection( curve );
2080  mCurveName = mCurves[ curve ].Name;
2081  }
2082 }

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

Change settings to those stored in parms.

Reimplemented from Effect.

Definition at line 426 of file Equalization.cpp.

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

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

2054 {
2055  unsigned i = 0;
2056  for( i = 0; i < mCurves.size(); i++ )
2057  if( curveName == mCurves[ i ].Name )
2058  break;
2059  if( i == mCurves.size())
2060  {
2062  XO("Requested curve not found, using 'unnamed'"),
2063  wxOK|wxICON_ERROR,
2064  XO("Curve not found") );
2065  setCurve();
2066  }
2067  else
2068  setCurve( i );
2069 }

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

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

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

2049 {
2050  setCurve((int) mCurves.size() - 1);
2051 }

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

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

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

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

Referenced by GraphicEQ().

Here is the caller graph for this function:

◆ Startup()

bool EffectEqualization::Startup ( )
overridevirtual

Reimplemented from Effect.

Definition at line 607 of file Equalization.cpp.

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

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

Here is the call graph for this function:

◆ TransferDataFromWindow()

bool EffectEqualization::TransferDataFromWindow ( )
overridevirtual

Reimplemented from Effect.

Definition at line 1252 of file Equalization.cpp.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Here is the call graph for this function:

◆ WriteXML()

void EffectEqualization::WriteXML ( XMLWriter xmlFile) const
private

Definition at line 2314 of file Equalization.cpp.

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

Referenced by SaveCurves().

Here is the caller graph for this function:

Friends And Related Function Documentation

◆ EditCurvesDialog

friend class EditCurvesDialog
friend

Definition at line 280 of file Equalization.h.

◆ EqualizationPanel

friend class EqualizationPanel
friend

Definition at line 279 of file Equalization.h.

Referenced by PopulateOrExchange().

Member Data Documentation

◆ hFFT

HFFT EffectEqualization::hFFT
private

Definition at line 207 of file Equalization.h.

Referenced by Filter().

◆ mBandsInUse

size_t EffectEqualization::mBandsInUse
private

Definition at line 220 of file Equalization.h.

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

◆ mCurve

wxChoice* EffectEqualization::mCurve
private

Definition at line 264 of file Equalization.h.

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

◆ mCurveName

wxString EffectEqualization::mCurveName
private

Definition at line 210 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 228 of file Equalization.h.

Referenced by EnvelopeUpdated(), and ValidateUI().

◆ mDisallowCustom

bool EffectEqualization::mDisallowCustom
private

Definition at line 224 of file Equalization.h.

Referenced by ValidateUI().

◆ mDraw

wxRadioButton* EffectEqualization::mDraw
private

Definition at line 259 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 208 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 260 of file Equalization.h.

Referenced by PopulateOrExchange(), and TransferDataToWindow().

◆ mGridOnOff

wxCheckBox* EffectEqualization::mGridOnOff
private

Definition at line 262 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 263 of file Equalization.h.

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

◆ mLeftSpacer

wxSizerItem* EffectEqualization::mLeftSpacer
private

Definition at line 255 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 261 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 265 of file Equalization.h.

◆ mMSlider

wxSlider* EffectEqualization::mMSlider
private

◆ mMText

wxStaticText* EffectEqualization::mMText
private

Definition at line 266 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 270 of file Equalization.h.

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

◆ mSlidersOld

int EffectEqualization::mSlidersOld[NUMBER_OF_BANDS]
private

Definition at line 229 of file Equalization.h.

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

◆ mWhens

double EffectEqualization::mWhens[NUM_PTS]
private

Definition at line 218 of file Equalization.h.

Referenced by ErrMin(), and GraphicEQ().

◆ mWhenSliders

double EffectEqualization::mWhenSliders[NUMBER_OF_BANDS+1]
private

Definition at line 219 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 98 of file Equalization.h.

Referenced by GetSymbol().

◆ szr1

wxSizer* EffectEqualization::szr1
private

Definition at line 249 of file Equalization.h.

Referenced by PopulateOrExchange(), and TransferDataToWindow().

◆ szr2

wxSizer* EffectEqualization::szr2
private

Definition at line 250 of file Equalization.h.

◆ szr3

wxSizer* EffectEqualization::szr3
private

Definition at line 251 of file Equalization.h.

◆ szr4

wxSizer* EffectEqualization::szr4
private

Definition at line 252 of file Equalization.h.

◆ szr5

wxSizer* EffectEqualization::szr5
private

Definition at line 253 of file Equalization.h.

◆ szrC

wxSizer* EffectEqualization::szrC
private

Definition at line 243 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 141 of file Equalization.h.

Referenced by ProcessOne().


The documentation for this class was generated from the following files:
FileNames::ResourcesDir
FILES_API FilePath ResourcesDir()
XMLWriter::EndTag
virtual void EndTag(const wxString &name)
Definition: XMLWriter.cpp:103
EqualizationPanel::ForceRecalc
void ForceRecalc()
Definition: Equalization.cpp:3102
ShuttleSetAutomation
Shuttle that sets parameters to a value (from a string)
Definition: ShuttleAutomation.h:38
TranslatableString
Holds a msgid for the translation catalog; may also bind format arguments.
Definition: TranslatableString.h:32
EffectEqualization::mLogEnvelope
std::unique_ptr< Envelope > mLogEnvelope
Definition: Equalization.h:234
CommandParameters
CommandParameters, derived from wxFileConfig, is essentially doing the same things as the Shuttle cla...
Definition: EffectAutomationParameters.h:67
label
TranslatableString label
Definition: TagsEditor.cpp:163
eIsCreating
@ eIsCreating
Definition: ShuttleGui.h:39
ID_Curve
@ ID_Curve
Definition: Equalization.cpp:135
Effect::mUIDialog
wxWeakRef< wxDialog > mUIDialog
This weak pointer may be the same as the above, or null.
Definition: Effect.h:437
kEqOptionGraphic
const int kEqOptionGraphic
Definition: Equalization.h:24
Effect::FindProject
const AudacityProject * FindProject() const
Definition: Effect.cpp:2035
WaveTrack
A Track that contains audio waveform data.
Definition: WaveTrack.h:75
CommandParameters::WriteEnum
bool WriteEnum(const wxString &key, int value, const EnumValueSymbol choices[], size_t nChoices)
Definition: EffectAutomationParameters.h:202
EffectTypeProcess
@ EffectTypeProcess
Definition: EffectInterface.h:56
wxSliderWrapper
wxSlider wxSliderWrapper
Definition: ShuttleGui.h:106
DB_TO_LINEAR
const double MIN_Threshold_Linear DB_TO_LINEAR(MIN_Threshold_dB)
EffectEqualization::mGraphic
wxRadioButton * mGraphic
Definition: Equalization.h:260
EQCURVES_REVISION
#define EQCURVES_REVISION
Definition: Equalization.cpp:159
RulerPanel
RulerPanel class allows you to work with a Ruler like any other wxWindow.
Definition: Ruler.h:228
S
#define S(N)
Definition: ToChars.cpp:64
Effect::CloseUI
bool CloseUI() override
Definition: Effect.cpp:624
Ruler::LinearDBFormat
@ LinearDBFormat
Definition: Ruler.h:34
fn
static const auto fn
Definition: WaveformView.cpp:1122
ID_Draw
@ ID_Draw
Definition: Equalization.cpp:130
EffectEqualization::mdBMin
float mdBMin
Definition: Equalization.h:213
flag
static std::once_flag flag
Definition: WaveformView.cpp:1133
gPrefs
FileConfig * gPrefs
Definition: Prefs.cpp:71
EffectEqualization::WriteXML
void WriteXML(XMLWriter &xmlFile) const
Definition: Equalization.cpp:2314
TranslatableStrings
std::vector< TranslatableString > TranslatableStrings
Definition: TranslatableString.h:295
Effect::MessageBox
int MessageBox(const TranslatableString &message, long style=DefaultMessageBoxStyle, const TranslatableString &titleStr={})
Definition: Effect.cpp:2238
Effect::CopyInputTracks
void CopyInputTracks(bool allSyncLockSelected=false)
Definition: Effect.cpp:1834
RegistryPaths
std::vector< RegistryPath > RegistryPaths
Definition: Identifier.h:219
EffectEqualization::mWindowSize
size_t mWindowSize
Definition: Equalization.h:227
EffectEqualization::mMText
wxStaticText * mMText
Definition: Equalization.h:266
EffectEqualization::GraphicEQ
void GraphicEQ(Envelope *env)
Definition: Equalization.cpp:2640
EffectEqualization::TransferDataFromWindow
bool TransferDataFromWindow() override
Definition: Equalization.cpp:1252
Envelope::Insert
void Insert(int point, const EnvPoint &p)
insert a point
Definition: Envelope.cpp:361
Ruler::SetLog
void SetLog(bool log)
Definition: Ruler.cpp:142
RealFFTf
void RealFFTf(fft_type *buffer, const FFTParam *h)
Definition: RealFFTf.cpp:162
EffectEqualization::hFFT
HFFT hFFT
Definition: Equalization.h:207
Envelope
Piecewise linear or piecewise exponential function from double to double.
Definition: Envelope.h:72
EffectEqualizationGraphic::Symbol
static const ComponentInterfaceSymbol Symbol
Definition: Equalization.h:294
ID_Clear
@ ID_Clear
Definition: Equalization.cpp:127
ID_Graphic
@ ID_Graphic
Definition: Equalization.cpp:131
kInterpStrings
static const EnumValueSymbol kInterpStrings[nInterpolations]
Definition: Equalization.cpp:162
Effect::mT1
double mT1
Definition: Effect.h:424
Effect::LoadUserPreset
bool LoadUserPreset(const RegistryPath &name) override
Change settings to a user-named preset.
Definition: Effect.cpp:530
EffectEqualization::mLoFreq
double mLoFreq
Definition: Equalization.h:225
ID_Linear
@ ID_Linear
Definition: Equalization.cpp:133
ID_Grid
@ ID_Grid
Definition: Equalization.cpp:134
Envelope::GetPoints
void GetPoints(double *bufferWhen, double *bufferValue, int bufferLen) const
Returns the sets of when and value pairs.
Definition: Envelope.cpp:694
Envelope::SetTrackLen
void SetTrackLen(double trackLen, double sampleDur=0.0)
Definition: Envelope.cpp:787
XO
#define XO(s)
Definition: Internat.h:31
EffectEqualization::mEQVals
double mEQVals[NUMBER_OF_BANDS+1]
Definition: Equalization.h:230
EffectEqualization::mdBMax
float mdBMax
Definition: Equalization.h:212
EffectEqualization::DefineParams
bool DefineParams(ShuttleParams &S) override
Definition: Equalization.cpp:374
Envelope::Reassign
int Reassign(double when, double value)
Move a point at when to value.
Definition: Envelope.cpp:669
Effect::IsBatchProcessing
virtual bool IsBatchProcessing()
Definition: Effect.cpp:960
kThirdOct
static const double kThirdOct[]
Definition: Equalization.cpp:172
EffectEqualization::mBandsInUse
size_t mBandsInUse
Definition: Equalization.h:220
EffectEqualization::EqualizationPanel
friend class EqualizationPanel
Definition: Equalization.h:279
EffectEqualization::UpdateGraphic
void UpdateGraphic(void)
Definition: Equalization.cpp:2437
EffectEqualization::mWhenSliders
double mWhenSliders[NUMBER_OF_BANDS+1]
Definition: Equalization.h:219
Effect::SaveUserPreset
bool SaveUserPreset(const RegistryPath &name) override
Save current settings as a user-named preset.
Definition: Effect.cpp:547
RealFFT
void RealFFT(size_t NumSamples, const float *RealIn, float *RealOut, float *ImagOut)
Definition: FFT.cpp:230
PluginSettings::SetConfig
bool SetConfig(EffectDefinitionInterface &ident, ConfigurationType type, const RegistryPath &group, const RegistryPath &key, const Value &value)
Definition: ConfigInterface.h:97
EffectEqualization::mdBMinSlider
wxSlider * mdBMinSlider
Definition: Equalization.h:268
WaveTrack::EmptyCopy
Holder EmptyCopy(const SampleBlockFactoryPtr &pFactory={}) const
Definition: WaveTrack.cpp:709
nInterpolations
@ nInterpolations
Definition: Equalization.cpp:154
EffectEqualization::mSlidersOld
int mSlidersOld[NUMBER_OF_BANDS]
Definition: Equalization.h:229
EffectEqualization::loFreqI
@ loFreqI
Definition: Equalization.h:145
EffectEqualization::SaveCurves
void SaveCurves(const wxString &fileName={})
Definition: Equalization.cpp:1845
EffectEqualization::szr1
wxSizer * szr1
Definition: Equalization.h:249
ID_Length
@ ID_Length
Definition: Equalization.cpp:124
EditCurvesDialog
Definition: Equalization.h:352
XMLFileReader::Parse
bool Parse(XMLTagHandler *baseHandler, const FilePath &fname)
Definition: XMLFileReader.cpp:42
ReorderToTime
void ReorderToTime(const FFTParam *hFFT, const fft_type *buffer, fft_type *TimeOut)
Definition: RealFFTf.cpp:361
EffectEqualization::mLin
bool mLin
Definition: Equalization.h:211
Ruler::GetMaxSize
void GetMaxSize(wxCoord *width, wxCoord *height)
Definition: Ruler.cpp:1603
EffectEqualization::mFilterFuncR
Floats mFilterFuncR
Definition: Equalization.h:208
FileNames::DataDir
FILES_API FilePath DataDir()
Audacity user data directory.
floatSample
@ floatSample
Definition: SampleFormat.h:34
RulerPanel::Range
std::pair< double, double > Range
Definition: Ruler.h:232
EffectEqualization::szrI
wxSizer * szrI
Definition: Equalization.h:247
ID_Manage
@ ID_Manage
Definition: Equalization.cpp:136
EQPoint
EQPoint is used with EQCurve and hence EffectEqualization.
Definition: Equalization.h:52
ReadAndVerifyEnum
#define ReadAndVerifyEnum(name, list, listSize)
Definition: Effect.h:580
EffectEqualization::Flatten
void Flatten()
Definition: Equalization.cpp:2168
EffectEqualization::mLinEnvelope
std::unique_ptr< Envelope > mLinEnvelope
Definition: Equalization.h:234
ReadAndVerifyInt
#define ReadAndVerifyInt(name)
Definition: Effect.h:591
EffectEqualization::mPanel
EqualizationPanel * mPanel
Definition: Equalization.h:257
kBspline
@ kBspline
Definition: Equalization.cpp:151
XXO
#define XXO(s)
Definition: Internat.h:44
WaveTrack::ConvertToSampleFormat
void ConvertToSampleFormat(sampleFormat format, const std::function< void(size_t)> &progressReport={})
Definition: WaveTrack.cpp:600
WaveTrack::Clear
void Clear(double t0, double t1) override
Definition: WaveTrack.cpp:790
EffectEqualization::spline
void spline(double x[], double y[], size_t n, double y2[])
Definition: Equalization.cpp:2778
XMLFileReader::GetErrorStr
const TranslatableString & GetErrorStr() const
Definition: XMLFileReader.cpp:183
Effect::mT0
double mT0
Definition: Effect.h:423
EQCURVES_VERSION
#define EQCURVES_VERSION
Definition: Equalization.cpp:158
name
const TranslatableString name
Definition: Equalization.cpp:475
ShuttleGetAutomation
Shuttle that gets parameter values into a string.
Definition: ShuttleAutomation.h:20
EffectEqualization::mMSlider
wxSlider * mMSlider
Definition: Equalization.h:267
EffectEqualization::Select
void Select(int sel)
Definition: Equalization.cpp:2074
InverseRealFFT
void InverseRealFFT(size_t NumSamples, const float *RealIn, const float *ImagIn, float *RealOut)
Definition: FFT.cpp:268
EffectEqualization::UpdateCurves
void UpdateCurves()
Definition: Equalization.cpp:2356
EffectEqualization::mM
size_t mM
Definition: Equalization.h:209
FactoryPresets
static const struct @1 FactoryPresets[]
EffectEqualization::mOptions
int mOptions
Definition: Equalization.h:206
SampleTrack::GetFloats
bool GetFloats(float *buffer, sampleCount start, size_t len, fillFormat fill=fillZero, bool mayThrow=true, sampleCount *pNumWithinClips=nullptr) const
Retrieve samples from a track in floating-point format, regardless of the storage format.
Definition: SampleTrack.h:64
EffectEqualization::setCurve
void setCurve(void)
Definition: Equalization.cpp:2048
Effect::LoadFactoryDefaults
bool LoadFactoryDefaults() override
Change settings back to "factory default".
Definition: Effect.cpp:582
EffectEqualization::mCurves
EQCurveArray mCurves
Definition: Equalization.h:232
WaveTrack::GetClips
WaveClipHolders & GetClips()
Definition: WaveTrack.h:322
EffectEqualization::OnLinFreq
void OnLinFreq(wxCommandEvent &event)
Definition: Equalization.cpp:3014
anonymous_namespace{TimeTrack.cpp}::GetRate
double GetRate()
Definition: TimeTrack.cpp:192
Effect::ReplaceProcessedTracks
void ReplaceProcessedTracks(const bool bGoodResult)
Definition: Effect.cpp:1956
WaveTrack::Paste
void Paste(double t0, const Track *src) override
Definition: WaveTrack.cpp:1568
EffectEqualization::szrG
wxSizer * szrG
Definition: Equalization.h:244
ID_dBMax
@ ID_dBMax
Definition: Equalization.cpp:125
kCubic
@ kCubic
Definition: Equalization.cpp:153
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:2800
anonymous_namespace{NoteTrack.cpp}::swap
void swap(std::unique_ptr< Alg_seq > &a, std::unique_ptr< Alg_seq > &b)
Definition: NoteTrack.cpp:753
EffectEqualization::mLinFreq
wxCheckBox * mLinFreq
Definition: Equalization.h:261
InverseRealFFTf
void InverseRealFFTf(fft_type *buffer, const FFTParam *h)
Definition: RealFFTf.cpp:264
EffectEqualization::mDirty
bool mDirty
Definition: Equalization.h:228
WaveTrack::GetMaxBlockSize
size_t GetMaxBlockSize() const override
This returns a nonnegative number of samples meant to size a memory buffer.
Definition: WaveTrack.cpp:1811
EffectEqualization::mInterp
int mInterp
Definition: Equalization.h:215
Effect::mOutputTracks
std::shared_ptr< TrackList > mOutputTracks
Definition: Effect.h:422
Msgids
TranslatableStrings Msgids(const EnumValueSymbol strings[], size_t nStrings)
Convenience function often useful when adding choice controls.
Definition: ShuttleGui.cpp:2523
NUMBER_OF_BANDS
#define NUMBER_OF_BANDS
Definition: Equalization.h:14
names
static TranslatableStrings names
Definition: TagsEditor.cpp:151
ID_Interp
@ ID_Interp
Definition: Equalization.cpp:132
RulerPanel::Options::LabelEdges
Options & LabelEdges(bool l)
Definition: Ruler.h:250
EffectEqualization::EnvLogToLin
void EnvLogToLin(void)
Definition: Equalization.cpp:2498
EffectEqualization::ProcessOne
bool ProcessOne(int count, WaveTrack *t, sampleCount start, sampleCount len)
Definition: Equalization.cpp:1311
Effect::GetCurrentSettingsGroup
RegistryPath GetCurrentSettingsGroup() override
Definition: Effect.cpp:820
EffectEqualization::IsLinear
bool IsLinear()
Definition: Equalization.cpp:2160
samplePtr
char * samplePtr
Definition: SampleFormat.h:49
min
int min(int a, int b)
Definition: CompareAudioCommand.cpp:106
EffectEqualization::mdBMaxSlider
wxSlider * mdBMaxSlider
Definition: Equalization.h:269
kEqOptionCurve
const int kEqOptionCurve
Definition: Equalization.h:25
EffectEqualization::szrH
wxSizer * szrH
Definition: Equalization.h:246
WaveTrack::Join
void Join(double t0, double t1)
Definition: WaveTrack.cpp:1713
FileConfig::Flush
virtual bool Flush(bool bCurrentOnly=false) wxOVERRIDE
Definition: FileConfig.cpp:143
EffectEqualization::EnvLinToLog
void EnvLinToLog(void)
Definition: Equalization.cpp:2522
TrackList::Get
static TrackList & Get(AudacityProject &project)
Definition: Track.cpp:377
EffectEqualization::mDisallowCustom
bool mDisallowCustom
Definition: Equalization.h:224
XMLFileReader
Reads a file and passes the results through an XMLTagHandler.
Definition: XMLFileReader.h:19
Effect::mUIParent
wxWindow * mUIParent
Definition: Effect.h:438
_
#define _(s)
Definition: Internat.h:75
EffectEqualization::Symbol
static const ComponentInterfaceSymbol Symbol
Definition: Equalization.h:98
EffectEqualization::mGridOnOff
wxCheckBox * mGridOnOff
Definition: Equalization.h:262
XMLFileWriter
Wrapper to output XML data to files.
Definition: XMLWriter.h:84
EffectEqualization::ForceRecalc
void ForceRecalc()
Definition: Equalization.cpp:2087
EffectEqualization::szrL
wxSizer * szrL
Definition: Equalization.h:248
EffectEqualization::GetDefaultFileName
bool GetDefaultFileName(wxFileName &fileName)
Definition: Equalization.cpp:1817
EffectEqualization::mCurveName
wxString mCurveName
Definition: Equalization.h:210
EffectEqualization::mDrawMode
bool mDrawMode
Definition: Equalization.h:214
XMLWriter::WriteAttr
void WriteAttr(const wxString &name, const Identifier &value)
Definition: XMLWriter.h:37
EffectEqualization::mWhens
double mWhens[NUM_PTS]
Definition: Equalization.h:218
EffectEqualization::EnvelopeUpdated
void EnvelopeUpdated()
Definition: Equalization.cpp:2098
RulerPanel::Options
Definition: Ruler.h:234
EffectEqualization::GetPrefsPrefix
wxString GetPrefsPrefix()
Definition: Equalization.cpp:596
EQCurveArray
std::vector< EQCurve > EQCurveArray
Definition: Equalization.h:88
EffectEqualization::TransferDataToWindow
bool TransferDataToWindow() override
Definition: Equalization.cpp:1196
EffectEqualization::Filter
void Filter(size_t len, float *buffer)
Definition: Equalization.cpp:1573
Verbatim
TranslatableString Verbatim(wxString str)
Require calls to the one-argument constructor to go through this distinct global function name.
Definition: TranslatableString.h:321
RulerPanel::ruler
Ruler ruler
Definition: Ruler.h:288
Envelope::Flatten
void Flatten(double value)
Definition: Envelope.cpp:132
EffectEqualization::mFreqRuler
RulerPanel * mFreqRuler
Definition: Equalization.h:222
M_PI
#define M_PI
Definition: Distortion.cpp:29
EffectEqualization::szrV
wxSizer * szrV
Definition: Equalization.h:245
EQCurve
EQCurve is used with EffectEqualization.
Definition: Equalization.h:74
Effect::GetDefinition
EffectDefinitionInterface & GetDefinition() override
Definition: Effect.cpp:759
EffectEqualization::mFFTBuffer
Floats mFFTBuffer
Definition: Equalization.h:208
EffectEqualization::UpdateDraw
void UpdateDraw()
Definition: Equalization.cpp:2384
EffectEqualization::mHiFreq
double mHiFreq
Definition: Equalization.h:226
EffectEqualization::mEnvelope
Envelope * mEnvelope
Definition: Equalization.h:235
EffectEqualization::CalcFilter
bool CalcFilter()
Definition: Equalization.cpp:1460
kCosine
@ kCosine
Definition: Equalization.cpp:152
EffectEqualization::mdBRuler
RulerPanel * mdBRuler
Definition: Equalization.h:221
params
EffectDistortion::Params params
Definition: Distortion.cpp:99
NUM_PTS
#define NUM_PTS
Definition: Equalization.h:15
TranslatableString::Translation
wxString Translation() const
Definition: TranslatableString.h:79
GuardedCall
R GuardedCall(const F1 &body, const F2 &handler=F2::Default(), F3 delayedHandler=DefaultDelayedHandlerAction) noexcept(noexcept(handler(std::declval< AudacityException * >())) &&noexcept(handler(nullptr)) &&noexcept(std::function< void(AudacityException *)>{std::move(delayedHandler)}))
Execute some code on any thread; catch any AudacityException; enqueue error report on the main thread...
Definition: AudacityException.h:207
EffectEqualization::mFilterFuncI
Floats mFilterFuncI
Definition: Equalization.h:208
UPDATE_ALL
#define UPDATE_ALL
Definition: Equalization.cpp:160
TranslatableString::Format
TranslatableString & Format(Args &&...args) &
Capture variadic format arguments (by copy) when there is no plural.
Definition: TranslatableString.h:103
EffectEqualization::mDrawGrid
bool mDrawGrid
Definition: Equalization.h:216
safenew
#define safenew
Definition: MemoryX.h:10
EffectEqualization::OnErase
void OnErase(wxEvent &event)
Definition: Equalization.cpp:2821
lrint
#define lrint(dbl)
Definition: float_cast.h:169
EffectEqualization::mInterpChoice
wxChoice * mInterpChoice
Definition: Equalization.h:263
EffectEqualizationCurve::Symbol
static const ComponentInterfaceSymbol Symbol
Definition: Equalization.h:286
limitSampleBufferSize
size_t limitSampleBufferSize(size_t bufferSize, sampleCount limit)
Definition: SampleCount.cpp:23
SampleTrack::LongSamplesToTime
double LongSamplesToTime(sampleCount pos) const
Convert correctly between a number of samples and an (absolute) time in seconds.
Definition: SampleTrack.cpp:40
TrackList::Selected
auto Selected() -> TrackIterRange< TrackType >
Definition: Track.h:1396
ID_Invert
@ ID_Invert
Definition: Equalization.cpp:128
Effect::TrackProgress
bool TrackProgress(int whichTrack, double frac, const TranslatableString &={})
Definition: Effect.cpp:1788
ArrayOf< float >
XMLWriter::StartTag
virtual void StartTag(const wxString &name)
Definition: XMLWriter.cpp:80
EffectEqualization::mSliders
wxSlider * mSliders[NUMBER_OF_BANDS]
Definition: Equalization.h:270
ID_dBMin
@ ID_dBMin
Definition: Equalization.cpp:126
ID_Slider
@ ID_Slider
Definition: Equalization.cpp:146
RulerPanel::Options::Log
Options & Log(bool l)
Definition: Ruler.h:244
ReadAndVerifyBool
#define ReadAndVerifyBool(name)
Definition: Effect.h:594
Envelope::GetNumberOfPoints
size_t GetNumberOfPoints() const
Return number of points.
Definition: Envelope.cpp:689
PluginSettings::Private
@ Private
Definition: PluginInterface.h:56
EffectEqualization::mDraw
wxRadioButton * mDraw
Definition: Equalization.h:259
EffectEqualization::UpdateDefaultCurves
void UpdateDefaultCurves(bool updateAll=false)
Definition: Equalization.cpp:1699
EffectEqualization::mCurve
wxChoice * mCurve
Definition: Equalization.h:264
EffectEqualization::ErrMin
void ErrMin(void)
Definition: Equalization.cpp:2564
EffectEqualization::windowSize
static const size_t windowSize
Definition: Equalization.h:141