3 * Copyright 2008 Free Software Foundation, Inc.
5 * This file is part of GNU Radio
7 * GNU Radio is free software; you can redistribute it and/or modify
8 * it under the tewavelet of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3, or (at your option)
12 * GNU Radio is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with GNU Radio; see the file COPYING. If not, write to
19 * the Free Software Foundation, Inc., 51 Franklin Street,
20 * Boston, MA 02110-1301, USA.
28 #include <gr_wavelet_ff.h>
29 #include <gr_io_signature.h>
33 // NB in this version, only Daubechies wavelets
34 // order is wavelet length, even, 2...20
37 gr_make_wavelet_ff(int size,
41 return gr_wavelet_ff_sptr(new gr_wavelet_ff(size,
46 gr_wavelet_ff::gr_wavelet_ff(int size,
49 : gr_sync_block("wavelet_ff",
50 gr_make_io_signature(1, 1, size * sizeof(float)),
51 gr_make_io_signature(1, 1, size * sizeof(float))),
56 d_wavelet = gsl_wavelet_alloc(gsl_wavelet_daubechies, d_order);
57 if (d_wavelet == NULL)
58 throw std::runtime_error("can't allocate wavelet");
59 d_workspace = gsl_wavelet_workspace_alloc(d_size);
60 if (d_workspace == NULL)
61 throw std::runtime_error("can't allocate wavelet workspace");
62 d_temp = (double *) malloc(d_size*sizeof(double));
63 if (d_workspace == NULL)
64 throw std::runtime_error("can't allocate wavelet double conversion temp");
67 gr_wavelet_ff::~gr_wavelet_ff()
69 gsl_wavelet_free(d_wavelet);
70 gsl_wavelet_workspace_free(d_workspace);
71 free((char *) d_temp);
75 gr_wavelet_ff::work(int noutput_items,
76 gr_vector_const_void_star &input_items,
77 gr_vector_void_star &output_items)
79 const float *in = (const float *) input_items[0];
80 float *out = (float *) output_items[0];
82 for (int count = 0; count < noutput_items; count++) {
83 for (int i = 0; i < d_size; i++)
87 gsl_wavelet_transform_forward(d_wavelet,
93 gsl_wavelet_transform_inverse(d_wavelet,
99 for (int i = 0; i < d_size; i++)
106 return noutput_items;