00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
#ifndef _GRFRACTIONALINTERPOLATINGSIGPROC_H_
00024
#define _GRFRACTIONALINTERPOLATINGSIGPROC_H_
00025
00026
#include <VrHistoryProc.h>
00027
#include <stdlib.h>
00028
#include <gr_math.h>
00029
#include <gr_mmse_fir_interpolator.h>
00030
00035
template<
class iType,
class oType>
00036 class GrFractionalInterpolatingSigProc :
public VrHistoryProc<iType,oType>
00037 {
00038
public:
00039 GrFractionalInterpolatingSigProc (
int outputs,
int arg_N,
int arg_M)
00040 :
VrHistoryProc<
iType,
oType>(outputs),
N(arg_N),
M(arg_M) {}
00041
00042 GrFractionalInterpolatingSigProc (
int arg_N,
int arg_M)
00043 :
VrHistoryProc<
iType,
oType>(1),
N(arg_N),
M(arg_M) {}
00044
00045 ~GrFractionalInterpolatingSigProc () {};
00046
00047
void pre_initialize ();
00048
int forecast (
VrSampleRange output,
VrSampleRange inputs[]);
00049
00050
protected:
00051 int N;
00052 int M;
00053 int iratio;
00054 };
00055
00056
template<
class iType,
class oType>
int
00057 GrFractionalInterpolatingSigProc<iType,oType>::forecast(
VrSampleRange output,
00058
VrSampleRange inputs[]) {
00059
00060
00061
00062
00063
00064
00065 assert ((output.
size %
iratio) == 0);
00066
00067
for(
unsigned int i=0;i<numberInputs;i++) {
00068 inputs[i].
index=output.
index/
iratio;
00069 inputs[i].
size=output.
size/
iratio + history-1;
00070 }
00071
return 0;
00072 }
00073
00074
00075
template<
class iType,
class oType>
void
00076 GrFractionalInterpolatingSigProc<iType,oType>::pre_initialize ()
00077 {
00078
if (
getSamplingFrequency () == 0.0)
00079
setSamplingFrequency ((getInputSamplingFrequencyN (0) *
N) /
M);
00080
00081
00082
00083
int d =
gr_gcd (N, M);
00084
iratio = (N * M) / (d * d);
00085
00086
setOutputSize(
iratio);
00087 }
00088
00089
#endif