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

GrFastChannelizer.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  *  Copyright 1997 Massachusetts Institute of Technology
00025  * 
00026  *  Permission to use, copy, modify, distribute, and sell this software and its
00027  *  documentation for any purpose is hereby granted without fee, provided that
00028  *  the above copyright notice appear in all copies and that both that
00029  *  copyright notice and this permission notice appear in supporting
00030  *  documentation, and that the name of M.I.T. not be used in advertising or
00031  *  publicity pertaining to distribution of the software without specific,
00032  *  written prior permission.  M.I.T. makes no representations about the
00033  *  suitability of this software for any purpose.  It is provided "as is"
00034  *  without express or implied warranty.
00035  * 
00036  */
00037 
00038 
00039 #ifndef _GrFastChannelizer_H_
00040 #define _GrFastChannelizer_H_
00041 
00042 #include <VrDecimatingSigProc.h>
00043 
00044 template<class iType> 
00045 class GrFastChannelizer : public VrDecimatingSigProc<iType,VrComplex> {
00046 private:
00047   int numTaps;
00048   int freq;
00049   float gain;
00050 public: 
00051   virtual const char *name() { return "GrFastChannelizer"; }
00052   virtual int work(VrSampleRange output, void *o[],
00053                    VrSampleRange inputs[], void *i[]);
00054 
00055   virtual void initialize();
00056   GrFastChannelizer(int d, int t, float g);
00057   GrFastChannelizer(int f, int d, int t, float g);
00058 };
00059 
00060 template<class iType> int
00061 GrFastChannelizer<iType>::work(VrSampleRange output, void *ao[],
00062                                 VrSampleRange inputs[], void *ai[])
00063 {
00064   iType **i = (iType **)ai;
00065   VrComplex **o = (VrComplex **)ao;
00066   unsigned int size = output.size;
00067 
00068   iType a = 0;
00069   iType b = 0;
00070 
00071 if(freq) {
00072   for(unsigned int j=0;j<history/4;j++)
00073   {
00074         a += (i[0][4*j]);
00075         b += (i[0][4*j+1]);
00076         a -= (i[0][4*j+2]);
00077         b -= (i[0][4*j+3]);
00078   }
00079   if(history % 4 > 0)
00080         a += (i[0][((int)(history/4))*4]);
00081   if(history % 4 > 1)
00082         b += (i[0][((int)(history/4))*4+1]);
00083   if(history % 4 > 2)
00084         a -= (i[0][((int)(history/4))*4+2]);
00085 
00086   for(unsigned int j = 0;j<size/4;j+=1)
00087   {
00088         a += i[0][j*4 + history] - i[0][j*4];
00089         if(j*4 % decimation == 0)
00090         {
00091                 o[0][0].real(a);
00092                 o[0][0].imag(b);
00093                 o[0]++;
00094         }
00095         b += i[0][j*4 + history + 1] - i[0][j*4 + 1];
00096         if(j*4 % decimation == 1)
00097         {
00098                 o[0]->real(b);
00099                 o[0]->imag(-a);
00100                 o[0]++;
00101         }
00102         a -= i[0][j*4 + history + 2] - i[0][j*4 + 2];
00103         if(j*4 % decimation == 2)
00104         {
00105                 o[0]->real(-a);
00106                 o[0]->imag(-b);
00107                 o[0]++;
00108         }
00109         b -= i[0][j*4 + history + 3] - i[0][j*4 + 3];
00110         if(j*4 % decimation == 3)
00111         {
00112                 o[0]->real(-b);
00113                 o[0]->imag(a);
00114                 o[0]++;
00115         }
00116   }
00117 }
00118 else
00119 {
00120   for(unsigned int j=0;j<history;j++)
00121             a += (int)(i[0][j]);
00122   for(unsigned int j=0;j<size;j++)
00123   {
00124           a += i[0][j+history] - i[0][j];
00125           if(j % decimation == 0)
00126           {
00127                           o[0][0].real(a);
00128                           o[0][0].imag(0);
00129                           o[0]++;
00130           } 
00131   }
00132                           
00133 
00134 
00135 }
00136   return output.size;
00137 }
00138 
00139 template<class iType> 
00140 GrFastChannelizer<iType>::GrFastChannelizer(int f, int dec,int t,float g)
00141   :VrDecimatingSigProc<iType,VrComplex>(1,dec), numTaps(t), freq(0), gain(g)
00142 {
00143 }
00144 
00145 template<class iType> 
00146 GrFastChannelizer<iType>::GrFastChannelizer(int dec,int t,float g)
00147   :VrDecimatingSigProc<iType,VrComplex>(1,dec), numTaps(t), freq(5), gain(g)
00148 {
00149 }
00150 
00151 template<class iType> 
00152 void GrFastChannelizer<iType>::initialize()
00153 {
00154   history=numTaps;
00155 }
00156 #endif

Generated on Tue Mar 30 21:31:48 2004 for GNU Radio by doxygen 1.3.2