summaryrefslogtreecommitdiff
path: root/gr-filter/lib/firdes.cc
diff options
context:
space:
mode:
Diffstat (limited to 'gr-filter/lib/firdes.cc')
-rw-r--r--gr-filter/lib/firdes.cc81
1 files changed, 3 insertions, 78 deletions
diff --git a/gr-filter/lib/firdes.cc b/gr-filter/lib/firdes.cc
index dd3c124565..93dfec5bc8 100644
--- a/gr-filter/lib/firdes.cc
+++ b/gr-filter/lib/firdes.cc
@@ -31,27 +31,13 @@ using std::vector;
namespace gr {
namespace filter {
-
-#define IzeroEPSILON 1E-21 /* Max error acceptable in Izero */
- static double Izero(double x)
+ std::vector<float>
+ firdes::window(win_type type, int ntaps, double beta)
{
- double sum, u, halfx, temp;
- int n;
-
- sum = u = n = 1;
- halfx = x/2.0;
- do {
- temp = halfx/(double)n;
- n += 1;
- temp *= temp;
- u *= temp;
- sum += u;
- } while (u >= IzeroEPSILON*sum);
- return(sum);
+ return fft::window::build(static_cast<fft::window::win_type>(type), ntaps, beta);
}
-
//
// === Low Pass ===
//
@@ -736,67 +722,6 @@ namespace gr {
return ans;
}
- vector<float>
- firdes::window (win_type type, int ntaps, double beta)
- {
- vector<float> taps(ntaps);
- int M = ntaps - 1; // filter order
-
- switch (type) {
- case WIN_RECTANGULAR:
- for(int n = 0; n < ntaps; n++)
- taps[n] = 1;
- break;
-
- case WIN_HAMMING:
- for(int n = 0; n < ntaps; n++)
- taps[n] = 0.54 - 0.46 * cos((2 * M_PI * n) / M);
- break;
-
- case WIN_HANN:
- for(int n = 0; n < ntaps; n++)
- taps[n] = 0.5 - 0.5 * cos((2 * M_PI * n) / M);
- break;
-
- case WIN_BLACKMAN:
- for(int n = 0; n < ntaps; n++)
- taps[n] = 0.42 - 0.50 * cos((2*M_PI * n) / M)
- + 0.08 * cos((4*M_PI * n) / M);
- break;
-
- case WIN_BLACKMAN_hARRIS:
- for(int n = -ntaps/2; n < ntaps/2; n++)
- taps[n+ntaps/2] = 0.35875 + 0.48829*cos((2*M_PI * n) / (float)M) +
- 0.14128*cos((4*M_PI * n) / (float)M) + 0.01168*cos((6*M_PI * n) / (float)M);
- break;
-
- case WIN_KAISER:
- {
- double IBeta = 1.0/Izero(beta);
- double inm1 = 1.0/((double)(ntaps-1));
- double temp;
-
- for(int i = 0; i <= ntaps; i++) {
- temp = 2*i*inm1 - 1;
- taps[i] = Izero(beta*sqrt(1.0-temp*temp)) * IBeta;
- }
- }
- break;
-
- case WIN_BARTLETT:
- for(int n = 0; n <= ntaps/2; n++)
- taps[n] = 2*n / (float)M;
- for(int n = ntaps/2 + 1; n < ntaps; n++)
- taps[n] = 2 - 2*n / (float)M;
- break;
-
- default:
- throw std::out_of_range("firdes:window: type out of range");
- }
-
- return taps;
- }
-
void
firdes::sanity_check_1f(double sampling_freq,
double fa, // cutoff freq