GNU Radio 3.6.0 C++ API
|
00001 /* 00002 * Copyright 2011 Free Software Foundation, Inc. 00003 * 00004 * This file is part of GNU Radio 00005 * 00006 * GNU Radio is free software; you can redistribute it and/or modify 00007 * it under the terms of the GNU General Public License as published by 00008 * the Free Software Foundation; either version 3, or (at your option) 00009 * any later version. 00010 * 00011 * GNU Radio is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 * GNU General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU General Public License 00017 * along with GNU Radio; see the file COPYING. If not, write to 00018 * the Free Software Foundation, Inc., 51 Franklin Street, 00019 * Boston, MA 02110-1301, USA. 00020 */ 00021 00022 #ifndef INCLUDED_GR_EXTRAS_SIGNAL_SOURCE_H 00023 #define INCLUDED_GR_EXTRAS_SIGNAL_SOURCE_H 00024 00025 #include <gnuradio/extras/api.h> 00026 #include <gr_sync_block.h> 00027 #include <complex> 00028 00029 namespace gnuradio{ namespace extras{ 00030 00031 /*! 00032 * \brief signal generator source 00033 * \ingroup source_blk 00034 */ 00035 class GR_EXTRAS_API signal_source : virtual public gr_sync_block{ 00036 public: 00037 typedef boost::shared_ptr<signal_source> sptr; 00038 00039 static sptr make_fc32(void); 00040 static sptr make_sc32(void); 00041 static sptr make_sc16(void); 00042 static sptr make_sc8(void); 00043 static sptr make_f32(void); 00044 static sptr make_s32(void); 00045 static sptr make_s16(void); 00046 static sptr make_s8(void); 00047 00048 //! Set the waveform type (CONST, COSINE, RAMP, SQUARE) 00049 virtual void set_waveform(const std::string &) = 0; 00050 00051 //! Get the current waveform setting 00052 virtual std::string get_waveform(void) = 0; 00053 00054 //! Set the offset, this is a free addition operation 00055 virtual void set_offset(const std::complex<double> &) = 0; 00056 00057 //! Get the current offset setting 00058 virtual std::complex<double> get_offset(void) = 0; 00059 00060 //! Set the scalar, this is a free multiply scalar operation 00061 virtual void set_amplitude(const std::complex<double> &) = 0; 00062 00063 //! Get the current amplitude setting 00064 virtual std::complex<double> get_amplitude(void) = 0; 00065 00066 //! Set the frequency, this is a fractional number between -1 and 1 00067 virtual void set_frequency(const double) = 0; 00068 00069 //! Get the actual frequency setting (-1 and 1) 00070 virtual double get_frequency(void) = 0; 00071 00072 //! Convenience call to set frequency with sample rate 00073 void set_frequency(const double samp_rate, const double wave_freq){ 00074 return this->set_frequency(wave_freq/samp_rate); 00075 } 00076 00077 //! Convenience call to get frequency with sample rate 00078 double get_frequency(const double samp_rate){ 00079 return samp_rate*this->get_frequency(); 00080 } 00081 00082 }; 00083 00084 }} 00085 00086 #endif /* INCLUDED_GR_EXTRAS_SIGNAL_SOURCE_H */