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 terms 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_fmdet_cf.h>
29 #include <gr_io_signature.h>
33 #define M_TWOPI (2*M_PI)
36 gr_make_fmdet_cf (float samplerate, float freq_low, float freq_high, float scl)
38 return gr_fmdet_cf_sptr (new gr_fmdet_cf (samplerate, freq_low, freq_high, scl));
41 gr_fmdet_cf::gr_fmdet_cf (float samplerate, float freq_low, float freq_high, float scl)
42 : gr_sync_block ("fmdet_cf",
43 gr_make_io_signature (1, 1, sizeof (gr_complex)),
44 gr_make_io_signature (1, 1, sizeof (float))),
51 delta = (d_freqhi - d_freqlo);
53 d_bias = 0.5*scl*(d_freqhi+d_freqlo)/delta;
57 gr_fmdet_cf::work (int noutput_items,
58 gr_vector_const_void_star &input_items,
59 gr_vector_void_star &output_items)
61 const gr_complex *iptr = (gr_complex *) input_items[0];
62 float *optr = (float *) output_items[0];
64 int size = noutput_items;
66 gr_complex Sdot,S0,S1=d_S1,S2=d_S2,S3=d_S3,S4=d_S4;
71 Sdot = gr_complex(d_scl*
72 (-S0.real() + 8.0*S1.real() - 8.0*S3.real() + S4.real()),
74 (-S0.imag() + 8.0*S1.imag() - 8.0*S3.imag() + S4.imag()));
75 d_freq = (S2.real()*Sdot.imag()-S2.imag()*Sdot.real())/
76 (S2.real()*S2.real()+S2.imag()*S2.imag());
84 *optr++ = d_freq-d_bias;