2 * Copyright 2004,2006,2007 Free Software Foundation, Inc.
4 * This file is part of GNU Radio
6 * GNU Radio is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3, or (at your option)
11 * GNU Radio is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with GNU Radio; see the file COPYING. If not, write to
18 * the Free Software Foundation, Inc., 51 Franklin Street,
19 * Boston, MA 02110-1301, USA.
26 #include <pager_slicer_fb.h>
27 #include <gr_io_signature.h>
29 pager_slicer_fb_sptr pager_make_slicer_fb(float alpha)
31 return pager_slicer_fb_sptr(new pager_slicer_fb(alpha));
34 pager_slicer_fb::pager_slicer_fb(float alpha) :
35 gr_sync_block ("slicer_fb",
36 gr_make_io_signature (1, 1, sizeof(float)),
37 gr_make_io_signature (1, 1, sizeof(unsigned char)))
44 // Tracks average, minimum, and peak, then converts input into one of:
47 unsigned char pager_slicer_fb::slice(float sample)
49 unsigned char decision;
51 // Update DC level and remove
52 d_avg = d_avg*d_beta+sample*d_alpha;
71 int pager_slicer_fb::work(int noutput_items,
72 gr_vector_const_void_star &input_items,
73 gr_vector_void_star &output_items)
75 float *iptr = (float *) input_items[0];
76 unsigned char *optr = (unsigned char *) output_items[0];
78 int size = noutput_items;
80 for (int i = 0; i < size; i++)
81 *optr++ = slice(*iptr++);