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

VrQuadratureDemod.h

Go to the documentation of this file.
00001 /* -*- Mode: c++ -*- 
00002  *
00003  *  Copyright 1997 Massachusetts Institute of Technology
00004  * 
00005  *  Permission to use, copy, modify, distribute, and sell this software and its
00006  *  documentation for any purpose is hereby granted without fee, provided that
00007  *  the above copyright notice appear in all copies and that both that
00008  *  copyright notice and this permission notice appear in supporting
00009  *  documentation, and that the name of M.I.T. not be used in advertising or
00010  *  publicity pertaining to distribution of the software without specific,
00011  *  written prior permission.  M.I.T. makes no representations about the
00012  *  suitability of this software for any purpose.  It is provided "as is"
00013  *  without express or implied warranty.
00014  * 
00015  */
00016 
00017 
00018 #ifndef _VRQUADRATUREDEMOD_H_
00019 #define _VRQUADRATUREDEMOD_H_
00020 
00021 #include <VrHistoryProc.h>
00022 #include <math.h>
00023 
00024 template<class oType> 
00025 class VrQuadratureDemod : public VrHistoryProc<complex,oType> {
00026 protected:
00027   float gain;
00028 public:
00029   virtual const char *name() { return "VrQuadratureDemod"; }
00030   void setGain(float g){ gain = g; return;}
00031   virtual int work(VrSampleRange output, void *o[],
00032                    VrSampleRange inputs[], void *i[]);
00033   virtual void initialize();
00034   VrQuadratureDemod(oType g);
00035   VrQuadratureDemod();
00036 };
00037 
00038 template<class oType> int
00039 VrQuadratureDemod<oType>::work(VrSampleRange output, void *ao[],
00040                                 VrSampleRange inputs[], void *ai[])
00041 {
00042   complex **i = (complex **)ai;
00043   oType **o = (oType **)ao;
00044   complex product,val;
00045   complex lastVal = *i[0]++;
00046   unsigned int size=output.size;
00047 
00048   for (; size>0; i[0]++,size--) {
00049     val = *i[0];
00050     product = val * conj(lastVal);
00051     lastVal = val;
00052     *o[0]++=(oType)(gain * arg(product));
00053   }
00054   return output.size;
00055 }
00056 
00057 template<class oType> void
00058 VrQuadratureDemod<oType>::initialize()
00059 {
00060   history=2;
00061 }
00062 
00063 template<class oType> 
00064 VrQuadratureDemod<oType>::VrQuadratureDemod(oType g)
00065   : VrHistoryProc<complex, oType>(1), gain(g)
00066 {
00067 }
00068 
00069 #if 0 /* jca */
00070 template<class oType> 
00071 VrQuadratureDemod<oType>::VrQuadratureDemod()
00072   :gain(1)
00073 {
00074 }
00075 #endif
00076 #endif

Generated on Wed Mar 23 12:30:26 2005 for GNU Radio by  doxygen 1.4.0