[Kst] kdeextragear-2/kst/plugins/pass_filters

Andrew Walker arwalker at sumusltd.com
Fri Oct 15 21:04:50 CEST 2004


CVS commit by arwalker: 

Make the bandstop the inverse of Barth's bandpass filter.


  M +5 -5      butterworth_bandpass/butterworth_bandpass.cpp   1.6
  M +13 -5     butterworth_bandstop/butterworth_bandstop.cpp   1.5


--- kdeextragear-2/kst/plugins/pass_filters/butterworth_bandstop/butterworth_bandstop.cpp  #1.4:1.5
@@ -34,7 +34,15 @@ double filter_calculate( double dFreqVal
   double dValue;
   
-  dValue  = dFreqValue * inScalars[2];
-  dValue /= ( (dFreqValue * dFreqValue) - (inScalars[1] * inScalars[1]) );
-  dValue  = 1.0 / ( 1.0 + pow( dValue, 2.0 * (double)inScalars[0] ) ); 
+  int order2 = int(2.0 * inScalars[0]);
+  double lowpass  = inScalars[1] + 0.5*inScalars[2];
+  double highpass = inScalars[1] - 0.5*inScalars[2];
+
+  if( dFreqValue > 0.0 ) {
+    dValue = 1.0 / ( 1.0 + gsl_pow_int( dFreqValue / lowpass, order2) );
+    dValue *= 1.0 / ( 1.0 + gsl_pow_int( highpass / dFreqValue, order2) );
+    dValue = 1.0 - dValue;
+  } else {
+    dValue = 0.0;
+  }
   
   return dValue;

--- kdeextragear-2/kst/plugins/pass_filters/butterworth_bandpass/butterworth_bandpass.cpp  #1.5:1.6
@@ -35,11 +35,11 @@ double filter_calculate( double dFreqVal
   double dValue;
 
-  int order2 = int(2.0*inScalars[0]);
-  double lp = inScalars[1] + 0.5*inScalars[2];
-  double hp = lp - inScalars[2];
+  int order2 = int(2.0 * inScalars[0]);
+  double lowpass  = inScalars[1] + 0.5*inScalars[2];
+  double highpass = inScalars[1] - 0.5*inScalars[2];
 
   if( dFreqValue > 0.0 ) {
-    dValue = 1.0 / ( 1.0 + gsl_pow_int( dFreqValue / lp, order2) );
-    dValue *= 1.0 / ( 1.0 + gsl_pow_int( hp / dFreqValue, order2) );
+    dValue = 1.0 / ( 1.0 + gsl_pow_int( dFreqValue / lowpass, order2) );
+    dValue *= 1.0 / ( 1.0 + gsl_pow_int( highpass / dFreqValue, order2) );
   } else {
     dValue = 0.0;





More information about the Kst mailing list