[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] r11537 - in gnuradio/trunk/gnuradio-core/src: lib/gene
From: |
trondeau |
Subject: |
[Commit-gnuradio] r11537 - in gnuradio/trunk/gnuradio-core/src: lib/general python/gnuradio |
Date: |
Tue, 4 Aug 2009 19:36:09 -0600 (MDT) |
Author: trondeau
Date: 2009-08-04 19:36:09 -0600 (Tue, 04 Aug 2009)
New Revision: 11537
Modified:
gnuradio/trunk/gnuradio-core/src/lib/general/gr_remez.cc
gnuradio/trunk/gnuradio-core/src/python/gnuradio/optfir.py
Log:
Fixed optfir for producing equiripple FIR filters. Does LPF, fixes the HPF, and
adds BPF (real).
Modified: gnuradio/trunk/gnuradio-core/src/lib/general/gr_remez.cc
===================================================================
--- gnuradio/trunk/gnuradio-core/src/lib/general/gr_remez.cc 2009-08-04
21:52:34 UTC (rev 11536)
+++ gnuradio/trunk/gnuradio-core/src/lib/general/gr_remez.cc 2009-08-05
01:36:09 UTC (rev 11537)
@@ -814,8 +814,10 @@
if (arg_bands[0] < 0 || arg_bands[arg_bands.size () - 1] > 1)
punt ("gr_remez: band edges must be in the range [0,1]");
+ // Divide by 2 to fit with the implementation that uses a
+ // sample rate of [0, 0.5] instead of [0, 1.0]
for (int i = 0; i < 2 * numbands; i++)
- bands[i] = arg_bands[i] / 2; // FIXME why / 2?
+ bands[i] = arg_bands[i] / 2;
LOCAL_BUFFER (double, response, numbands * 2);
if (arg_response.size () != arg_bands.size ())
Modified: gnuradio/trunk/gnuradio-core/src/python/gnuradio/optfir.py
===================================================================
--- gnuradio/trunk/gnuradio-core/src/python/gnuradio/optfir.py 2009-08-04
21:52:34 UTC (rev 11536)
+++ gnuradio/trunk/gnuradio-core/src/python/gnuradio/optfir.py 2009-08-05
01:36:09 UTC (rev 11537)
@@ -1,5 +1,5 @@
#
-# Copyright 2004,2005 Free Software Foundation, Inc.
+# Copyright 2004,2005,2009 Free Software Foundation, Inc.
#
# This file is part of GNU Radio
#
@@ -34,25 +34,68 @@
# ----------------------------------------------------------------
+## Builds a low pass filter.
+# @param gain Filter gain in the passband (linear)
+# @param Fs Sampling rate (sps)
+# @param freq1 End of pass band (in Hz)
+# @param freq2 Start of stop 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 low_pass (gain, Fs, freq1, freq2, passband_ripple_db, stopband_atten_db,
- nextra_taps=0):
+ nextra_taps=2):
passband_dev = passband_ripple_to_dev (passband_ripple_db)
stopband_dev = stopband_atten_to_dev (stopband_atten_db)
desired_ampls = (gain, 0)
(n, fo, ao, w) = remezord ([freq1, freq2], desired_ampls,
[passband_dev, stopband_dev], Fs)
+ # The remezord typically under-estimates the filter order, so add 2 taps
by default
taps = gr.remez (n + nextra_taps, fo, ao, w, "bandpass")
return taps
-# FIXME high_passs is broken...
-def high_pass (Fs, freq1, freq2, stopband_atten_db, passband_ripple_db,
- nextra_taps=0):
- """FIXME: broken"""
+## Builds a band pass filter.
+# @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 band_pass (gain, Fs, freq_sb1, freq_pb1, freq_pb2, freq_sb2,
+ passband_ripple_db, stopband_atten_db,
+ nextra_taps=2):
passband_dev = passband_ripple_to_dev (passband_ripple_db)
stopband_dev = stopband_atten_to_dev (stopband_atten_db)
+ desired_ampls = (0, gain, 0)
+ desired_freqs = [freq_sb1, freq_pb1, freq_pb2, freq_sb2]
+ desired_ripple = [stopband_dev, passband_dev, stopband_dev]
+ (n, fo, ao, w) = remezord (desired_freqs, desired_ampls,
+ desired_ripple, Fs)
+ # The remezord typically under-estimates the filter order, so add 2 taps
by default
+ taps = gr.remez (n + nextra_taps, fo, ao, w, "bandpass")
+ return taps
+
+## Builds a high pass filter.
+# @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 high_pass (gain, Fs, freq1, freq2, passband_ripple_db, stopband_atten_db,
+ nextra_taps=2):
+ passband_dev = passband_ripple_to_dev (passband_ripple_db)
+ stopband_dev = stopband_atten_to_dev (stopband_atten_db)
desired_ampls = (0, 1)
(n, fo, ao, w) = remezord ([freq1, freq2], desired_ampls,
[stopband_dev, passband_dev], Fs)
+ # For a HPF, we need to use an odd number of taps
+ # In gr.remez, ntaps = n+1, so n must be even
+ if((n+nextra_taps)%2 == 1):
+ n += 1
+
+ # The remezord typically under-estimates the filter order, so add 2 taps
by default
taps = gr.remez (n + nextra_taps, fo, ao, w, "bandpass")
return taps
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Commit-gnuradio] r11537 - in gnuradio/trunk/gnuradio-core/src: lib/general python/gnuradio,
trondeau <=