Main Page | Modules | Namespace List | Class Hierarchy | Class List | Directories | File List | Class Members | File Members

GrSSBMod.h

Go to the documentation of this file.
00001 /* -*- Mode: c++ -*- */
00002 /*
00003  * Copyright 2001 Free Software Foundation, Inc.
00004  * 
00005  * This file is part of GNU Radio
00006  * 
00007  * GNU Radio is free software; you can redistribute it and/or modify
00008  * it under the terms of the GNU General Public License as published by
00009  * the Free Software Foundation; either version 2, or (at your option)
00010  * any later version.
00011  * 
00012  * GNU Radio is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  * 
00017  * You should have received a copy of the GNU General Public License
00018  * along with GNU Radio; see the file COPYING.  If not, write to
00019  * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00020  * Boston, MA 02111-1307, USA.
00021  */
00022 
00023 
00024 #ifndef _GRSSBMOD_H_
00025 #define _GRSSBMOD_H_
00026 
00027 #include <VrSigProc.h>
00028 #include <gr_complex.h>
00029 #include <gr_nco.h>
00030 
00031 template<class oType> 
00032 class GrSSBMod : public VrSigProc {
00033 private:
00034   gr_nco<float,float>   d_nco;
00035   double                d_gain;
00036 public: 
00037   GrSSBMod (double freq, double gain);
00038 
00039   virtual const char *name() { return "GrSSBMod"; }
00040   virtual int work(VrSampleRange output, void *o[],
00041                    VrSampleRange inputs[], void *i[]);
00042 
00043   // FIXME scale freq?
00044   void set_freq (double freq) {
00045     cerr << "set freq to " << freq << endl;
00046     d_nco.set_freq (freq);
00047   };
00048 
00049   void set_gain (double g) { d_gain = g; };
00050 };
00051 
00052 template<class oType> int
00053 GrSSBMod<oType>::work(VrSampleRange output, void *ao[],
00054                       VrSampleRange inputs[], void *ai[])
00055 {
00056   gr_complex **i = (gr_complex **)ai;
00057   oType **o = (oType **)ao;
00058   int size = output.size;
00059 
00060   for(int x = 0; x < size; x++)
00061     {
00062       *o[0]++ = (oType) ( d_gain * (i[0]->real() * d_nco.cos()
00063                                     + i[0]->imag() * d_nco.sin() ));
00064       i[0]++;
00065       d_nco.step();
00066     }
00067   return output.size;
00068 }
00069 
00070 template<class oType> 
00071 GrSSBMod<oType>::GrSSBMod (double freq, double gain)
00072   : VrSigProc(1, sizeof(gr_complex), sizeof(oType)), d_gain (gain)
00073 {
00074   // FIXME scale freq?
00075   d_nco.set_freq (freq);
00076 }
00077 
00078 #endif

Generated on Sat Sep 24 11:14:04 2005 for GNU Radio 2.x by  doxygen 1.4.4