diff --git a/qucs-activefilter/filter.cpp b/qucs-activefilter/filter.cpp index ccfe736d..79e56276 100644 --- a/qucs-activefilter/filter.cpp +++ b/qucs-activefilter/filter.cpp @@ -39,12 +39,16 @@ Filter::Filter(Filter::FilterFunc ffunc_, Filter::FType type_, FilterParam par) TW = par.TW; BW = fabs(Fu -Fl); F0 = sqrt(Fu*Fl); - Fc=BW; // cutoff freq. of LPF prototype - float Fs1 = Fu + TW; - float Fs1lp = fabsf(Fs1 - (F0*F0)/Fs1); // stopband freq. of LPF prototype - float Fs2 = Fl - TW; - float Fs2lp = fabsf(Fs2 - (F0*F0)/Fs2); - Fs = std::min(Fs1lp,Fs2lp); + if (ftype==Filter::BandPass) { // BandPass + Fc=BW; // cutoff freq. of LPF prototype + float Fs1 = Fu + TW; + float Fs1lp = fabsf(Fs1 - (F0*F0)/Fs1); // stopband freq. of LPF prototype + float Fs2 = Fl - TW; + float Fs2lp = fabsf(Fs2 - (F0*F0)/Fs2); + Fs = std::min(Fs1lp,Fs2lp); + } else if (ftype==Filter::BandStop) { // BandStop + + } Ap = 3.0; As = 20.0; qDebug()<calcFirstOrder(); } + +void MFBfilter::calcBandPass() +{ + float W0 = 2*M_PI*F0; + float R1,R2,R3,C1,C2; + //float rho = Kv/Q; + //float gamma = 1.0; + int cnt = 1; + + for (int k=1; k <= order/2; k++) { + float re = Poles.at(k-1).real(); + float im = Poles.at(k-1).imag(); + float B = -2.0*re; + float C = re*re + im*im; + + float H = C + 4.0*Q*Q; + float E = (1.0/B)*sqrt(0.5*(H+sqrt(H*H-(4.0*B*B*Q*Q)))); + float F = (B*E)/Q; + float D = 0.5*(F+sqrt(F*F-4.0)); + + qDebug()<