00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
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
00074
00075
00076
00077
00078
00079 assert ((output.
size %
interp) == 0);
00080
00081
for(
unsigned int i=0;i<numberInputs;i++) {
00082 inputs[i].
index=output.
index/
interp;
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