18#if wxUSE_ACCESSIBILITY
24 20., 25., 31., 40., 50., 63., 80., 100., 125., 160., 200.,
25 250., 315., 400., 500., 630., 800., 1000., 1250., 1600., 2000.,
26 2500., 3150., 4000., 5000., 6300., 8000., 10000., 12500., 16000., 20000.,
31 : mCurvesList{ curvesList }
33 for (
size_t i = 0; i <
NUM_PTS - 1; ++i)
52 wxWindow *pParent =
S.GetParent();
66 S.AddFixedText( fNum );
68 wxDefaultPosition, wxSize(-1,50), wxSL_VERTICAL | wxSL_INVERSE);
70 #if wxUSE_ACCESSIBILITY
96 const auto &drawMode = parameters.
mDrawMode;
97 auto &linEnvelope = parameters.mLinEnvelope;
98 auto &logEnvelope = parameters.mLogEnvelope;
100 logEnvelope.Flatten(0.);
101 logEnvelope.SetTrackLen(1.0);
102 linEnvelope.Flatten(0.);
103 linEnvelope.SetTrackLen(1.0);
115 tip.Printf(
wxT(
"%dHz\n%.1fdB"), (
int)
kThirdOct[i], 0. );
117 tip.Printf(
wxT(
"%gkHz\n%.1fdB"),
kThirdOct[i]/1000., 0. );
128 auto &logEnvelope = parameters.mLogEnvelope;
129 const auto &hiFreq = parameters.mHiFreq;
140 linEnvelope.Flatten(0.);
141 linEnvelope.SetTrackLen(1.0);
142 logEnvelope.GetPoints( when.get(), value.get(), numPoints );
143 linEnvelope.Reassign(0., value[0]);
144 double loLog = log10(20.);
145 double hiLog = log10(hiFreq);
146 double denom = hiLog - loLog;
148 for (
size_t i = 0; i < numPoints; i++)
149 linEnvelope.Insert(pow( 10., ((when[i] * denom) + loLog))/hiFreq , value[i]);
150 linEnvelope.Reassign(1., value[numPoints-1]);
157 auto &logEnvelope = parameters.mLogEnvelope;
158 const auto &hiFreq = parameters.mHiFreq;
169 logEnvelope.Flatten(0.);
170 logEnvelope.SetTrackLen(1.0);
171 linEnvelope.GetPoints( when.get(), value.get(), numPoints );
172 logEnvelope.Reassign(0., value[0]);
173 double loLog = log10(20.);
174 double hiLog = log10(hiFreq );
175 double denom = hiLog - loLog;
176 bool changed =
false;
178 for (
size_t i = 0; i < numPoints; i++)
180 if( when[i]*hiFreq >= 20 )
184 double flog = (log10(when[i]*hiFreq )-loLog)/denom;
185 logEnvelope.Insert(std::max(0.0, flog) , value[i]);
191 logEnvelope.Insert(0., v);
194 logEnvelope.Reassign(1., value[numPoints - 1]);
205 const auto &loFreq = parameters.mLoFreq;
206 const auto &hiFreq = parameters.mHiFreq;
208 const double loLog = log10(loFreq);
209 const double hiLog = log10(hiFreq );
210 const double denom = hiLog - loLog;
220 std::clamp(logEnvelope.GetValue(
mWhenSliders[i]), -20., 20.);
225 double oldError = 0.0;
226 double mEQValsOld = 0.0;
227 double correction = 1.6;
230 Envelope testEnvelope{ logEnvelope };
232 for(
size_t i = 0; i <
NUM_PTS; i++)
238 for(
size_t i = 0; i <
NUM_PTS; i++)
240 double err = vals[i] - testEnvelope.GetValue(
mWhens[i]);
247 if( (j > 0) & (i == 0) )
250 correction = -correction;
252 correction = -correction/2.;
272 for(
size_t k = 0; k <
NUM_PTS; k++)
274 double err = vals[k] - testEnvelope.GetValue(
mWhens[k]);
278 while( (error < oldError) &&
flag );
279 if( error > oldError )
313 const auto &interp = parameters.
mInterp;
318 double dist, span, s;
328 for(
size_t i = 0; i <
NUM_PTS; i++)
341 value =
mEQVals[0]*(s + 1.5)*(s + 1.5)/2.;
367 value =
mEQVals[minF]*(0.75 - s*s);
369 value +=
mEQVals[minF+1]*(s+.5)*(s+.5)/2.;
371 value +=
mEQVals[minF-1]*(s-.5)*(s-.5)/2.;
375 value =
mEQVals[minF]*(s-1.5)*(s-1.5)/2.;
377 value +=
mEQVals[minF+1]*(.75-(1.-s)*(1.-s));
379 value +=
mEQVals[minF+2]*(s-.5)*(s-.5)/2.;
394 for(
size_t i = 0; i <
NUM_PTS; i++)
423 value =
mEQVals[minF]*(1. + cos(
M_PI*(span-dist)/span))/2. +
440 for(
double xf=0; xf<1.; xf+=1./
NUM_PTS)
452 double x[],
double y[],
size_t n,
double y2[])
461 for (
size_t i = 1; i + 1 < n; i++)
463 sig = ( x[i] - x[i-1] ) / ( x[i+1] - x[i-1] );
464 p = sig * y2[i-1] + 2.;
465 y2[i] = (sig - 1.)/p;
466 u[i] = ( y[i+1] - y[i] ) / ( x[i+1] - x[i] ) - ( y[i] - y[i-1] ) / ( x[i] - x[i-1] );
467 u[i] = (6.*u[i]/( x[i+1] - x[i-1] ) - sig * u[i-1]) / p;
470 for (
size_t i = n - 1; i--;)
471 y2[i] = y2[i]*y2[i+1] + u[i];
475 double x[],
double y[],
size_t n,
double y2[],
double xr)
480 static double xlast = 0.;
486 while( (x[k] <= xr) && (k + 1 < n) )
491 a = ( x[k+1] - xr )/h;
493 return( a*y[k]+b*y[k+1]+((a*a*a-a)*y2[k]+(b*b*b-b)*y2[k+1])*h*h/6.);
505 wxSlider *s = (wxSlider *)event.GetEventObject();
511 if( wxGetKeyState(WXK_SHIFT) )
545 auto &logEnvelope = parameters.mLogEnvelope;
547 if (!parameters.mDrawMode)
567 bool lin = parameters.IsLinear();
574 numPoints = linEnvelope.GetNumberOfPoints();
578 numPoints = logEnvelope.GetNumberOfPoints();
588 linEnvelope.GetPoints( when.get(), value.get(), numPoints );
590 logEnvelope.GetPoints( when.get(), value.get(), numPoints );
593 for (
size_t i = 0; i < numPoints; i++)
596 linEnvelope.Reassign(when[i] , -value[i]);
598 logEnvelope.Reassign(when[i] , -value[i]);
static const double kThirdOct[]
TranslatableString Verbatim(wxString str)
Require calls to the one-argument constructor to go through this distinct global function name.
Piecewise linear or piecewise exponential function from double to double.
void Insert(int point, const EnvPoint &p) noexcept
insert a point
double GetValue(double t, double sampleDur=0) const
Get envelope value at time t.
void SetTrackLen(double trackLen, double sampleDur=0.0)
size_t GetNumberOfPoints() const
Return number of points.
int Reassign(double when, double value)
Move a point at when to value.
void Flatten(double value)
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI.
Holds a msgid for the translation catalog; may also bind format arguments.
TranslatableString & Format(Args &&...args) &
Capture variadic format arguments (by copy) when there is no plural.
static void spline(double x[], double y[], size_t n, double y2[])
void BindTo(wxEvtHandler &src, const EventTag &eventType, void(Class::*pmf)(Event &))
static double splint(double x[], double y[], size_t n, double y2[], double xr)
void OnErase(wxEvent &event)
double mWhenSliders[NUMBER_OF_BANDS+1]
int mSlidersOld[NUMBER_OF_BANDS]
EqualizationCurvesList & mCurvesList
void AddBandSliders(ShuttleGui &S)
void GraphicEQ(Envelope &env)
EqualizationBandSliders(EqualizationCurvesList &curvesList)
double mEQVals[NUMBER_OF_BANDS+1]
wxSlider * mSliders[NUMBER_OF_BANDS]
void OnSlider(wxCommandEvent &event)
Maintains a list of preset curves for Equalization effects.
EqualizationFilter & mParameters