Audacity 3.2.0
Namespaces | Macros | Enumerations | Functions | Variables
Equalization.cpp File Reference

Implements EffectEqualiztaion, EqualizationDialog, EqualizationPanel, EQCurve and EQPoint. More...

#include "Equalization.h"
#include "LoadEffects.h"
#include <math.h>
#include <vector>
#include <wx/setup.h>
#include <wx/bitmap.h>
#include <wx/button.h>
#include <wx/brush.h>
#include <wx/dcclient.h>
#include <wx/dcmemory.h>
#include <wx/event.h>
#include <wx/listctrl.h>
#include <wx/log.h>
#include <wx/image.h>
#include <wx/intl.h>
#include <wx/choice.h>
#include <wx/radiobut.h>
#include <wx/slider.h>
#include <wx/stattext.h>
#include <wx/string.h>
#include <wx/textdlg.h>
#include <wx/ffile.h>
#include <wx/filefn.h>
#include <wx/stdpaths.h>
#include <wx/settings.h>
#include <wx/sizer.h>
#include <wx/checkbox.h>
#include <wx/tooltip.h>
#include <wx/utils.h>
#include "AColor.h"
#include "ConfigInterface.h"
#include "../ShuttleAutomation.h"
#include "../ShuttleGui.h"
#include "PlatformCompatibility.h"
#include "FileNames.h"
#include "Envelope.h"
#include "../EnvelopeEditor.h"
#include "FFT.h"
#include "Prefs.h"
#include "Project.h"
#include "Theme.h"
#include "../TrackArtist.h"
#include "../WaveClip.h"
#include "ViewInfo.h"
#include "../WaveTrack.h"
#include "../widgets/Ruler.h"
#include "../widgets/AudacityTextEntryDialog.h"
#include "XMLFileReader.h"
#include "AllThemeResources.h"
#include "float_cast.h"
#include "../widgets/FileDialog/FileDialog.h"
#include "../TrackPanelDrawingContext.h"

Go to the source code of this file.

Namespaces

namespace  anonymous_namespace{Equalization.cpp}
 

Macros

#define EQCURVES_VERSION   1
 
#define EQCURVES_REVISION   0
 
#define UPDATE_ALL   0
 

Enumerations

enum  {
  ID_Length = 10000 , ID_dBMax , ID_dBMin , ID_Clear ,
  ID_Invert , ID_Mode , ID_Draw , ID_Graphic ,
  ID_Interp , ID_Linear , ID_Grid , ID_Curve ,
  ID_Manage , ID_Delete , ID_Slider
}
 

Functions

 EVT_COMMAND_RANGE (ID_Slider, ID_Slider+NUMBER_OF_BANDS - 1, wxEVT_COMMAND_SLIDER_UPDATED, EffectEqualization::OnSlider) EffectEqualization
 
 EVT_LIST_ITEM_SELECTED (CurvesListID, EditCurvesDialog::OnListSelectionChange) EVT_LIST_ITEM_DESELECTED(CurvesListID
 Constructor. More...
 
static const FileNames::FileTypesXMLtypes ()
 

Variables

static const double kThirdOct []
 
BuiltinEffectsModule::Registration< EffectEqualizationCurveanonymous_namespace{Equalization.cpp}::reg2
 
BuiltinEffectsModule::Registration< EffectEqualizationGraphicanonymous_namespace{Equalization.cpp}::reg3
 
const bool kCURVE = false
 
const bool kBOTH = true
 
struct {
   const bool   bForBoth
 
   const TranslatableString   name
 
   const wxChar *   values
 
FactoryPresets []
 

Detailed Description

Implements EffectEqualiztaion, EqualizationDialog, EqualizationPanel, EQCurve and EQPoint.

Definition in file Equalization.cpp.

Macro Definition Documentation

◆ EQCURVES_REVISION

#define EQCURVES_REVISION   0

Definition at line 152 of file Equalization.cpp.

◆ EQCURVES_VERSION

#define EQCURVES_VERSION   1

Definition at line 151 of file Equalization.cpp.

◆ UPDATE_ALL

#define UPDATE_ALL   0

Definition at line 153 of file Equalization.cpp.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
ID_Length 
ID_dBMax 
ID_dBMin 
ID_Clear 
ID_Invert 
ID_Mode 
ID_Draw 
ID_Graphic 
ID_Interp 
ID_Linear 
ID_Grid 
ID_Curve 
ID_Manage 
ID_Delete 
ID_Slider 

Definition at line 123 of file Equalization.cpp.

124{
125 ID_Length = 10000,
126 ID_dBMax,
127 ID_dBMin,
128 ID_Clear,
129 ID_Invert,
130 ID_Mode,
131 ID_Draw,
133 ID_Interp,
134 ID_Linear,
135 ID_Grid,
136 ID_Curve,
137 ID_Manage,
138 ID_Delete,
139#ifdef EXPERIMENTAL_EQ_SSE_THREADED
140 ID_DefaultMath,
141 ID_SSE,
142 ID_SSEThreaded,
143 ID_AVX,
144 ID_AVXThreaded,
145 ID_Bench,
146#endif
147 ID_Slider, // needs to come last
148};
@ ID_Curve
@ ID_Delete
@ ID_Graphic
@ ID_Mode
@ ID_dBMax
@ ID_Invert
@ ID_Interp
@ ID_Grid
@ ID_Length
@ ID_Linear
@ ID_Slider
@ ID_Manage
@ ID_Clear
@ ID_Draw
@ ID_dBMin

Function Documentation

◆ EVT_COMMAND_RANGE()

EVT_COMMAND_RANGE ( ID_Slider  ,
ID_Slider+NUMBER_OF_BANDS 1,
wxEVT_COMMAND_SLIDER_UPDATED  ,
EffectEqualization::OnSlider   
)

Definition at line 223 of file Equalization.cpp.

250 : mFFTBuffer{ windowSize }
251 , mFilterFuncR{ windowSize }
252 , mFilterFuncI{ windowSize }
253{
254 Parameters().Reset(*this);
255
256 mOptions = Options;
257 mGraphic = NULL;
258 mDraw = NULL;
259 mCurve = NULL;
260 mPanel = NULL;
261 mMSlider = NULL;
262
263 hFFT = GetFFT(windowSize);
264
265 SetLinearEffectFlag(true);
266
267 mCurveName = CurveName.def;
268
269 GetConfig(GetDefinition(), PluginSettings::Private,
270 CurrentSettingsGroup(), wxT("dBMin"), mdBMin, dBMin.def);
271 GetConfig(GetDefinition(), PluginSettings::Private,
272 CurrentSettingsGroup(), wxT("dBMax"), mdBMax, dBMax.def);
273 GetConfig(GetDefinition(), PluginSettings::Private,
274 CurrentSettingsGroup(), wxT("DrawMode"), mDrawMode, DrawMode.def);
275 GetConfig(GetDefinition(), PluginSettings::Private,
276 CurrentSettingsGroup(), wxT("DrawGrid"), mDrawGrid, DrawGrid.def);
277
278 mLogEnvelope = std::make_unique<Envelope>
279 (false,
280 dBMin.min, dBMax.max, // MB: this is the highest possible range
281 0.0);
282 mLogEnvelope->SetTrackLen(1.0);
283
284 mLinEnvelope = std::make_unique<Envelope>
285 (false,
286 dBMin.min, dBMax.max, // MB: this is the highest possible range
287 0.0);
288 mLinEnvelope->SetTrackLen(1.0);
289
290 mEnvelope = (mLin ? mLinEnvelope : mLogEnvelope).get();
291
292 mWindowSize = windowSize;
293
294 mDirty = false;
295 mDisallowCustom = false;
296
297 // Load the EQ curves
298 LoadCurves();
299
300 // Note: initial curve is set in TransferDataToWindow
301
302 mBandsInUse = NUMBER_OF_BANDS;
303 //double loLog = log10(mLoFreq);
304 //double stepLog = (log10(mHiFreq) - loLog)/((double)NUM_PTS-1.);
305 for(int i=0; i<NUM_PTS-1; i++)
306 mWhens[i] = (double)i/(NUM_PTS-1.);
307 mWhens[NUM_PTS-1] = 1.;
308 mWhenSliders[NUMBER_OF_BANDS] = 1.;
309 mEQVals[NUMBER_OF_BANDS] = 0.;
310
311#ifdef EXPERIMENTAL_EQ_SSE_THREADED
312 bool useSSE;
313 GetPrivateConfig(CurrentSettingsGroup(), wxT("/SSE/GUI"), useSSE, false);
314 if(useSSE && !mEffectEqualization48x)
315 mEffectEqualization48x = std::make_unique<EffectEqualization48x>();
316 else if(!useSSE)
317 mEffectEqualization48x.reset();
318 mBench=false;
319#endif
320
321 // We expect these Hi and Lo frequencies to be overridden by Init().
322 // Don't use inputTracks(). See bug 2321.
323#if 0
324 auto trackList = inputTracks();
325 const auto t = trackList
326 ? *trackList->Any< const WaveTrack >().first
327 : nullptr
328 ;
329 mHiFreq =
330 (t
331 ? t->GetRate()
332 : mProjectRate)
333 / 2.0;
334#endif
335 mHiFreq = mProjectRate / 2.0;
336 mLoFreq = loFreqI;
337}
wxT("CloseDown"))
const RegistryPath & CurrentSettingsGroup()
Component of a configuration key path, for last-used destructive settings.
#define NUM_PTS
Definition: Equalization.h:15
#define NUMBER_OF_BANDS
Definition: Equalization.h:14
HFFT GetFFT(size_t fftlen)
Definition: RealFFTf.cpp:105
A Track that contains audio waveform data.
Definition: WaveTrack.h:57
bool GetConfig(const EffectDefinitionInterface &ident, ConfigurationType type, const RegistryPath &group, const RegistryPath &key, Value &var, const Value &defval)
std::vector< CommandFlagOptions > & Options()
Definition: Menus.cpp:535

◆ EVT_LIST_ITEM_SELECTED()

EVT_LIST_ITEM_SELECTED ( CurvesListID  ,
EditCurvesDialog::OnListSelectionChange   
)

Constructor.

◆ XMLtypes()

static const FileNames::FileTypes & XMLtypes ( )
static

Definition at line 3626 of file Equalization.cpp.

3627{
3628 static const FileNames::FileTypes results{
3630 };
3631 return results;
3632}
FILES_API const FileType XMLFiles
Definition: FileNames.h:74
std::vector< FileType > FileTypes
Definition: FileNames.h:76

References FileNames::XMLFiles.

Referenced by EditCurvesDialog::OnExport(), and EditCurvesDialog::OnImport().

Here is the caller graph for this function:

Variable Documentation

◆ bForBoth

const bool bForBoth

Definition at line 452 of file Equalization.cpp.

◆ 

const struct { ... } FactoryPresets[]
Initial value:
=
{
{ kCURVE, XO("100Hz Rumble"), wxT("f0=\"20.0\" v0=\"-80.0\" f1=\"49.237316986327\" v1=\"-33.107692718506\" f2=\"54.196034330446\" v2=\"-29.553844451904\" f3=\"88.033573501041\" v3=\"-6.923076629639\" f4=\"95.871851182279\" v4=\"-4.523078918457\" f5=\"108.957037410504\" v5=\"-1.938461303711\" f6=\"123.828171198057\" v6=\"-0.73846244812\" f7=\"149.228077614658\" v7=\"-0.092308044434\"") },
{ kCURVE, XO("AM Radio"), wxT("f0=\"20.0\" v0=\"-63.67\" f1=\"31.0\" v1=\"-33.219\" f2=\"50.0\" v2=\"-3.01\" f3=\"63.0\" v3=\"-0.106\" f4=\"100.0\" v4=\"0.0\" f5=\"2500.0\" v5=\"0.0\" f6=\"4000.0\" v6=\"-0.614\" f7=\"5000.0\" v7=\"-8.059\" f8=\"8000.0\" v8=\"-39.981\" f9=\"20000.0\" v9=\"-103.651\" f10=\"48000.0\" v10=\"-164.485\"") },
{ kBOTH, XO("Bass Boost"), wxT("f0=\"100.0\" v0=\"9.0\" f1=\"500.0\" v1=\"0.0\"") },
{ kBOTH, XO("Bass Cut"), wxT("f0=\"150.0\" v0=\"-50.0\" f1=\"300.0\" v1=\"0.0\"") },
{ kCURVE, XO("Low rolloff for speech"), wxT("f0=\"50.0\" v0=\"-120.0\" f1=\"60.0\" v1=\"-50.0\" f2=\"65.0\" v2=\"-24.0\" f3=\"70.0\" v3=\"-12.0\" f4=\"80.0\" v4=\"-4.0\" f5=\"90.0\" v5=\"-1.0\" f6=\"100.0\" v6=\"0.0\"") },
{ kBOTH, XO("RIAA"), wxT("f0=\"20.0\" v0=\"19.274\" f1=\"25.0\" v1=\"18.954\" f2=\"31.0\" v2=\"18.516\" f3=\"40.0\" v3=\"17.792\" f4=\"50.0\" v4=\"16.946\" f5=\"63.0\" v5=\"15.852\" f6=\"80.0\" v6=\"14.506\" f7=\"100.0\" v7=\"13.088\" f8=\"125.0\" v8=\"11.563\" f9=\"160.0\" v9=\"9.809\" f10=\"200.0\" v10=\"8.219\" f11=\"250.0\" v11=\"6.677\" f12=\"315.0\" v12=\"5.179\" f13=\"400.0\" v13=\"3.784\" f14=\"500.0\" v14=\"2.648\" f15=\"630.0\" v15=\"1.642\" f16=\"800.0\" v16=\"0.751\" f17=\"1000.0\" v17=\"0.0\" f18=\"1250.0\" v18=\"-0.744\" f19=\"1600.0\" v19=\"-1.643\" f20=\"2000.0\" v20=\"-2.589\" f21=\"2500.0\" v21=\"-3.7\" f22=\"3150.0\" v22=\"-5.038\" f23=\"4000.0\" v23=\"-6.605\" f24=\"5000.0\" v24=\"-8.21\" f25=\"6300.0\" v25=\"-9.98\" f26=\"8000.0\" v26=\"-11.894\" f27=\"10000.0\" v27=\"-13.734\" f28=\"12500.0\" v28=\"-15.609\" f29=\"16000.0\" v29=\"-17.708\" f30=\"20000.0\" v30=\"-19.62\" f31=\"25000.0\" v31=\"-21.542\" f32=\"48000.0\" v32=\"-27.187\"") },
{ kCURVE, XO("Telephone"), wxT("f0=\"20.0\" v0=\"-94.087\" f1=\"200.0\" v1=\"-14.254\" f2=\"250.0\" v2=\"-7.243\" f3=\"315.0\" v3=\"-2.245\" f4=\"400.0\" v4=\"-0.414\" f5=\"500.0\" v5=\"0.0\" f6=\"2500.0\" v6=\"0.0\" f7=\"3150.0\" v7=\"-0.874\" f8=\"4000.0\" v8=\"-3.992\" f9=\"5000.0\" v9=\"-9.993\" f10=\"48000.0\" v10=\"-88.117\"") },
{ kBOTH, XO("Treble Boost"), wxT("f0=\"4000.0\" v0=\"0.0\" f1=\"5000.0\" v1=\"9.0\"") },
{ kBOTH, XO("Treble Cut"), wxT("f0=\"6000.0\" v0=\"0.0\" f1=\"10000.0\" v1=\"-110.0\"") },
{ kCURVE, XO("Walkie-talkie"), wxT("f0=\"100.0\" v0=\"-120.0\" f1=\"101.0\" v1=\"0.0\" f2=\"2000.0\" v2=\"0.0\" f3=\"2001.0\" v3=\"-120.0\"") },
}
const bool kBOTH
const bool kCURVE
#define XO(s)
Definition: Internat.h:31

Referenced by EffectEqualization::GetFactoryPresets(), and EffectEqualization::LoadFactoryPreset().

◆ kBOTH

const bool kBOTH = true

Definition at line 448 of file Equalization.cpp.

◆ kCURVE

const bool kCURVE = false

Definition at line 447 of file Equalization.cpp.

◆ kThirdOct

const double kThirdOct[]
static
Initial value:
=
{
20., 25., 31., 40., 50., 63., 80., 100., 125., 160., 200.,
250., 315., 400., 500., 630., 800., 1000., 1250., 1600., 2000.,
2500., 3150., 4000., 5000., 6300., 8000., 10000., 12500., 16000., 20000.,
}

Definition at line 165 of file Equalization.cpp.

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

◆ name

const TranslatableString name

◆ values

const wxChar* values