Audacity 3.2.0
ScienFilter.cpp
Go to the documentation of this file.
1/**********************************************************************
2
3 Audacity: A Digital Audio Editor
4
5 Effect/ScienFilter.cpp
6
7 Norm C
8 Mitch Golden
9 Vaughan Johnson (Preview)
10
11*******************************************************************//****************************************************************//****************************************************************//*******************************************************************/
34#include "ScienFilter.h"
35#include "EffectEditor.h"
36#include "LoadEffects.h"
37
38#include <math.h>
39
40#include <wx/setup.h> // for wxUSE_* macros
41
42#include <wx/brush.h>
43#include <wx/choice.h>
44#include <wx/dcclient.h>
45#include <wx/dcmemory.h>
46#include <wx/settings.h>
47#include <wx/slider.h>
48#include <wx/stattext.h>
49#include <wx/utils.h>
50#include <wx/valgen.h>
51
52#include "AColor.h"
53#include "AllThemeResources.h"
55#include "Prefs.h"
56#include "Project.h"
57#include "ShuttleGui.h"
58#include "Theme.h"
59#include "WaveTrack.h"
60#include "../widgets/valnum.h"
61#include "AudacityMessageBox.h"
62#include "../widgets/RulerPanel.h"
63#include "../widgets/IntFormat.h"
64#include "../widgets/LinearDBFormat.h"
65#include "WindowAccessible.h"
66
67#if !defined(M_PI)
68#define PI = 3.1415926535897932384626433832795
69#else
70#define PI M_PI
71#endif
72#define square(a) ((a)*(a))
73
74enum
75{
85};
86
88{
89 /*i18n-hint: Butterworth is the name of the person after whom the filter type is named.*/
90 { XO("Butterworth") },
91 /*i18n-hint: Chebyshev is the name of the person after whom the filter type is named.*/
92 { XO("Chebyshev Type I") },
93 /*i18n-hint: Chebyshev is the name of the person after whom the filter type is named.*/
94 { XO("Chebyshev Type II") }
95};
96
98{
99 // These are acceptable dual purpose internal/visible names
100 { XO("Lowpass") },
101 { XO("Highpass") }
102};
103
105{
108 > parameters{
110 bool updating){
111 if (updating) {
112 e.mOrderIndex = e.mOrder - 1;
113 e.CalcFilter();
114 }
115 return true;
116 },
117 };
118 return parameters;
119}
120
121//----------------------------------------------------------------------------
122// EffectScienFilter
123//----------------------------------------------------------------------------
124
126{ XO("Classic Filters") };
127
128// true argument means don't automatically enable this effect
130
131BEGIN_EVENT_TABLE(EffectScienFilter, wxEvtHandler)
133
143
145{
146 Parameters().Reset(*this);
147 SetLinearEffectFlag(true);
148
149 mOrderIndex = mOrder - 1;
150
151 mdBMin = -30.0;
152 mdBMax = 30.0;
153
154 mLoFreq = 20; // Lowest frequency to display in response graph
155 mNyquist = 44100.0 / 2.0; // only used during initialization, updated when effect is used
156}
157
159{
160}
161
162// ComponentInterface implementation
163
165{
166 return Symbol;
167}
168
170{
171 /* i18n-hint: "infinite impulse response" */
172 return XO("Performs IIR filtering that emulates analog filters");
173}
174
176{
177 return L"Classic_Filters";
178}
179
180
181// EffectDefinitionInterface implementation
182
184{
185 return EffectTypeProcess;
186}
187
189{
190 return 1;
191}
192
194{
195 return 1;
196}
197
199 EffectSettings &, double, ChannelNames chanMap)
200{
201 for (int iPair = 0; iPair < (mOrder + 1) / 2; iPair++)
202 mpBiquad[iPair].Reset();
203 return true;
204}
205
207 const float *const *inBlock, float *const *outBlock, size_t blockLen)
208{
209 const float *ibuf = inBlock[0];
210 for (int iPair = 0; iPair < (mOrder + 1) / 2; iPair++)
211 {
212 mpBiquad[iPair].Process(ibuf, outBlock[0], blockLen);
213 ibuf = outBlock[0];
214 }
215
216 return blockLen;
217}
218
219// Effect implementation
220
222{
223 int selcount = 0;
224 double rate = 0.0;
225
226 auto trackRange = inputTracks()->Selected<const WaveTrack>();
227
228 {
229 auto t = *trackRange.begin();
230 mNyquist =
231 (t
232 ? t->GetRate()
233 : mProjectRate)
234 / 2.0;
235 }
236
237 for (auto t : trackRange) {
238 if (selcount == 0)
239 rate = t->GetRate();
240 else {
241 if (t->GetRate() != rate) {
243 XO(
244"To apply a filter, all selected tracks must have the same sample rate.") );
245 return false;
246 }
247 }
248 ++selcount;
249 }
250
251 return true;
252}
253
254std::unique_ptr<EffectEditor> EffectScienFilter::PopulateOrExchange(
256 const EffectOutputs *)
257{
258 mUIParent = S.GetParent();
259 S.AddSpace(5);
260 S.SetSizerProportion(1);
261 S.StartMultiColumn(3, wxEXPAND);
262 {
263 S.SetStretchyCol(1);
264 S.SetStretchyRow(0);
265
266 // -------------------------------------------------------------------
267 // ROW 1: Freq response panel and sliders for vertical scale
268 // -------------------------------------------------------------------
269
270 S.StartVerticalLay();
271 {
273 S.GetParent(), wxID_ANY, wxVERTICAL,
274 wxSize{ 100, 100 }, // Ruler can't handle small sizes
275 RulerPanel::Range{ 30.0, -120.0 },
277 XO("dB"),
279 .LabelEdges(true)
280 );
281
282 S.SetBorder(1);
283 S.AddSpace(1, 1);
284 S.Prop(1)
285 .Position(wxALIGN_RIGHT | wxTOP)
286 .AddWindow(mdBRuler);
287 S.AddSpace(1, 1);
288 }
289 S.EndVerticalLay();
290
292 S.GetParent(), wxID_ANY,
293 this, mLoFreq, mNyquist
294 );
295
296 S.SetBorder(5);
297 S.Prop(1)
298 .Position(wxEXPAND | wxRIGHT)
299 .MinSize( { -1, -1 } )
300 .AddWindow(mPanel);
301
302 S.StartVerticalLay();
303 {
304 S.AddVariableText(XO("+ dB"), false, wxCENTER);
306 .Name(XO("Max dB"))
307 .Style(wxSL_VERTICAL | wxSL_INVERSE)
308 .AddSlider( {}, 10, 20, 0);
309#if wxUSE_ACCESSIBILITY
310 mdBMaxSlider->SetAccessible(safenew SliderAx(mdBMaxSlider, XO("%d dB")));
311#endif
313 .Name(XO("Min dB"))
314 .Style(wxSL_VERTICAL | wxSL_INVERSE)
315 .AddSlider( {}, -10, -10, -120);
316#if wxUSE_ACCESSIBILITY
317 mdBMinSlider->SetAccessible(safenew SliderAx(mdBMinSlider, XO("%d dB")));
318#endif
319
320 S.AddVariableText(XO("- dB"), false, wxCENTER);
321 }
322 S.EndVerticalLay();
323
324 // -------------------------------------------------------------------
325 // ROW 2: Frequency ruler
326 // -------------------------------------------------------------------
327
328 S.AddSpace(1, 1);
329
331 S.GetParent(), wxID_ANY, wxHORIZONTAL,
332 wxSize{ 100, 100 }, // Ruler can't handle small sizes
333 RulerPanel::Range{ mLoFreq, mNyquist },
335 {},
337 .Log(true)
338 .Flip(true)
339 .LabelEdges(true)
340 );
341
342 S.Prop(1)
343 .Position(wxEXPAND | wxALIGN_LEFT | wxRIGHT)
344 .AddWindow(mfreqRuler);
345
346 S.AddSpace(1, 1);
347
348 // -------------------------------------------------------------------
349 // ROW 3 and 4: Type, Order, Ripple, Subtype, Cutoff
350 // -------------------------------------------------------------------
351
352 S.AddSpace(1, 1);
353 S.SetSizerProportion(0);
354 S.StartMultiColumn(8, wxALIGN_CENTER);
355 {
356 wxASSERT(nTypes == WXSIZEOF(kTypeStrings));
357
359 .Focus()
360 .Validator<wxGenericValidator>(&mFilterType)
361 .MinSize( { -1, -1 } )
362 .AddChoice(XXO("&Filter Type:"),
364 );
365
367 .Validator<wxGenericValidator>(&mOrderIndex)
368 .MinSize( { -1, -1 } )
369 /*i18n-hint: 'Order' means the complexity of the filter, and is a number between 1 and 10.*/
370 .AddChoice(XXO("O&rder:"),
371 []{
372 TranslatableStrings orders;
373 for (int i = 1; i <= 10; i++)
374 orders.emplace_back( Verbatim("%d").Format( i ) );
375 return orders;
376 }()
377 );
378 S.AddSpace(1, 1);
379
380 mRippleCtlP = S.AddVariableText( XO("&Passband Ripple:"),
381 false, wxALL | wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
383 .Name(XO("Passband Ripple (dB)"))
384 .Validator<FloatingPointValidator<float>>(
385 1, &mRipple, NumValidatorStyle::DEFAULT,
387 .AddTextBox( {}, L"", 10);
388 mRippleCtlU = S.AddVariableText(XO("dB"),
389 false, wxALL | wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL);
390
392 .Validator<wxGenericValidator>(&mFilterSubtype)
393 .MinSize( { -1, -1 } )
394 .AddChoice(XXO("&Subtype:"),
396 );
397
399 .Name(XO("Cutoff (Hz)"))
400 .Validator<FloatingPointValidator<float>>(
401 1, &mCutoff, NumValidatorStyle::DEFAULT,
402 Cutoff.min, mNyquist - 1)
403 .AddTextBox(XXO("C&utoff:"), L"", 10);
404 S.AddUnits(XO("Hz"));
405
407 S.AddVariableText(XO("Minimum S&topband Attenuation:"),
408 false, wxALL | wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
410 .Name(XO("Minimum S&topband Attenuation (dB)"))
411 .Validator<FloatingPointValidator<float>>(
412 1, &mStopbandRipple, NumValidatorStyle::DEFAULT,
414 .AddTextBox( {}, L"", 10);
416 S.AddVariableText(XO("dB"),
417 false, wxALL | wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL);
418 }
419 S.EndMultiColumn();
420 S.AddSpace(1, 1);
421 }
422 S.EndMultiColumn();
423
424 return nullptr;
425}
426
427//
428// Populate the window with relevant variables
429//
431{
432 mOrderIndex = mOrder - 1;
433
434 if (!mUIParent->TransferDataToWindow())
435 {
436 return false;
437 }
438
439 mdBMinSlider->SetValue((int) mdBMin);
440 mdBMin = 0.0; // force refresh in TransferGraphLimitsFromWindow()
441
442 mdBMaxSlider->SetValue((int) mdBMax);
443 mdBMax = 0.0; // force refresh in TransferGraphLimitsFromWindow()
444
446
448}
449
451{
452 if (!mUIParent->Validate() || !mUIParent->TransferDataFromWindow())
453 {
454 return false;
455 }
456
457 mOrder = mOrderIndex + 1;
458
459 CalcFilter();
460
461 return true;
462}
463
464// EffectScienFilter implementation
465
466//
467// Retrieve data from the window
468//
470{
471 // Read the sliders and send to the panel
472 wxString tip;
473
474 bool rr = false;
475 int dB = mdBMinSlider->GetValue();
476 if (dB != mdBMin) {
477 rr = true;
478 mdBMin = dB;
479 tip.Printf(_("%d dB"), (int)mdBMin);
480 mdBMinSlider->SetToolTip(tip);
481 }
482
483 dB = mdBMaxSlider->GetValue();
484 if (dB != mdBMax) {
485 rr = true;
486 mdBMax = dB;
487 tip.Printf(_("%d dB"),(int)mdBMax);
488 mdBMaxSlider->SetToolTip(tip);
489 }
490
491 if (rr) {
493 }
494
495 // Refresh ruler if values have changed
496 if (rr) {
497 int w1, w2, h;
498 mdBRuler->ruler.GetMaxSize(&w1, &h);
500 mdBRuler->ruler.GetMaxSize(&w2, &h);
501 if( w1 != w2 ) // Reduces flicker
502 {
503 mdBRuler->SetSize(wxSize(w2,h));
504 mUIParent->Layout();
505 mfreqRuler->Refresh(false);
506 }
507 mdBRuler->Refresh(false);
508 }
509
510 mPanel->Refresh(false);
511
512 return true;
513}
514
516{
517 switch (mFilterType)
518 {
519 case kButterworth:
521 break;
522 case kChebyshevTypeI:
524 break;
525 case kChebyshevTypeII:
527 break;
528 }
529}
530
532{
533 float Magn;
534 if (Freq >= mNyquist)
535 Freq = mNyquist - 1; // prevent tan(PI/2)
536 float FreqWarped = tan (PI * Freq/(2*mNyquist));
537 if (mCutoff >= mNyquist)
538 mCutoff = mNyquist - 1;
539 float CutoffWarped = tan (PI * mCutoff/(2*mNyquist));
540 float fOverflowThresh = pow (10.0, 12.0 / (2*mOrder)); // once we exceed 10^12 there's not much to be gained and overflow could happen
541
542 switch (mFilterType)
543 {
544 case kButterworth: // Butterworth
545 default:
546 switch (mFilterSubtype)
547 {
548 case kLowPass: // lowpass
549 default:
550 if (FreqWarped/CutoffWarped > fOverflowThresh) // prevent pow() overflow
551 Magn = 0;
552 else
553 Magn = sqrt (1 / (1 + pow (FreqWarped/CutoffWarped, 2*mOrder)));
554 break;
555 case kHighPass: // highpass
556 if (FreqWarped/CutoffWarped > fOverflowThresh)
557 Magn = 1;
558 else
559 Magn = sqrt (pow (FreqWarped/CutoffWarped, 2*mOrder) / (1 + pow (FreqWarped/CutoffWarped, 2*mOrder)));
560 break;
561 }
562 break;
563
564 case kChebyshevTypeI: // Chebyshev Type 1
565 double eps; eps = sqrt(pow (10.0, wxMax(0.001, mRipple)/10.0) - 1);
566 double chebyPolyVal;
567 switch (mFilterSubtype)
568 {
569 case 0: // lowpass
570 default:
571 chebyPolyVal = Biquad::ChebyPoly(mOrder, FreqWarped/CutoffWarped);
572 Magn = sqrt (1 / (1 + square(eps) * square(chebyPolyVal)));
573 break;
574 case 1:
575 chebyPolyVal = Biquad::ChebyPoly(mOrder, CutoffWarped/FreqWarped);
576 Magn = sqrt (1 / (1 + square(eps) * square(chebyPolyVal)));
577 break;
578 }
579 break;
580
581 case kChebyshevTypeII: // Chebyshev Type 2
582 eps = 1 / sqrt(pow (10.0, wxMax(0.001, mStopbandRipple)/10.0) - 1);
583 switch (mFilterSubtype)
584 {
585 case kLowPass: // lowpass
586 default:
587 chebyPolyVal = Biquad::ChebyPoly(mOrder, CutoffWarped/FreqWarped);
588 Magn = sqrt (1 / (1 + 1 / (square(eps) * square(chebyPolyVal))));
589 break;
590 case kHighPass:
591 chebyPolyVal = Biquad::ChebyPoly(mOrder, FreqWarped/CutoffWarped);
592 Magn = sqrt (1 / (1 + 1 / (square(eps) * square(chebyPolyVal))));
593 break;
594 }
595 break;
596 }
597
598 return Magn;
599}
600
601void EffectScienFilter::OnOrder(wxCommandEvent & WXUNUSED(evt))
602{
603 mOrderIndex = mFilterOrderCtl->GetSelection();
604 mOrder = mOrderIndex + 1; // 0..n-1 -> 1..n
605 mPanel->Refresh(false);
606}
607
608void EffectScienFilter::OnFilterType(wxCommandEvent & WXUNUSED(evt))
609{
610 mFilterType = mFilterTypeCtl->GetSelection();
612 mPanel->Refresh(false);
613}
614
615void EffectScienFilter::OnFilterSubtype(wxCommandEvent & WXUNUSED(evt))
616{
617 mFilterSubtype = mFilterSubTypeCtl->GetSelection();
618 mPanel->Refresh(false);
619}
620
621void EffectScienFilter::OnCutoff(wxCommandEvent & WXUNUSED(evt))
622{
624 mUIParent, mUIParent->TransferDataFromWindow()))
625 {
626 return;
627 }
628
629 mPanel->Refresh(false);
630}
631
632void EffectScienFilter::OnRipple(wxCommandEvent & WXUNUSED(evt))
633{
635 mUIParent, mUIParent->TransferDataFromWindow()))
636 {
637 return;
638 }
639
640 mPanel->Refresh(false);
641}
642
643void EffectScienFilter::OnStopbandRipple(wxCommandEvent & WXUNUSED(evt))
644{
646 mUIParent, mUIParent->TransferDataFromWindow()))
647 {
648 return;
649 }
650
651 mPanel->Refresh(false);
652}
653
654void EffectScienFilter::OnSliderDBMIN(wxCommandEvent & WXUNUSED(evt))
655{
657}
658
659void EffectScienFilter::OnSliderDBMAX(wxCommandEvent & WXUNUSED(evt))
660{
662}
663
664void EffectScienFilter::OnSize(wxSizeEvent & evt)
665{
666 // On Windows the Passband and Stopband boxes do not refresh properly
667 // on a resize...no idea why.
668 mUIParent->Refresh();
669 evt.Skip();
670}
671
673{
674 bool ripple;
675 bool stop;
676
677 if (FilterType == kButterworth) // Butterworth
678 {
679 ripple = false;
680 stop = false;
681 }
682 else if (FilterType == kChebyshevTypeI) // Chebyshev Type1
683 {
684 ripple = true;
685 stop = false;
686 }
687 else // Chebyshev Type2
688 {
689 ripple = false;
690 stop = true;
691 }
692
693 mRippleCtlP->Enable(ripple);
694 mRippleCtl->Enable(ripple);
695 mRippleCtlU->Enable(ripple);
696 mStopbandRippleCtlP->Enable(stop);
697 mStopbandRippleCtl->Enable(stop);
698 mStopbandRippleCtlU->Enable(stop);
699}
700
701//----------------------------------------------------------------------------
702// EffectScienFilterPanel
703//----------------------------------------------------------------------------
704
705BEGIN_EVENT_TABLE(EffectScienFilterPanel, wxPanelWrapper)
709
711 wxWindow *parent, wxWindowID winid,
712 EffectScienFilter *effect, double lo, double hi)
713: wxPanelWrapper(parent, winid, wxDefaultPosition, wxSize(400, 200))
714{
715 mEffect = effect;
716 mParent = parent;
717
718 mBitmap = NULL;
719 mWidth = 0;
720 mHeight = 0;
721 mLoFreq = 0.0;
722 mHiFreq = 0.0;
723 mDbMin = 0.0;
724 mDbMax = 0.0;
725
726 SetFreqRange(lo, hi);
727}
728
730{
731}
732
733void EffectScienFilterPanel::SetFreqRange(double lo, double hi)
734{
735 mLoFreq = lo;
736 mHiFreq = hi;
737 Refresh(false);
738}
739
741{
742 mDbMin = min;
743 mDbMax = max;
744 Refresh(false);
745}
746
748{
749 return false;
750}
751
753{
754 return false;
755}
756
757void EffectScienFilterPanel::OnSize(wxSizeEvent & WXUNUSED(evt))
758{
759 Refresh(false);
760}
761
762void EffectScienFilterPanel::OnPaint(wxPaintEvent & WXUNUSED(evt))
763{
764 wxPaintDC dc(this);
765 int width, height;
766 GetSize(&width, &height);
767
768 if (!mBitmap || mWidth != width || mHeight != height)
769 {
770 mWidth = width;
771 mHeight = height;
772 mBitmap = std::make_unique<wxBitmap>(mWidth, mHeight,24);
773 }
774
775 wxBrush bkgndBrush(wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE));
776
777 wxMemoryDC memDC;
778 memDC.SelectObject(*mBitmap);
779
780 wxRect bkgndRect;
781 bkgndRect.x = 0;
782 bkgndRect.y = 0;
783 bkgndRect.width = mWidth;
784 bkgndRect.height = mHeight;
785 memDC.SetBrush(bkgndBrush);
786 memDC.SetPen(*wxTRANSPARENT_PEN);
787 memDC.DrawRectangle(bkgndRect);
788
789 bkgndRect.y = mHeight;
790 memDC.DrawRectangle(bkgndRect);
791
792 wxRect border;
793 border.x = 0;
794 border.y = 0;
795 border.width = mWidth;
796 border.height = mHeight;
797
798 memDC.SetBrush(*wxWHITE_BRUSH);
799 memDC.SetPen(*wxBLACK_PEN);
800 memDC.DrawRectangle(border);
801
802 mEnvRect = border;
803 mEnvRect.Deflate(2, 2);
804
805 // Pure blue x-axis line
806 memDC.SetPen(wxPen(theTheme.Colour(clrGraphLines), 1, wxPENSTYLE_SOLID));
807 int center = (int) (mEnvRect.height * mDbMax / (mDbMax - mDbMin) + 0.5);
808 AColor::Line(memDC,
809 mEnvRect.GetLeft(), mEnvRect.y + center,
810 mEnvRect.GetRight(), mEnvRect.y + center);
811
812 //Now draw the actual response that you will get.
813 //mFilterFunc has a linear scale, window has a log one so we have to fiddle about
814 memDC.SetPen(wxPen(theTheme.Colour(clrResponseLines), 3, wxPENSTYLE_SOLID));
815 double scale = (double) mEnvRect.height / (mDbMax - mDbMin); // pixels per dB
816 double yF; // gain at this freq
817
818 double loLog = log10(mLoFreq);
819 double step = log10(mHiFreq) - loLog;
820 step /= ((double) mEnvRect.width - 1.0);
821 double freq; // actual freq corresponding to x position
822 int x, y, xlast = 0, ylast = 0;
823 for (int i = 0; i < mEnvRect.width; i++)
824 {
825 x = mEnvRect.x + i;
826 freq = pow(10.0, loLog + i * step); //Hz
827 yF = mEffect->FilterMagnAtFreq (freq);
828 yF = LINEAR_TO_DB(yF);
829
830 if (yF < mDbMin)
831 {
832 yF = mDbMin;
833 }
834
835 yF = center-scale * yF;
836 if (yF > mEnvRect.height)
837 {
838 yF = (double) mEnvRect.height - 1.0;
839 }
840 if (yF < 0.0)
841 {
842 yF = 0.0;
843 }
844 y = (int) (yF + 0.5);
845
846 if (i != 0 && (y < mEnvRect.height - 1 || ylast < mEnvRect.y + mEnvRect.height - 1))
847 {
848 AColor::Line(memDC, xlast, ylast, x, mEnvRect.y + y);
849 }
850 xlast = x;
851 ylast = mEnvRect.y + y;
852 }
853
854 memDC.SetPen(*wxBLACK_PEN);
855 mEffect->mfreqRuler->ruler.DrawGrid(memDC, mEnvRect.height + 2, true, true, 0, 1);
856 mEffect->mdBRuler->ruler.DrawGrid(memDC, mEnvRect.width + 2, true, true, 1, 2);
857
858 dc.Blit(0, 0, mWidth, mHeight, &memDC, 0, 0, wxCOPY, FALSE);
859
860 memDC.SelectObject(wxNullBitmap);
861}
END_EVENT_TABLE()
int min(int a, int b)
EffectType
@ EffectTypeProcess
ChannelName
XO("Cut/Copy/Paste")
XXO("&Cut/Copy/Paste Toolbar")
@ nTypes
#define _(s)
Definition: Internat.h:73
#define safenew
Definition: MemoryX.h:9
#define LINEAR_TO_DB(x)
Definition: MemoryX.h:338
@ ID_Cutoff
Definition: ScienFilter.cpp:83
@ ID_SubType
Definition: ScienFilter.cpp:80
@ ID_dBMax
Definition: ScienFilter.cpp:77
@ ID_Ripple
Definition: ScienFilter.cpp:82
@ ID_StopbandRipple
Definition: ScienFilter.cpp:84
@ ID_Order
Definition: ScienFilter.cpp:81
@ ID_FilterPanel
Definition: ScienFilter.cpp:76
@ ID_Type
Definition: ScienFilter.cpp:79
@ ID_dBMin
Definition: ScienFilter.cpp:78
#define square(a)
Definition: ScienFilter.cpp:72
#define PI
Definition: ScienFilter.cpp:68
TranslatableStrings Msgids(const EnumValueSymbol strings[], size_t nStrings)
Convenience function often useful when adding choice controls.
THEME_API Theme theTheme
Definition: Theme.cpp:82
#define S(N)
Definition: ToChars.cpp:64
TranslatableString Verbatim(wxString str)
Require calls to the one-argument constructor to go through this distinct global function name.
std::vector< TranslatableString > TranslatableStrings
static void Line(wxDC &dc, wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2)
Definition: AColor.cpp:187
Generates EffectParameterMethods overrides from variadic template arguments.
ComponentInterfaceSymbol pairs a persistent string identifier used internally with an optional,...
const TrackList * inputTracks() const
Definition: EffectBase.h:91
double mProjectRate
Definition: EffectBase.h:110
static bool EnableApply(wxWindow *parent, bool enable=true)
Enable or disable the Apply button of the dialog that contains parent.
Performs effect computation.
Hold values to send to effect output meters.
Interface for manipulations of an Effect's settings.
An Effect that applies 'classical' IIR filters.
Definition: ScienFilter.h:36
void OnFilterSubtype(wxCommandEvent &evt)
EffectScienFilterPanel * mPanel
Definition: ScienFilter.h:111
TranslatableString GetDescription() const override
void OnSliderDBMAX(wxCommandEvent &evt)
static const EnumValueSymbol kSubTypeStrings[nSubTypes]
Definition: ScienFilter.h:143
wxStaticText * mRippleCtlU
Definition: ScienFilter.h:117
void OnStopbandRipple(wxCommandEvent &evt)
friend class EffectScienFilterPanel
Definition: ScienFilter.h:135
bool ProcessInitialize(EffectSettings &settings, double sampleRate, ChannelNames chanMap) override
void OnCutoff(wxCommandEvent &evt)
static const EnumValueSymbol kTypeStrings[nTypes]
Definition: ScienFilter.h:152
ArrayOf< Biquad > mpBiquad
Definition: ScienFilter.h:102
wxTextCtrl * mRippleCtl
Definition: ScienFilter.h:116
void EnableDisableRippleCtl(int FilterType)
wxChoice * mFilterSubTypeCtl
Definition: ScienFilter.h:126
virtual ~EffectScienFilter()
static constexpr EffectParameter Stopband
Definition: ScienFilter.h:166
unsigned GetAudioOutCount() const override
How many output buffers to allocate at once.
static constexpr EffectParameter Cutoff
Definition: ScienFilter.h:162
size_t ProcessBlock(EffectSettings &settings, const float *const *inBlock, float *const *outBlock, size_t blockLen) override
Called for destructive effect computation.
static constexpr EnumParameter Subtype
Definition: ScienFilter.h:158
bool TransferDataFromWindow(EffectSettings &settings) override
wxTextCtrl * mCutoffCtl
Definition: ScienFilter.h:119
wxSlider * mdBMaxSlider
Definition: ScienFilter.h:113
wxChoice * mFilterTypeCtl
Definition: ScienFilter.h:125
void OnFilterType(wxCommandEvent &evt)
ManualPageID ManualPage() const override
Name of a page in the Audacity alpha manual, default is empty.
wxChoice * mFilterOrderCtl
Definition: ScienFilter.h:127
wxWeakRef< wxWindow > mUIParent
Definition: ScienFilter.h:93
wxStaticText * mStopbandRippleCtlP
Definition: ScienFilter.h:121
const EffectParameterMethods & Parameters() const override
std::unique_ptr< EffectEditor > PopulateOrExchange(ShuttleGui &S, EffectInstance &instance, EffectSettingsAccess &access, const EffectOutputs *pOutputs) override
Add controls to effect panel; always succeeds.
static constexpr EnumParameter Type
Definition: ScienFilter.h:156
static constexpr EffectParameter Passband
Definition: ScienFilter.h:164
RulerPanel * mdBRuler
Definition: ScienFilter.h:129
EffectType GetType() const override
Type determines how it behaves.
static constexpr EffectParameter Order
Definition: ScienFilter.h:160
wxTextCtrl * mStopbandRippleCtl
Definition: ScienFilter.h:122
bool TransferGraphLimitsFromWindow()
static const ComponentInterfaceSymbol Symbol
Definition: ScienFilter.h:40
bool TransferDataToWindow(const EffectSettings &settings) override
void OnSliderDBMIN(wxCommandEvent &evt)
bool Init() override
void OnOrder(wxCommandEvent &evt)
void OnRipple(wxCommandEvent &evt)
RulerPanel * mfreqRuler
Definition: ScienFilter.h:130
wxStaticText * mRippleCtlP
Definition: ScienFilter.h:115
float FilterMagnAtFreq(float Freq)
unsigned GetAudioInCount() const override
How many input buffers to allocate at once.
ComponentInterfaceSymbol GetSymbol() const override
wxStaticText * mStopbandRippleCtlU
Definition: ScienFilter.h:123
void OnSize(wxSizeEvent &evt)
wxSlider * mdBMinSlider
Definition: ScienFilter.h:112
EffectScienFilterPanel is used with EffectScienFilter and controls a graph for EffectScienFilter.
Definition: ScienFilter.h:171
void OnPaint(wxPaintEvent &evt)
void OnSize(wxSizeEvent &evt)
virtual ~EffectScienFilterPanel()
void SetDbRange(double min, double max)
bool AcceptsFocus() const
bool AcceptsFocusFromKeyboard() const
EffectScienFilter * mEffect
Definition: ScienFilter.h:191
std::unique_ptr< wxBitmap > mBitmap
Definition: ScienFilter.h:200
void SetFreqRange(double lo, double hi)
static int DoMessageBox(const EffectPlugin &plugin, const TranslatableString &message, long style=DefaultMessageBoxStyle, const TranslatableString &titleStr={})
static const IntFormat & Instance()
Definition: IntFormat.cpp:14
static const LinearDBFormat & Instance()
void DrawGrid(wxDC &dc, int length, bool minor=true, bool major=true, int xOffset=0, int yOffset=0) const
Definition: Ruler.cpp:530
void GetMaxSize(wxCoord *width, wxCoord *height)
Definition: Ruler.cpp:612
void SetRange(double min, double max)
Definition: Ruler.cpp:152
RulerPanel class allows you to work with a Ruler like any other wxWindow.
Definition: RulerPanel.h:19
Ruler ruler
Definition: RulerPanel.h:79
std::pair< double, double > Range
Definition: RulerPanel.h:23
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI.
Definition: ShuttleGui.h:640
wxColour & Colour(int iIndex)
auto Selected() -> TrackIterRange< TrackType >
Definition: Track.h:967
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.
A Validator is an object which checks whether a wxVariant satisfies a certain criterion....
Definition: Validators.h:54
A Track that contains audio waveform data.
Definition: WaveTrack.h:203
BuiltinEffectsModule::Registration< EffectScienFilter > reg(true)
__finl float_x4 __vecc sqrt(const float_x4 &a)
static ArrayOf< Biquad > CalcButterworthFilter(int order, double fn, double fc, int type)
Definition: Biquad.cpp:64
static ArrayOf< Biquad > CalcChebyshevType2Filter(int order, double fn, double fc, double ripple, int type)
Definition: Biquad.cpp:228
static double ChebyPoly(int Order, double NormFreq)
Definition: Biquad.cpp:329
static ArrayOf< Biquad > CalcChebyshevType1Filter(int order, double fn, double fc, double ripple, int type)
Definition: Biquad.cpp:146
const Type min
Minimum value.
const Type max
Maximum value.
Externalized state of a plug-in.
Options & LabelEdges(bool l)
Definition: RulerPanel.h:41
Options & Flip(bool f)
Definition: RulerPanel.h:38
Options & Log(bool l)
Definition: RulerPanel.h:35