root / gnuradio-core / src / lib / general / gr_phase_modulator_fc.cc @ 2cc26e4d
History | View | Annotate | Download (1.8 kB)
| 1 | 5d69a524 | jcorgan | /* -*- c++ -*- */
|
|---|---|---|---|
| 2 | 5d69a524 | jcorgan | /*
|
| 3 | 0a9b999b | Eric Blossom | * Copyright 2005,2006,2010 Free Software Foundation, Inc. |
| 4 | 5d69a524 | jcorgan | * |
| 5 | 5d69a524 | jcorgan | * This file is part of GNU Radio |
| 6 | 5d69a524 | jcorgan | * |
| 7 | 5d69a524 | jcorgan | * GNU Radio is free software; you can redistribute it and/or modify |
| 8 | 5d69a524 | jcorgan | * it under the terms of the GNU General Public License as published by |
| 9 | 937b719d | eb | * the Free Software Foundation; either version 3, or (at your option) |
| 10 | 5d69a524 | jcorgan | * any later version. |
| 11 | 5d69a524 | jcorgan | * |
| 12 | 5d69a524 | jcorgan | * GNU Radio is distributed in the hope that it will be useful, |
| 13 | 5d69a524 | jcorgan | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | 5d69a524 | jcorgan | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | 5d69a524 | jcorgan | * GNU General Public License for more details. |
| 16 | 5d69a524 | jcorgan | * |
| 17 | 5d69a524 | jcorgan | * You should have received a copy of the GNU General Public License |
| 18 | 5d69a524 | jcorgan | * along with GNU Radio; see the file COPYING. If not, write to |
| 19 | 86f5c924 | eb | * the Free Software Foundation, Inc., 51 Franklin Street, |
| 20 | 86f5c924 | eb | * Boston, MA 02110-1301, USA. |
| 21 | 5d69a524 | jcorgan | */ |
| 22 | 5d69a524 | jcorgan | |
| 23 | 5d69a524 | jcorgan | #ifdef HAVE_CONFIG_H
|
| 24 | 5d69a524 | jcorgan | #include "config.h" |
| 25 | 5d69a524 | jcorgan | #endif
|
| 26 | 5d69a524 | jcorgan | |
| 27 | 5d69a524 | jcorgan | #include <gr_phase_modulator_fc.h> |
| 28 | 5d69a524 | jcorgan | #include <gr_io_signature.h> |
| 29 | 5d69a524 | jcorgan | #include <gr_sincos.h> |
| 30 | 5d69a524 | jcorgan | #include <math.h> |
| 31 | 5d69a524 | jcorgan | |
| 32 | 5d69a524 | jcorgan | |
| 33 | 5d69a524 | jcorgan | gr_phase_modulator_fc_sptr gr_make_phase_modulator_fc (double sensitivity)
|
| 34 | 5d69a524 | jcorgan | {
|
| 35 | 0a9b999b | Eric Blossom | return gnuradio::get_initial_sptr(new gr_phase_modulator_fc (sensitivity)); |
| 36 | 5d69a524 | jcorgan | } |
| 37 | 5d69a524 | jcorgan | |
| 38 | 5d69a524 | jcorgan | gr_phase_modulator_fc::gr_phase_modulator_fc (double sensitivity)
|
| 39 | 5d69a524 | jcorgan | : gr_sync_block ("phase_modulator_fc",
|
| 40 | 5d69a524 | jcorgan | gr_make_io_signature (1, 1, sizeof (float)), |
| 41 | 5d69a524 | jcorgan | gr_make_io_signature (1, 1, sizeof (gr_complex))), |
| 42 | 5d69a524 | jcorgan | d_sensitivity (sensitivity), d_phase (0)
|
| 43 | 5d69a524 | jcorgan | {
|
| 44 | 5d69a524 | jcorgan | } |
| 45 | 5d69a524 | jcorgan | |
| 46 | 5d69a524 | jcorgan | int
|
| 47 | 5d69a524 | jcorgan | gr_phase_modulator_fc::work (int noutput_items,
|
| 48 | 5d69a524 | jcorgan | gr_vector_const_void_star &input_items, |
| 49 | 5d69a524 | jcorgan | gr_vector_void_star &output_items) |
| 50 | 5d69a524 | jcorgan | {
|
| 51 | 5d69a524 | jcorgan | const float *in = (const float *) input_items[0]; |
| 52 | 5d69a524 | jcorgan | gr_complex *out = (gr_complex *) output_items[0];
|
| 53 | 5d69a524 | jcorgan | |
| 54 | 5d69a524 | jcorgan | for (int i = 0; i < noutput_items; i++){ |
| 55 | 5d69a524 | jcorgan | d_phase = d_sensitivity * in[i]; |
| 56 | 5d69a524 | jcorgan | float oi, oq;
|
| 57 | 5d69a524 | jcorgan | gr_sincosf (d_phase, &oq, &oi); |
| 58 | 5d69a524 | jcorgan | out[i] = gr_complex (oi, oq); |
| 59 | 5d69a524 | jcorgan | } |
| 60 | 5d69a524 | jcorgan | |
| 61 | 5d69a524 | jcorgan | return noutput_items;
|
| 62 | 5d69a524 | jcorgan | } |