and Barrie W. Jervis, Adison-Wesley, 1993. ISBN 0-201-54413-X.
'''
-import math
+import math, cmath
from gnuradio import gr
remez = gr.remez
taps = gr.remez (n + nextra_taps, fo, ao, w, "bandpass")
return taps
+
+## Builds a band pass filter with complex taps by making an LPF and
+# spinning it up to the right center frequency
+# @param gain Filter gain in the passband (linear)
+# @param Fs Sampling rate (sps)
+# @param freq1 End of stop band (in Hz)
+# @param freq2 Start of pass band (in Hz)
+# @param passband_ripple_db Pass band ripple in dB (should be small, < 1)
+# @param stopband_atten_db Stop band attenuation in dB (should be large, >= 60)
+# @param nextra_taps Extra taps to use in the filter (default=2)
+def complex_band_pass (gain, Fs, freq_sb1, freq_pb1, freq_pb2, freq_sb2,
+ passband_ripple_db, stopband_atten_db,
+ nextra_taps=2):
+ center_freq = (freq_pb2 + freq_pb1) / 2.0
+ lp_pb = (freq_pb2 - center_freq)/1.0
+ lp_sb = freq_sb2 - center_freq
+ lptaps = low_pass(gain, Fs, lp_pb, lp_sb, passband_ripple_db,
+ stopband_atten_db, nextra_taps)
+ spinner = [cmath.exp(2j*cmath.pi*center_freq/Fs*i) for i in xrange(len(lptaps))]
+ taps = [s*t for s,t in zip(spinner, lptaps)]
+ return taps
+
+
## Builds a high pass filter.
# @param gain Filter gain in the passband (linear)
# @param Fs Sampling rate (sps)
from scipy import fftpack
from pyqt_filter import Ui_MainWindow
-from pyqt_filter_firlpf import Ui_firlpfForm
-from pyqt_filter_firhpf import Ui_firhpfForm
class gr_plot_filter(QtGui.QMainWindow):
def __init__(self, qapp, options):
if(winstr == "Equiripple"):
designer = {"Low Pass" : self.design_opt_lpf,
"Band Pass" : self.design_opt_bpf,
- "High Pass" : self.design_opt_hpf}
+ "Complex Band Pass" : self.design_opt_cbpf,
+ "High Pass" : self.design_opt_hpf}
taps,r = designer[ftype](fs, gain)
else:
else:
return ([],r)
+ def design_opt_cbpf(self, fs, gain, wintype=None):
+ ret = True
+ pb1,r = self.gui.startofBpfPassBandEdit.text().toDouble()
+ ret = r and ret
+ pb2,r = self.gui.endofBpfPassBandEdit.text().toDouble()
+ ret = r and ret
+ tb,r = self.gui.bpfTransitionEdit.text().toDouble()
+ ret = r and ret
+ atten,r = self.gui.bpfStopBandAttenEdit.text().toDouble()
+ ret = r and ret
+ ripple,r = self.gui.bpfPassBandRippleEdit.text().toDouble()
+ ret = r and ret
+
+ if(r):
+ sb1 = pb1 - tb
+ sb2 = pb2 + tb
+ taps = blks2.optfir.complex_band_pass(gain, fs, sb1, pb1, pb2, sb2,
+ ripple, atten)
+ return (taps,r)
+ else:
+ return ([],r)
+
def design_opt_hpf(self, fs, gain, wintype=None):
ret = True
sb,r = self.gui.endofHpfStopBandEdit.text().toDouble()