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#ifdef EXPERIMENTAL_SCIENCE_FILTERS
129// true argument means don't automatically enable this effect
131#endif
132
133BEGIN_EVENT_TABLE(EffectScienFilter, wxEvtHandler)
135
145
147{
148 Parameters().Reset(*this);
149 SetLinearEffectFlag(true);
150
151 mOrderIndex = mOrder - 1;
152
153 mdBMin = -30.0;
154 mdBMax = 30.0;
155
156 mLoFreq = 20; // Lowest frequency to display in response graph
157 mNyquist = 44100.0 / 2.0; // only used during initialization, updated when effect is used
158}
159
161{
162}
163
164// ComponentInterface implementation
165
167{
168 return Symbol;
169}
170
172{
173 /* i18n-hint: "infinite impulse response" */
174 return XO("Performs IIR filtering that emulates analog filters");
175}
176
178{
179 return L"Classic_Filters";
180}
181
182
183// EffectDefinitionInterface implementation
184
186{
187 return EffectTypeProcess;
188}
189
191{
192 return 1;
193}
194
196{
197 return 1;
198}
199
201 EffectSettings &, double, ChannelNames chanMap)
202{
203 for (int iPair = 0; iPair < (mOrder + 1) / 2; iPair++)
204 mpBiquad[iPair].Reset();
205 return true;
206}
207
209 const float *const *inBlock, float *const *outBlock, size_t blockLen)
210{
211 const float *ibuf = inBlock[0];
212 for (int iPair = 0; iPair < (mOrder + 1) / 2; iPair++)
213 {
214 mpBiquad[iPair].Process(ibuf, outBlock[0], blockLen);
215 ibuf = outBlock[0];
216 }
217
218 return blockLen;
219}
220
221// Effect implementation
222
224{
225 int selcount = 0;
226 double rate = 0.0;
227
228 auto trackRange = inputTracks()->Selected< const WaveTrack >();
229
230 {
231 auto t = *trackRange.begin();
232 mNyquist =
233 (t
234 ? t->GetRate()
235 : mProjectRate)
236 / 2.0;
237 }
238
239 for (auto t : trackRange)
240 {
241 if (selcount == 0)
242 {
243 rate = t->GetRate();
244 }
245 else
246 {
247 if (t->GetRate() != rate)
248 {
250 XO(
251"To apply a filter, all selected tracks must have the same sample rate.") );
252 return false;
253 }
254 }
255 selcount++;
256 }
257
258 return true;
259}
260
261std::unique_ptr<EffectEditor> EffectScienFilter::PopulateOrExchange(
263 const EffectOutputs *)
264{
265 mUIParent = S.GetParent();
266 S.AddSpace(5);
267 S.SetSizerProportion(1);
268 S.StartMultiColumn(3, wxEXPAND);
269 {
270 S.SetStretchyCol(1);
271 S.SetStretchyRow(0);
272
273 // -------------------------------------------------------------------
274 // ROW 1: Freq response panel and sliders for vertical scale
275 // -------------------------------------------------------------------
276
277 S.StartVerticalLay();
278 {
280 S.GetParent(), wxID_ANY, wxVERTICAL,
281 wxSize{ 100, 100 }, // Ruler can't handle small sizes
282 RulerPanel::Range{ 30.0, -120.0 },
284 XO("dB"),
286 .LabelEdges(true)
287 );
288
289 S.SetBorder(1);
290 S.AddSpace(1, 1);
291 S.Prop(1)
292 .Position(wxALIGN_RIGHT | wxTOP)
293 .AddWindow(mdBRuler);
294 S.AddSpace(1, 1);
295 }
296 S.EndVerticalLay();
297
299 S.GetParent(), wxID_ANY,
300 this, mLoFreq, mNyquist
301 );
302
303 S.SetBorder(5);
304 S.Prop(1)
305 .Position(wxEXPAND | wxRIGHT)
306 .MinSize( { -1, -1 } )
307 .AddWindow(mPanel);
308
309 S.StartVerticalLay();
310 {
311 S.AddVariableText(XO("+ dB"), false, wxCENTER);
313 .Name(XO("Max dB"))
314 .Style(wxSL_VERTICAL | wxSL_INVERSE)
315 .AddSlider( {}, 10, 20, 0);
316#if wxUSE_ACCESSIBILITY
317 mdBMaxSlider->SetAccessible(safenew SliderAx(mdBMaxSlider, XO("%d dB")));
318#endif
320 .Name(XO("Min dB"))
321 .Style(wxSL_VERTICAL | wxSL_INVERSE)
322 .AddSlider( {}, -10, -10, -120);
323#if wxUSE_ACCESSIBILITY
324 mdBMinSlider->SetAccessible(safenew SliderAx(mdBMinSlider, XO("%d dB")));
325#endif
326
327 S.AddVariableText(XO("- dB"), false, wxCENTER);
328 }
329 S.EndVerticalLay();
330
331 // -------------------------------------------------------------------
332 // ROW 2: Frequency ruler
333 // -------------------------------------------------------------------
334
335 S.AddSpace(1, 1);
336
338 S.GetParent(), wxID_ANY, wxHORIZONTAL,
339 wxSize{ 100, 100 }, // Ruler can't handle small sizes
340 RulerPanel::Range{ mLoFreq, mNyquist },
342 {},
344 .Log(true)
345 .Flip(true)
346 .LabelEdges(true)
347 );
348
349 S.Prop(1)
350 .Position(wxEXPAND | wxALIGN_LEFT | wxRIGHT)
351 .AddWindow(mfreqRuler);
352
353 S.AddSpace(1, 1);
354
355 // -------------------------------------------------------------------
356 // ROW 3 and 4: Type, Order, Ripple, Subtype, Cutoff
357 // -------------------------------------------------------------------
358
359 S.AddSpace(1, 1);
360 S.SetSizerProportion(0);
361 S.StartMultiColumn(8, wxALIGN_CENTER);
362 {
363 wxASSERT(nTypes == WXSIZEOF(kTypeStrings));
364
366 .Focus()
367 .Validator<wxGenericValidator>(&mFilterType)
368 .MinSize( { -1, -1 } )
369 .AddChoice(XXO("&Filter Type:"),
371 );
372
374 .Validator<wxGenericValidator>(&mOrderIndex)
375 .MinSize( { -1, -1 } )
376 /*i18n-hint: 'Order' means the complexity of the filter, and is a number between 1 and 10.*/
377 .AddChoice(XXO("O&rder:"),
378 []{
379 TranslatableStrings orders;
380 for (int i = 1; i <= 10; i++)
381 orders.emplace_back( Verbatim("%d").Format( i ) );
382 return orders;
383 }()
384 );
385 S.AddSpace(1, 1);
386
387 mRippleCtlP = S.AddVariableText( XO("&Passband Ripple:"),
388 false, wxALL | wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
390 .Name(XO("Passband Ripple (dB)"))
391 .Validator<FloatingPointValidator<float>>(
392 1, &mRipple, NumValidatorStyle::DEFAULT,
394 .AddTextBox( {}, L"", 10);
395 mRippleCtlU = S.AddVariableText(XO("dB"),
396 false, wxALL | wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL);
397
399 .Validator<wxGenericValidator>(&mFilterSubtype)
400 .MinSize( { -1, -1 } )
401 .AddChoice(XXO("&Subtype:"),
403 );
404
406 .Name(XO("Cutoff (Hz)"))
407 .Validator<FloatingPointValidator<float>>(
408 1, &mCutoff, NumValidatorStyle::DEFAULT,
409 Cutoff.min, mNyquist - 1)
410 .AddTextBox(XXO("C&utoff:"), L"", 10);
411 S.AddUnits(XO("Hz"));
412
414 S.AddVariableText(XO("Minimum S&topband Attenuation:"),
415 false, wxALL | wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
417 .Name(XO("Minimum S&topband Attenuation (dB)"))
418 .Validator<FloatingPointValidator<float>>(
419 1, &mStopbandRipple, NumValidatorStyle::DEFAULT,
421 .AddTextBox( {}, L"", 10);
423 S.AddVariableText(XO("dB"),
424 false, wxALL | wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL);
425 }
426 S.EndMultiColumn();
427 S.AddSpace(1, 1);
428 }
429 S.EndMultiColumn();
430
431 return nullptr;
432}
433
434//
435// Populate the window with relevant variables
436//
438{
439 mOrderIndex = mOrder - 1;
440
441 if (!mUIParent->TransferDataToWindow())
442 {
443 return false;
444 }
445
446 mdBMinSlider->SetValue((int) mdBMin);
447 mdBMin = 0.0; // force refresh in TransferGraphLimitsFromWindow()
448
449 mdBMaxSlider->SetValue((int) mdBMax);
450 mdBMax = 0.0; // force refresh in TransferGraphLimitsFromWindow()
451
453
455}
456
458{
459 if (!mUIParent->Validate() || !mUIParent->TransferDataFromWindow())
460 {
461 return false;
462 }
463
464 mOrder = mOrderIndex + 1;
465
466 CalcFilter();
467
468 return true;
469}
470
471// EffectScienFilter implementation
472
473//
474// Retrieve data from the window
475//
477{
478 // Read the sliders and send to the panel
479 wxString tip;
480
481 bool rr = false;
482 int dB = mdBMinSlider->GetValue();
483 if (dB != mdBMin) {
484 rr = true;
485 mdBMin = dB;
486 tip.Printf(_("%d dB"), (int)mdBMin);
487 mdBMinSlider->SetToolTip(tip);
488 }
489
490 dB = mdBMaxSlider->GetValue();
491 if (dB != mdBMax) {
492 rr = true;
493 mdBMax = dB;
494 tip.Printf(_("%d dB"),(int)mdBMax);
495 mdBMaxSlider->SetToolTip(tip);
496 }
497
498 if (rr) {
500 }
501
502 // Refresh ruler if values have changed
503 if (rr) {
504 int w1, w2, h;
505 mdBRuler->ruler.GetMaxSize(&w1, &h);
507 mdBRuler->ruler.GetMaxSize(&w2, &h);
508 if( w1 != w2 ) // Reduces flicker
509 {
510 mdBRuler->SetSize(wxSize(w2,h));
511 mUIParent->Layout();
512 mfreqRuler->Refresh(false);
513 }
514 mdBRuler->Refresh(false);
515 }
516
517 mPanel->Refresh(false);
518
519 return true;
520}
521
523{
524 switch (mFilterType)
525 {
526 case kButterworth:
528 break;
529 case kChebyshevTypeI:
531 break;
532 case kChebyshevTypeII:
534 break;
535 }
536}
537
539{
540 float Magn;
541 if (Freq >= mNyquist)
542 Freq = mNyquist - 1; // prevent tan(PI/2)
543 float FreqWarped = tan (PI * Freq/(2*mNyquist));
544 if (mCutoff >= mNyquist)
545 mCutoff = mNyquist - 1;
546 float CutoffWarped = tan (PI * mCutoff/(2*mNyquist));
547 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
548
549 switch (mFilterType)
550 {
551 case kButterworth: // Butterworth
552 default:
553 switch (mFilterSubtype)
554 {
555 case kLowPass: // lowpass
556 default:
557 if (FreqWarped/CutoffWarped > fOverflowThresh) // prevent pow() overflow
558 Magn = 0;
559 else
560 Magn = sqrt (1 / (1 + pow (FreqWarped/CutoffWarped, 2*mOrder)));
561 break;
562 case kHighPass: // highpass
563 if (FreqWarped/CutoffWarped > fOverflowThresh)
564 Magn = 1;
565 else
566 Magn = sqrt (pow (FreqWarped/CutoffWarped, 2*mOrder) / (1 + pow (FreqWarped/CutoffWarped, 2*mOrder)));
567 break;
568 }
569 break;
570
571 case kChebyshevTypeI: // Chebyshev Type 1
572 double eps; eps = sqrt(pow (10.0, wxMax(0.001, mRipple)/10.0) - 1);
573 double chebyPolyVal;
574 switch (mFilterSubtype)
575 {
576 case 0: // lowpass
577 default:
578 chebyPolyVal = Biquad::ChebyPoly(mOrder, FreqWarped/CutoffWarped);
579 Magn = sqrt (1 / (1 + square(eps) * square(chebyPolyVal)));
580 break;
581 case 1:
582 chebyPolyVal = Biquad::ChebyPoly(mOrder, CutoffWarped/FreqWarped);
583 Magn = sqrt (1 / (1 + square(eps) * square(chebyPolyVal)));
584 break;
585 }
586 break;
587
588 case kChebyshevTypeII: // Chebyshev Type 2
589 eps = 1 / sqrt(pow (10.0, wxMax(0.001, mStopbandRipple)/10.0) - 1);
590 switch (mFilterSubtype)
591 {
592 case kLowPass: // lowpass
593 default:
594 chebyPolyVal = Biquad::ChebyPoly(mOrder, CutoffWarped/FreqWarped);
595 Magn = sqrt (1 / (1 + 1 / (square(eps) * square(chebyPolyVal))));
596 break;
597 case kHighPass:
598 chebyPolyVal = Biquad::ChebyPoly(mOrder, FreqWarped/CutoffWarped);
599 Magn = sqrt (1 / (1 + 1 / (square(eps) * square(chebyPolyVal))));
600 break;
601 }
602 break;
603 }
604
605 return Magn;
606}
607
608void EffectScienFilter::OnOrder(wxCommandEvent & WXUNUSED(evt))
609{
610 mOrderIndex = mFilterOrderCtl->GetSelection();
611 mOrder = mOrderIndex + 1; // 0..n-1 -> 1..n
612 mPanel->Refresh(false);
613}
614
615void EffectScienFilter::OnFilterType(wxCommandEvent & WXUNUSED(evt))
616{
617 mFilterType = mFilterTypeCtl->GetSelection();
619 mPanel->Refresh(false);
620}
621
622void EffectScienFilter::OnFilterSubtype(wxCommandEvent & WXUNUSED(evt))
623{
624 mFilterSubtype = mFilterSubTypeCtl->GetSelection();
625 mPanel->Refresh(false);
626}
627
628void EffectScienFilter::OnCutoff(wxCommandEvent & WXUNUSED(evt))
629{
631 mUIParent, mUIParent->TransferDataFromWindow()))
632 {
633 return;
634 }
635
636 mPanel->Refresh(false);
637}
638
639void EffectScienFilter::OnRipple(wxCommandEvent & WXUNUSED(evt))
640{
642 mUIParent, mUIParent->TransferDataFromWindow()))
643 {
644 return;
645 }
646
647 mPanel->Refresh(false);
648}
649
650void EffectScienFilter::OnStopbandRipple(wxCommandEvent & WXUNUSED(evt))
651{
653 mUIParent, mUIParent->TransferDataFromWindow()))
654 {
655 return;
656 }
657
658 mPanel->Refresh(false);
659}
660
661void EffectScienFilter::OnSliderDBMIN(wxCommandEvent & WXUNUSED(evt))
662{
664}
665
666void EffectScienFilter::OnSliderDBMAX(wxCommandEvent & WXUNUSED(evt))
667{
669}
670
671void EffectScienFilter::OnSize(wxSizeEvent & evt)
672{
673 // On Windows the Passband and Stopband boxes do not refresh properly
674 // on a resize...no idea why.
675 mUIParent->Refresh();
676 evt.Skip();
677}
678
680{
681 bool ripple;
682 bool stop;
683
684 if (FilterType == kButterworth) // Butterworth
685 {
686 ripple = false;
687 stop = false;
688 }
689 else if (FilterType == kChebyshevTypeI) // Chebyshev Type1
690 {
691 ripple = true;
692 stop = false;
693 }
694 else // Chebyshev Type2
695 {
696 ripple = false;
697 stop = true;
698 }
699
700 mRippleCtlP->Enable(ripple);
701 mRippleCtl->Enable(ripple);
702 mRippleCtlU->Enable(ripple);
703 mStopbandRippleCtlP->Enable(stop);
704 mStopbandRippleCtl->Enable(stop);
705 mStopbandRippleCtlU->Enable(stop);
706}
707
708//----------------------------------------------------------------------------
709// EffectScienFilterPanel
710//----------------------------------------------------------------------------
711
712BEGIN_EVENT_TABLE(EffectScienFilterPanel, wxPanelWrapper)
716
718 wxWindow *parent, wxWindowID winid,
719 EffectScienFilter *effect, double lo, double hi)
720: wxPanelWrapper(parent, winid, wxDefaultPosition, wxSize(400, 200))
721{
722 mEffect = effect;
723 mParent = parent;
724
725 mBitmap = NULL;
726 mWidth = 0;
727 mHeight = 0;
728 mLoFreq = 0.0;
729 mHiFreq = 0.0;
730 mDbMin = 0.0;
731 mDbMax = 0.0;
732
733 SetFreqRange(lo, hi);
734}
735
737{
738}
739
740void EffectScienFilterPanel::SetFreqRange(double lo, double hi)
741{
742 mLoFreq = lo;
743 mHiFreq = hi;
744 Refresh(false);
745}
746
748{
749 mDbMin = min;
750 mDbMax = max;
751 Refresh(false);
752}
753
755{
756 return false;
757}
758
760{
761 return false;
762}
763
764void EffectScienFilterPanel::OnSize(wxSizeEvent & WXUNUSED(evt))
765{
766 Refresh(false);
767}
768
769void EffectScienFilterPanel::OnPaint(wxPaintEvent & WXUNUSED(evt))
770{
771 wxPaintDC dc(this);
772 int width, height;
773 GetSize(&width, &height);
774
775 if (!mBitmap || mWidth != width || mHeight != height)
776 {
777 mWidth = width;
778 mHeight = height;
779 mBitmap = std::make_unique<wxBitmap>(mWidth, mHeight,24);
780 }
781
782 wxBrush bkgndBrush(wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE));
783
784 wxMemoryDC memDC;
785 memDC.SelectObject(*mBitmap);
786
787 wxRect bkgndRect;
788 bkgndRect.x = 0;
789 bkgndRect.y = 0;
790 bkgndRect.width = mWidth;
791 bkgndRect.height = mHeight;
792 memDC.SetBrush(bkgndBrush);
793 memDC.SetPen(*wxTRANSPARENT_PEN);
794 memDC.DrawRectangle(bkgndRect);
795
796 bkgndRect.y = mHeight;
797 memDC.DrawRectangle(bkgndRect);
798
799 wxRect border;
800 border.x = 0;
801 border.y = 0;
802 border.width = mWidth;
803 border.height = mHeight;
804
805 memDC.SetBrush(*wxWHITE_BRUSH);
806 memDC.SetPen(*wxBLACK_PEN);
807 memDC.DrawRectangle(border);
808
809 mEnvRect = border;
810 mEnvRect.Deflate(2, 2);
811
812 // Pure blue x-axis line
813 memDC.SetPen(wxPen(theTheme.Colour(clrGraphLines), 1, wxPENSTYLE_SOLID));
814 int center = (int) (mEnvRect.height * mDbMax / (mDbMax - mDbMin) + 0.5);
815 AColor::Line(memDC,
816 mEnvRect.GetLeft(), mEnvRect.y + center,
817 mEnvRect.GetRight(), mEnvRect.y + center);
818
819 //Now draw the actual response that you will get.
820 //mFilterFunc has a linear scale, window has a log one so we have to fiddle about
821 memDC.SetPen(wxPen(theTheme.Colour(clrResponseLines), 3, wxPENSTYLE_SOLID));
822 double scale = (double) mEnvRect.height / (mDbMax - mDbMin); // pixels per dB
823 double yF; // gain at this freq
824
825 double loLog = log10(mLoFreq);
826 double step = log10(mHiFreq) - loLog;
827 step /= ((double) mEnvRect.width - 1.0);
828 double freq; // actual freq corresponding to x position
829 int x, y, xlast = 0, ylast = 0;
830 for (int i = 0; i < mEnvRect.width; i++)
831 {
832 x = mEnvRect.x + i;
833 freq = pow(10.0, loLog + i * step); //Hz
834 yF = mEffect->FilterMagnAtFreq (freq);
835 yF = LINEAR_TO_DB(yF);
836
837 if (yF < mDbMin)
838 {
839 yF = mDbMin;
840 }
841
842 yF = center-scale * yF;
843 if (yF > mEnvRect.height)
844 {
845 yF = (double) mEnvRect.height - 1.0;
846 }
847 if (yF < 0.0)
848 {
849 yF = 0.0;
850 }
851 y = (int) (yF + 0.5);
852
853 if (i != 0 && (y < mEnvRect.height - 1 || ylast < mEnvRect.y + mEnvRect.height - 1))
854 {
855 AColor::Line(memDC, xlast, ylast, x, mEnvRect.y + y);
856 }
857 xlast = x;
858 ylast = mEnvRect.y + y;
859 }
860
861 memDC.SetPen(*wxBLACK_PEN);
862 mEffect->mfreqRuler->ruler.DrawGrid(memDC, mEnvRect.height + 2, true, true, 0, 1);
863 mEffect->mdBRuler->ruler.DrawGrid(memDC, mEnvRect.width + 2, true, true, 1, 2);
864
865 dc.Blit(0, 0, mWidth, mHeight, &memDC, 0, 0, wxCOPY, FALSE);
866
867 memDC.SelectObject(wxNullBitmap);
868}
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:10
#define LINEAR_TO_DB(x)
Definition: MemoryX.h:561
#define square(a)
Definition: ScienFilter.cpp:72
#define PI
Definition: ScienFilter.cpp:68
@ 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
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:108
double mProjectRate
Definition: EffectBase.h:105
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:531
void GetMaxSize(wxCoord *width, wxCoord *height)
Definition: Ruler.cpp:613
void SetRange(double min, double max)
Definition: Ruler.cpp:151
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:625
wxColour & Colour(int iIndex)
auto Selected() -> TrackIterRange< TrackType >
Definition: Track.h:1457
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:53
A Track that contains audio waveform data.
Definition: WaveTrack.h:51
BuiltinCommandsModule::Registration< CompareAudioCommand > reg
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