aboutsummaryrefslogtreecommitdiffstats
path: root/gr-fft
diff options
context:
space:
mode:
authorJacob Gilbert <mrjacobagilbert@gmail.com>2020-04-25 20:56:08 -0600
committermormj <34754695+mormj@users.noreply.github.com>2020-04-26 11:17:00 -0400
commit9e678e4b7d0c8d914470d6be22413df27e5badb0 (patch)
tree9977cf2cb477b5a16109c4e0236acbf42ecd2071 /gr-fft
parentgr-fft: added documentation for flat top window design (diff)
downloadgnuradio-9e678e4b7d0c8d914470d6be22413df27e5badb0.tar.xz
gnuradio-9e678e4b7d0c8d914470d6be22413df27e5badb0.zip
fft: added gaussian window
and updated the docs for gaussian and tukey windows
Diffstat (limited to 'gr-fft')
-rw-r--r--gr-fft/include/gnuradio/fft/window.h15
-rw-r--r--gr-fft/lib/window.cc16
2 files changed, 31 insertions, 0 deletions
diff --git a/gr-fft/include/gnuradio/fft/window.h b/gr-fft/include/gnuradio/fft/window.h
index 9fc15c123..8cc6a5d9b 100644
--- a/gr-fft/include/gnuradio/fft/window.h
+++ b/gr-fft/include/gnuradio/fft/window.h
@@ -300,6 +300,10 @@ public:
/*!
* \brief Build a Tukey window.
+ * <pre>
+ * Bloomfield, P. Fourier Analysis of Time Series: An Introduction. New York:
+ * Wiley-Interscience, 2000, pp 69 (eqn 6.9)
+ * </pre>
*
* \param ntaps Number of coefficients in the window.
* \param alpha Shaping parameter for the Tukey window, an
@@ -309,6 +313,17 @@ public:
static std::vector<float> tukey(int ntaps, float alpha);
/*!
+ * \brief Build a Gaussian window using the equation
+ * <pre>
+ * exp(-(1/2) * (n/sigma)^2)
+ * </pre>
+ *
+ * \param ntaps Number of coefficients in the window.
+ * \param sigma Standard deviation of gaussian distribution.
+ */
+ static std::vector<float> gaussian(int ntaps, float sigma);
+
+ /*!
* \brief Build a window using gr::fft::win_type to index the
* type of window desired.
*
diff --git a/gr-fft/lib/window.cc b/gr-fft/lib/window.cc
index 8b0a07f43..430b435bd 100644
--- a/gr-fft/lib/window.cc
+++ b/gr-fft/lib/window.cc
@@ -339,6 +339,22 @@ std::vector<float> window::tukey(int ntaps, float a)
return taps;
}
+std::vector<float> window::gaussian(int ntaps, float sigma)
+{
+ if (sigma <= 0)
+ throw std::out_of_range("window::gaussian: sigma must be > 0");
+
+ float a = 2 * sigma * sigma;
+ double m1 = midm1(ntaps);
+ std::vector<float> taps(ntaps);
+ for (int i = 0; i < midn(ntaps); i++) {
+ float N = (i - m1);
+ taps[i] = exp(-(N * N / a));
+ taps[ntaps - 1 - i] = taps[i];
+ }
+ return taps;
+}
+
std::vector<float> window::build(win_type type, int ntaps, double beta)
{
switch (type) {