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 if (selcount == 0)
241 rate = t->GetRate();
242 else {
243 if (t->GetRate() != rate) {
245 XO(
246"To apply a filter, all selected tracks must have the same sample rate.") );
247 return false;
248 }
249 }
250 ++selcount;
251 }
252
253 return true;
254}
255
256std::unique_ptr<EffectEditor> EffectScienFilter::PopulateOrExchange(
258 const EffectOutputs *)
259{
260 mUIParent = S.GetParent();
261 S.AddSpace(5);
262 S.SetSizerProportion(1);
263 S.StartMultiColumn(3, wxEXPAND);
264 {
265 S.SetStretchyCol(1);
266 S.SetStretchyRow(0);
267
268 // -------------------------------------------------------------------
269 // ROW 1: Freq response panel and sliders for vertical scale
270 // -------------------------------------------------------------------
271
272 S.StartVerticalLay();
273 {
275 S.GetParent(), wxID_ANY, wxVERTICAL,
276 wxSize{ 100, 100 }, // Ruler can't handle small sizes
277 RulerPanel::Range{ 30.0, -120.0 },
279 XO("dB"),
281 .LabelEdges(true)
282 );
283
284 S.SetBorder(1);
285 S.AddSpace(1, 1);
286 S.Prop(1)
287 .Position(wxALIGN_RIGHT | wxTOP)
288 .AddWindow(mdBRuler);
289 S.AddSpace(1, 1);
290 }
291 S.EndVerticalLay();
292
294 S.GetParent(), wxID_ANY,
295 this, mLoFreq, mNyquist
296 );
297
298 S.SetBorder(5);
299 S.Prop(1)
300 .Position(wxEXPAND | wxRIGHT)
301 .MinSize( { -1, -1 } )
302 .AddWindow(mPanel);
303
304 S.StartVerticalLay();
305 {
306 S.AddVariableText(XO("+ dB"), false, wxCENTER);
308 .Name(XO("Max dB"))
309 .Style(wxSL_VERTICAL | wxSL_INVERSE)
310 .AddSlider( {}, 10, 20, 0);
311#if wxUSE_ACCESSIBILITY
312 mdBMaxSlider->SetAccessible(safenew SliderAx(mdBMaxSlider, XO("%d dB")));
313#endif
315 .Name(XO("Min dB"))
316 .Style(wxSL_VERTICAL | wxSL_INVERSE)
317 .AddSlider( {}, -10, -10, -120);
318#if wxUSE_ACCESSIBILITY
319 mdBMinSlider->SetAccessible(safenew SliderAx(mdBMinSlider, XO("%d dB")));
320#endif
321
322 S.AddVariableText(XO("- dB"), false, wxCENTER);
323 }
324 S.EndVerticalLay();
325
326 // -------------------------------------------------------------------
327 // ROW 2: Frequency ruler
328 // -------------------------------------------------------------------
329
330 S.AddSpace(1, 1);
331
333 S.GetParent(), wxID_ANY, wxHORIZONTAL,
334 wxSize{ 100, 100 }, // Ruler can't handle small sizes
335 RulerPanel::Range{ mLoFreq, mNyquist },
337 {},
339 .Log(true)
340 .Flip(true)
341 .LabelEdges(true)
342 );
343
344 S.Prop(1)
345 .Position(wxEXPAND | wxALIGN_LEFT | wxRIGHT)
346 .AddWindow(mfreqRuler);
347
348 S.AddSpace(1, 1);
349
350 // -------------------------------------------------------------------
351 // ROW 3 and 4: Type, Order, Ripple, Subtype, Cutoff
352 // -------------------------------------------------------------------
353
354 S.AddSpace(1, 1);
355 S.SetSizerProportion(0);
356 S.StartMultiColumn(8, wxALIGN_CENTER);
357 {
358 wxASSERT(nTypes == WXSIZEOF(kTypeStrings));
359
361 .Focus()
362 .Validator<wxGenericValidator>(&mFilterType)
363 .MinSize( { -1, -1 } )
364 .AddChoice(XXO("&Filter Type:"),
366 );
367
369 .Validator<wxGenericValidator>(&mOrderIndex)
370 .MinSize( { -1, -1 } )
371 /*i18n-hint: 'Order' means the complexity of the filter, and is a number between 1 and 10.*/
372 .AddChoice(XXO("O&rder:"),
373 []{
374 TranslatableStrings orders;
375 for (int i = 1; i <= 10; i++)
376 orders.emplace_back( Verbatim("%d").Format( i ) );
377 return orders;
378 }()
379 );
380 S.AddSpace(1, 1);
381
382 mRippleCtlP = S.AddVariableText( XO("&Passband Ripple:"),
383 false, wxALL | wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
385 .Name(XO("Passband Ripple (dB)"))
386 .Validator<FloatingPointValidator<float>>(
387 1, &mRipple, NumValidatorStyle::DEFAULT,
389 .AddTextBox( {}, L"", 10);
390 mRippleCtlU = S.AddVariableText(XO("dB"),
391 false, wxALL | wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL);
392
394 .Validator<wxGenericValidator>(&mFilterSubtype)
395 .MinSize( { -1, -1 } )
396 .AddChoice(XXO("&Subtype:"),
398 );
399
401 .Name(XO("Cutoff (Hz)"))
402 .Validator<FloatingPointValidator<float>>(
403 1, &mCutoff, NumValidatorStyle::DEFAULT,
404 Cutoff.min, mNyquist - 1)
405 .AddTextBox(XXO("C&utoff:"), L"", 10);
406 S.AddUnits(XO("Hz"));
407
409 S.AddVariableText(XO("Minimum S&topband Attenuation:"),
410 false, wxALL | wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
412 .Name(XO("Minimum S&topband Attenuation (dB)"))
413 .Validator<FloatingPointValidator<float>>(
414 1, &mStopbandRipple, NumValidatorStyle::DEFAULT,
416 .AddTextBox( {}, L"", 10);
418 S.AddVariableText(XO("dB"),
419 false, wxALL | wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL);
420 }
421 S.EndMultiColumn();
422 S.AddSpace(1, 1);
423 }
424 S.EndMultiColumn();
425
426 return nullptr;
427}
428
429//
430// Populate the window with relevant variables
431//
433{
434 mOrderIndex = mOrder - 1;
435
436 if (!mUIParent->TransferDataToWindow())
437 {
438 return false;
439 }
440
441 mdBMinSlider->SetValue((int) mdBMin);
442 mdBMin = 0.0; // force refresh in TransferGraphLimitsFromWindow()
443
444 mdBMaxSlider->SetValue((int) mdBMax);
445 mdBMax = 0.0; // force refresh in TransferGraphLimitsFromWindow()
446
448
450}
451
453{
454 if (!mUIParent->Validate() || !mUIParent->TransferDataFromWindow())
455 {
456 return false;
457 }
458
459 mOrder = mOrderIndex + 1;
460
461 CalcFilter();
462
463 return true;
464}
465
466// EffectScienFilter implementation
467
468//
469// Retrieve data from the window
470//
472{
473 // Read the sliders and send to the panel
474 wxString tip;
475
476 bool rr = false;
477 int dB = mdBMinSlider->GetValue();
478 if (dB != mdBMin) {
479 rr = true;
480 mdBMin = dB;
481 tip.Printf(_("%d dB"), (int)mdBMin);
482 mdBMinSlider->SetToolTip(tip);
483 }
484
485 dB = mdBMaxSlider->GetValue();
486 if (dB != mdBMax) {
487 rr = true;
488 mdBMax = dB;
489 tip.Printf(_("%d dB"),(int)mdBMax);
490 mdBMaxSlider->SetToolTip(tip);
491 }
492
493 if (rr) {
495 }
496
497 // Refresh ruler if values have changed
498 if (rr) {
499 int w1, w2, h;
500 mdBRuler->ruler.GetMaxSize(&w1, &h);
502 mdBRuler->ruler.GetMaxSize(&w2, &h);
503 if( w1 != w2 ) // Reduces flicker
504 {
505 mdBRuler->SetSize(wxSize(w2,h));
506 mUIParent->Layout();
507 mfreqRuler->Refresh(false);
508 }
509 mdBRuler->Refresh(false);
510 }
511
512 mPanel->Refresh(false);
513
514 return true;
515}
516
518{
519 switch (mFilterType)
520 {
521 case kButterworth:
523 break;
524 case kChebyshevTypeI:
526 break;
527 case kChebyshevTypeII:
529 break;
530 }
531}
532
534{
535 float Magn;
536 if (Freq >= mNyquist)
537 Freq = mNyquist - 1; // prevent tan(PI/2)
538 float FreqWarped = tan (PI * Freq/(2*mNyquist));
539 if (mCutoff >= mNyquist)
540 mCutoff = mNyquist - 1;
541 float CutoffWarped = tan (PI * mCutoff/(2*mNyquist));
542 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
543
544 switch (mFilterType)
545 {
546 case kButterworth: // Butterworth
547 default:
548 switch (mFilterSubtype)
549 {
550 case kLowPass: // lowpass
551 default:
552 if (FreqWarped/CutoffWarped > fOverflowThresh) // prevent pow() overflow
553 Magn = 0;
554 else
555 Magn = sqrt (1 / (1 + pow (FreqWarped/CutoffWarped, 2*mOrder)));
556 break;
557 case kHighPass: // highpass
558 if (FreqWarped/CutoffWarped > fOverflowThresh)
559 Magn = 1;
560 else
561 Magn = sqrt (pow (FreqWarped/CutoffWarped, 2*mOrder) / (1 + pow (FreqWarped/CutoffWarped, 2*mOrder)));
562 break;
563 }
564 break;
565
566 case kChebyshevTypeI: // Chebyshev Type 1
567 double eps; eps = sqrt(pow (10.0, wxMax(0.001, mRipple)/10.0) - 1);
568 double chebyPolyVal;
569 switch (mFilterSubtype)
570 {
571 case 0: // lowpass
572 default:
573 chebyPolyVal = Biquad::ChebyPoly(mOrder, FreqWarped/CutoffWarped);
574 Magn = sqrt (1 / (1 + square(eps) * square(chebyPolyVal)));
575 break;
576 case 1:
577 chebyPolyVal = Biquad::ChebyPoly(mOrder, CutoffWarped/FreqWarped);
578 Magn = sqrt (1 / (1 + square(eps) * square(chebyPolyVal)));
579 break;
580 }
581 break;
582
583 case kChebyshevTypeII: // Chebyshev Type 2
584 eps = 1 / sqrt(pow (10.0, wxMax(0.001, mStopbandRipple)/10.0) - 1);
585 switch (mFilterSubtype)
586 {
587 case kLowPass: // lowpass
588 default:
589 chebyPolyVal = Biquad::ChebyPoly(mOrder, CutoffWarped/FreqWarped);
590 Magn = sqrt (1 / (1 + 1 / (square(eps) * square(chebyPolyVal))));
591 break;
592 case kHighPass:
593 chebyPolyVal = Biquad::ChebyPoly(mOrder, FreqWarped/CutoffWarped);
594 Magn = sqrt (1 / (1 + 1 / (square(eps) * square(chebyPolyVal))));
595 break;
596 }
597 break;
598 }
599
600 return Magn;
601}
602
603void EffectScienFilter::OnOrder(wxCommandEvent & WXUNUSED(evt))
604{
605 mOrderIndex = mFilterOrderCtl->GetSelection();
606 mOrder = mOrderIndex + 1; // 0..n-1 -> 1..n
607 mPanel->Refresh(false);
608}
609
610void EffectScienFilter::OnFilterType(wxCommandEvent & WXUNUSED(evt))
611{
612 mFilterType = mFilterTypeCtl->GetSelection();
614 mPanel->Refresh(false);
615}
616
617void EffectScienFilter::OnFilterSubtype(wxCommandEvent & WXUNUSED(evt))
618{
619 mFilterSubtype = mFilterSubTypeCtl->GetSelection();
620 mPanel->Refresh(false);
621}
622
623void EffectScienFilter::OnCutoff(wxCommandEvent & WXUNUSED(evt))
624{
626 mUIParent, mUIParent->TransferDataFromWindow()))
627 {
628 return;
629 }
630
631 mPanel->Refresh(false);
632}
633
634void EffectScienFilter::OnRipple(wxCommandEvent & WXUNUSED(evt))
635{
637 mUIParent, mUIParent->TransferDataFromWindow()))
638 {
639 return;
640 }
641
642 mPanel->Refresh(false);
643}
644
645void EffectScienFilter::OnStopbandRipple(wxCommandEvent & WXUNUSED(evt))
646{
648 mUIParent, mUIParent->TransferDataFromWindow()))
649 {
650 return;
651 }
652
653 mPanel->Refresh(false);
654}
655
656void EffectScienFilter::OnSliderDBMIN(wxCommandEvent & WXUNUSED(evt))
657{
659}
660
661void EffectScienFilter::OnSliderDBMAX(wxCommandEvent & WXUNUSED(evt))
662{
664}
665
666void EffectScienFilter::OnSize(wxSizeEvent & evt)
667{
668 // On Windows the Passband and Stopband boxes do not refresh properly
669 // on a resize...no idea why.
670 mUIParent->Refresh();
671 evt.Skip();
672}
673
675{
676 bool ripple;
677 bool stop;
678
679 if (FilterType == kButterworth) // Butterworth
680 {
681 ripple = false;
682 stop = false;
683 }
684 else if (FilterType == kChebyshevTypeI) // Chebyshev Type1
685 {
686 ripple = true;
687 stop = false;
688 }
689 else // Chebyshev Type2
690 {
691 ripple = false;
692 stop = true;
693 }
694
695 mRippleCtlP->Enable(ripple);
696 mRippleCtl->Enable(ripple);
697 mRippleCtlU->Enable(ripple);
698 mStopbandRippleCtlP->Enable(stop);
699 mStopbandRippleCtl->Enable(stop);
700 mStopbandRippleCtlU->Enable(stop);
701}
702
703//----------------------------------------------------------------------------
704// EffectScienFilterPanel
705//----------------------------------------------------------------------------
706
707BEGIN_EVENT_TABLE(EffectScienFilterPanel, wxPanelWrapper)
711
713 wxWindow *parent, wxWindowID winid,
714 EffectScienFilter *effect, double lo, double hi)
715: wxPanelWrapper(parent, winid, wxDefaultPosition, wxSize(400, 200))
716{
717 mEffect = effect;
718 mParent = parent;
719
720 mBitmap = NULL;
721 mWidth = 0;
722 mHeight = 0;
723 mLoFreq = 0.0;
724 mHiFreq = 0.0;
725 mDbMin = 0.0;
726 mDbMax = 0.0;
727
728 SetFreqRange(lo, hi);
729}
730
732{
733}
734
735void EffectScienFilterPanel::SetFreqRange(double lo, double hi)
736{
737 mLoFreq = lo;
738 mHiFreq = hi;
739 Refresh(false);
740}
741
743{
744 mDbMin = min;
745 mDbMax = max;
746 Refresh(false);
747}
748
750{
751 return false;
752}
753
755{
756 return false;
757}
758
759void EffectScienFilterPanel::OnSize(wxSizeEvent & WXUNUSED(evt))
760{
761 Refresh(false);
762}
763
764void EffectScienFilterPanel::OnPaint(wxPaintEvent & WXUNUSED(evt))
765{
766 wxPaintDC dc(this);
767 int width, height;
768 GetSize(&width, &height);
769
770 if (!mBitmap || mWidth != width || mHeight != height)
771 {
772 mWidth = width;
773 mHeight = height;
774 mBitmap = std::make_unique<wxBitmap>(mWidth, mHeight,24);
775 }
776
777 wxBrush bkgndBrush(wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE));
778
779 wxMemoryDC memDC;
780 memDC.SelectObject(*mBitmap);
781
782 wxRect bkgndRect;
783 bkgndRect.x = 0;
784 bkgndRect.y = 0;
785 bkgndRect.width = mWidth;
786 bkgndRect.height = mHeight;
787 memDC.SetBrush(bkgndBrush);
788 memDC.SetPen(*wxTRANSPARENT_PEN);
789 memDC.DrawRectangle(bkgndRect);
790
791 bkgndRect.y = mHeight;
792 memDC.DrawRectangle(bkgndRect);
793
794 wxRect border;
795 border.x = 0;
796 border.y = 0;
797 border.width = mWidth;
798 border.height = mHeight;
799
800 memDC.SetBrush(*wxWHITE_BRUSH);
801 memDC.SetPen(*wxBLACK_PEN);
802 memDC.DrawRectangle(border);
803
804 mEnvRect = border;
805 mEnvRect.Deflate(2, 2);
806
807 // Pure blue x-axis line
808 memDC.SetPen(wxPen(theTheme.Colour(clrGraphLines), 1, wxPENSTYLE_SOLID));
809 int center = (int) (mEnvRect.height * mDbMax / (mDbMax - mDbMin) + 0.5);
810 AColor::Line(memDC,
811 mEnvRect.GetLeft(), mEnvRect.y + center,
812 mEnvRect.GetRight(), mEnvRect.y + center);
813
814 //Now draw the actual response that you will get.
815 //mFilterFunc has a linear scale, window has a log one so we have to fiddle about
816 memDC.SetPen(wxPen(theTheme.Colour(clrResponseLines), 3, wxPENSTYLE_SOLID));
817 double scale = (double) mEnvRect.height / (mDbMax - mDbMin); // pixels per dB
818 double yF; // gain at this freq
819
820 double loLog = log10(mLoFreq);
821 double step = log10(mHiFreq) - loLog;
822 step /= ((double) mEnvRect.width - 1.0);
823 double freq; // actual freq corresponding to x position
824 int x, y, xlast = 0, ylast = 0;
825 for (int i = 0; i < mEnvRect.width; i++)
826 {
827 x = mEnvRect.x + i;
828 freq = pow(10.0, loLog + i * step); //Hz
829 yF = mEffect->FilterMagnAtFreq (freq);
830 yF = LINEAR_TO_DB(yF);
831
832 if (yF < mDbMin)
833 {
834 yF = mDbMin;
835 }
836
837 yF = center-scale * yF;
838 if (yF > mEnvRect.height)
839 {
840 yF = (double) mEnvRect.height - 1.0;
841 }
842 if (yF < 0.0)
843 {
844 yF = 0.0;
845 }
846 y = (int) (yF + 0.5);
847
848 if (i != 0 && (y < mEnvRect.height - 1 || ylast < mEnvRect.y + mEnvRect.height - 1))
849 {
850 AColor::Line(memDC, xlast, ylast, x, mEnvRect.y + y);
851 }
852 xlast = x;
853 ylast = mEnvRect.y + y;
854 }
855
856 memDC.SetPen(*wxBLACK_PEN);
857 mEffect->mfreqRuler->ruler.DrawGrid(memDC, mEnvRect.height + 2, true, true, 0, 1);
858 mEffect->mdBRuler->ruler.DrawGrid(memDC, mEnvRect.width + 2, true, true, 1, 2);
859
860 dc.Blit(0, 0, mWidth, mHeight, &memDC, 0, 0, wxCOPY, FALSE);
861
862 memDC.SelectObject(wxNullBitmap);
863}
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:562
#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:91
double mProjectRate
Definition: EffectBase.h:112
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:534
void GetMaxSize(wxCoord *width, wxCoord *height)
Definition: Ruler.cpp:616
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:630
wxColour & Colour(int iIndex)
auto Selected() -> TrackIterRange< TrackType >
Definition: Track.h:1108
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:220
BuiltinCommandsModule::Registration< CompareAudioCommand > reg
__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