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

VrInterpolatingSigProcNoWork.h

Go to the documentation of this file.
00001 /* -*- Mode: c++ -*- */
00002 /*
00003  * Copyright 2001,2003 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  *  Copyright 1997 Massachusetts Institute of Technology
00024  * 
00025  *  Permission to use, copy, modify, distribute, and sell this software and its
00026  *  documentation for any purpose is hereby granted without fee, provided that
00027  *  the above copyright notice appear in all copies and that both that
00028  *  copyright notice and this permission notice appear in supporting
00029  *  documentation, and that the name of M.I.T. not be used in advertising or
00030  *  publicity pertaining to distribution of the software without specific,
00031  *  written prior permission.  M.I.T. makes no representations about the
00032  *  suitability of this software for any purpose.  It is provided "as is"
00033  *  without express or implied warranty.
00034  * 
00035  */
00036 
00037 /*
00038  * Crock to work around compiler bug.  This really show be the
00039  * base template for VrInterpolatingSigProc, but I'm not going to
00040  * bother.  This stuff should all be gone in a month or two.
00041  */
00042 
00043 #ifndef _VrINTERPOLATINGSIGPROCNOWORK_H_
00044 #define _VrINTERPOLATINGSIGPROCNOWORK_H_
00045 
00046 #include <VrHistoryProc.h>
00047 
00048 template<class iType, class oType> 
00049 class VrInterpolatingSigProcNoWork : public VrHistoryProc<iType,oType> {
00050 
00051 protected:
00052   int   interp;
00053 
00054 public: 
00055   virtual int forecast(VrSampleRange output,
00056                        VrSampleRange inputs[]);
00057 
00058   virtual void pre_initialize ();
00059 
00060   VrInterpolatingSigProcNoWork() : interp(1) {}
00061 
00062   VrInterpolatingSigProcNoWork(int outputs) :
00063     VrHistoryProc<iType, oType>(outputs),
00064     interp(1) {}
00065 
00066   VrInterpolatingSigProcNoWork(int outputs, int i) :
00067     VrHistoryProc<iType, oType>(outputs),
00068     interp(i) {}
00069 
00070   virtual ~VrInterpolatingSigProcNoWork() {}
00071 
00072 };
00073 
00074 template<class iType,class oType> int
00075 VrInterpolatingSigProcNoWork<iType,oType>::forecast(VrSampleRange output,
00076                                                     VrSampleRange inputs[]) {
00077   /* 1:interp ratio */
00078   /*
00079    * Note that this code only works correctly if output size of the
00080    * module (set using setOutputSize(n) in initialize() ) is a multiple
00081    * of interp.
00082    */
00083   assert ((output.size % interp) == 0);
00084   
00085   for(unsigned int i=0;i<numberInputs;i++) {
00086     inputs[i].index=output.index/interp; /* ! do not subtract history ! */
00087     inputs[i].size=output.size/interp + history-1;
00088   }
00089   return 0;
00090 }  
00091 
00092 
00093 template<class iType,class oType> void 
00094 VrInterpolatingSigProcNoWork<iType,oType>::pre_initialize ()
00095 {
00096   assert (interp >= 1);
00097   if (interp == 1){
00098     fprintf (stderr, "### Warning: interp == 1 in pre_initialize of %s.  Are you sure?\n",
00099              name ());
00100   }
00101   if (getSamplingFrequency () == 0.0)
00102     setSamplingFrequency (getInputSamplingFrequencyN (0) * interp);
00103 
00104   setOutputSize(interp);
00105 }
00106 
00107 #endif

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