00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
#ifndef _GRWEAVERMODTAIL_H_
00023
#define _GRWEAVERMODTAIL_H_
00024
00025
#include <assert.h>
00026
00041
template<
class iType,
class oType>
00042 class GrWeaverModTail :
public VrSigProc {
00043
00044
public:
00045
GrWeaverModTail (
float freq,
float gain);
00046
00047 virtual const char *
name () {
return "GrWeaverModTail"; }
00048
00049
virtual int work (
VrSampleRange output,
void *o[],
00050
VrSampleRange inputs[],
void *i[]);
00051
00053 void set_freq (
float frequency) { freq = frequency; }
00054 void set_gain (
float g) { gain = g; }
00055
00056
protected:
00057 gr_nco<float,float> nco;
00058 float gain;
00059 float freq;
00060 };
00061
00062
template<
class iType,
class oType>
00063 GrWeaverModTail<iType,oType>::GrWeaverModTail (
float freq,
float gain)
00064 :
VrSigProc(1, sizeof(
iType), sizeof(
oType)), gain(gain), freq(freq)
00065 {
00066 }
00067
00068
template<
class iType,
class oType>
int
00069 GrWeaverModTail<iType, oType>::work(
VrSampleRange output,
void *ao[],
00070
VrSampleRange inputs[],
void *ai[])
00071 {
00072 assert (numberInputs == 2);
00073
00074
iType *i = ((
iType **) ai)[0];
00075
iType *q = ((
iType **) ai)[1];
00076
oType *o = ((
oType **) ao)[0];
00077
long size = output.
size;
00078
00079
sync (output.
index);
00080
00081
nco.
set_freq (
freq / getSamplingFrequency () * 2 * M_PI);
00082
00083
for (
long n = 0; n < size; n++) {
00084
float cosv, sinv;
00085
nco.
cossin (cosv, sinv);
00086 o[n] = (
oType) (
gain * (i[n] * cosv + q[n] * sinv));
00087
nco.
step();
00088 }
00089
return output.
size;
00090 }
00091
00092
#endif