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
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