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

VrInterpolatingSigProc.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 * 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 #ifndef _VrINTERPOLATINGSIGPROC_H_ 00038 #define _VrINTERPOLATINGSIGPROC_H_ 00039 00040 #include <VrHistoryProc.h> 00041 00042 template<class iType, class oType> 00043 class VrInterpolatingSigProc : public VrHistoryProc<iType,oType> { 00044 00045 protected: 00046 int interp; 00047 00048 public: 00049 virtual int forecast(VrSampleRange output, 00050 VrSampleRange inputs[]); 00051 00052 virtual void pre_initialize (); 00053 00054 VrInterpolatingSigProc() : interp(1) {} 00055 00056 VrInterpolatingSigProc(int outputs) : 00057 VrHistoryProc<iType, oType>(outputs), 00058 interp(1) {} 00059 00060 VrInterpolatingSigProc(int outputs, int i) : 00061 VrHistoryProc<iType, oType>(outputs), 00062 interp(i) {} 00063 00064 virtual ~VrInterpolatingSigProc() {} 00065 00066 virtual int work(VrSampleRange output, void *ao[], VrSampleRange inputs[], void *ai[]); 00067 00068 }; 00069 00070 template<class iType,class oType> int 00071 VrInterpolatingSigProc<iType,oType>::forecast(VrSampleRange output, 00072 VrSampleRange inputs[]) { 00073 /* 1:interp ratio */ 00074 /* 00075 * Note that this code only works correctly if output size of the 00076 * module (set using setOutputSize(n) in initialize() ) is a multiple 00077 * of interp. 00078 */ 00079 assert ((output.size % interp) == 0); 00080 00081 for(unsigned int i=0;i<numberInputs;i++) { 00082 inputs[i].index=output.index/interp; /* ! do not subtract history ! */ 00083 inputs[i].size=output.size/interp + history-1; 00084 } 00085 return 0; 00086 } 00087 00088 00089 template<class iType,class oType> void 00090 VrInterpolatingSigProc<iType,oType>::pre_initialize () 00091 { 00092 assert (interp >= 1); 00093 if (interp == 1){ 00094 fprintf (stderr, "### Warning: interp == 1 in pre_initialize of %s. Are you sure?\n", 00095 name ()); 00096 } 00097 if (getSamplingFrequency () == 0.0) 00098 setSamplingFrequency (getInputSamplingFrequencyN (0) * interp); 00099 00100 setOutputSize(interp); 00101 } 00102 00103 template<class iType,class oType> int 00104 VrInterpolatingSigProc<iType,oType>::work(VrSampleRange output, void *ao[], 00105 VrSampleRange inputs[], void *ai[]) 00106 { 00107 iType **i = (iType **)ai; 00108 oType **o = (oType **)ao; 00109 int size = output.size; 00110 iType input_symbol; 00111 00112 for (int insamp = 0; insamp < size/interp; insamp++){ 00113 input_symbol = i[0][insamp]; 00114 *o[0]++ = input_symbol; 00115 for (int outsamp = 1; outsamp < interp; outsamp++){ 00116 *o[0]++ = 0; 00117 } 00118 } 00119 return output.size; 00120 } 00121 00122 #endif

Generated on Wed Aug 4 02:22:05 2004 for GNU Radio by doxygen 1.3.8