Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

GrWeaverModTail.h

Go to the documentation of this file.
00001 /* -*- c++ -*- */
00002 /*
00003  * Copyright 2002 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 #ifndef _GRWEAVERMODTAIL_H_
00023 #define _GRWEAVERMODTAIL_H_
00024 
00025 #include <assert.h>
00026 
00041 template<class iType, class oType>
00042 class GrWeaverModTail : public VrSigProc {
00043 
00044 public:
00045   GrWeaverModTail (float freq, float gain);
00046 
00047   virtual const char *name () { return "GrWeaverModTail"; }
00048 
00049   virtual int work (VrSampleRange output, void *o[],
00050                     VrSampleRange inputs[], void *i[]);
00051 
00053   void set_freq (float frequency) { freq = frequency; }
00054   void set_gain (float g)    { gain = g; }
00055 
00056 protected:
00057   gr_nco<float,float>   nco;
00058   float                 gain;
00059   float                 freq;
00060 };
00061 
00062 template<class iType, class oType> 
00063 GrWeaverModTail<iType,oType>::GrWeaverModTail (float freq, float gain)
00064   : VrSigProc(1, sizeof(iType), sizeof(oType)), gain(gain), freq(freq)
00065 {
00066 }
00067 
00068 template<class iType, class oType> int
00069 GrWeaverModTail<iType, oType>::work(VrSampleRange output, void *ao[],
00070                                     VrSampleRange inputs[], void *ai[])
00071 {
00072   assert (numberInputs == 2);
00073 
00074   iType *i = ((iType **) ai)[0];
00075   iType *q = ((iType **) ai)[1];
00076   oType *o = ((oType **) ao)[0];
00077   long size = output.size;
00078 
00079   sync (output.index);
00080 
00081   nco.set_freq (freq / getSamplingFrequency () * 2 * M_PI);
00082 
00083   for (long n = 0; n < size; n++) {
00084     float       cosv, sinv;
00085     nco.cossin (cosv, sinv);    // compute them at the same time (faster!)
00086     o[n] = (oType) (gain * (i[n] * cosv + q[n] * sinv));
00087     nco.step();
00088   }
00089   return output.size;
00090 }
00091 
00092 #endif /* _GRWEAVERMODTAIL_H_ */

Generated on Tue Mar 15 23:48:04 2005 for GNU Radio by  doxygen 1.4.0