3
* Copyright 2004 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.
23
// WARNING: this file is machine generated. Edits will be over written
28
#include <gr_sig_source_f.h>
30
#include <gr_io_signature.h>
32
#include <gr_complex.h>
35
gr_sig_source_f::gr_sig_source_f (double sampling_freq, gr_waveform_t waveform,
36
double frequency, double ampl, float offset)
37
: gr_sync_block ("sig_source_f",
38
gr_make_io_signature (0, 0, 0),
39
gr_make_io_signature (1, 1, sizeof (float))),
40
d_sampling_freq (sampling_freq), d_waveform (waveform), d_frequency (frequency),
41
d_ampl (ampl), d_offset (offset)
43
d_nco.set_freq (2 * M_PI * d_frequency / d_sampling_freq);
47
gr_make_sig_source_f (double sampling_freq, gr_waveform_t waveform,
48
double frequency, double ampl, float offset)
50
return gr_sig_source_f_sptr (new gr_sig_source_f (sampling_freq, waveform, frequency, ampl, offset));
54
gr_sig_source_f::work (int noutput_items,
55
gr_vector_const_void_star &input_items,
56
gr_vector_void_star &output_items)
58
float *optr = (float *) output_items[0];
66
t = (gr_complex) d_ampl + d_offset;
67
for (int i = 0; i < noutput_items; i++) // FIXME unroll
73
d_nco.sincos (optr, noutput_items, d_ampl);
74
if (d_offset == gr_complex(0,0))
77
for (int i = 0; i < noutput_items; i++){
85
t = (float) d_ampl + d_offset;
86
for (int i = 0; i < noutput_items; i++) // FIXME unroll
91
d_nco.sin (optr, noutput_items, d_ampl);
95
for (int i = 0; i < noutput_items; i++){
101
d_nco.cos (optr, noutput_items, d_ampl);
105
for (int i = 0; i < noutput_items; i++){
112
throw std::runtime_error ("gr_sig_source: invalid waveform");
115
return noutput_items;
119
gr_sig_source_f::set_sampling_freq (double sampling_freq)
121
d_sampling_freq = sampling_freq;
122
d_nco.set_freq (2 * M_PI * d_frequency / d_sampling_freq);
126
gr_sig_source_f::set_waveform (gr_waveform_t waveform)
128
d_waveform = waveform;
132
gr_sig_source_f::set_frequency (double frequency)
134
d_frequency = frequency;
135
d_nco.set_freq (2 * M_PI * d_frequency / d_sampling_freq);
139
gr_sig_source_f::set_amplitude (double ampl)
145
gr_sig_source_f::set_offset (float offset)