#include "block.h" #include "fir.h" class FIRAverage : public Block { private: InPort < double > * in; OutPort < double > * out; Parameter < long > * samples; Fir < double > fir; public: FIRAverage(const Blockopt & blockopt) : Block(blockopt) {} void makeParameters() { samples = new Parameter < long > (this, "samples", 10); } void makeIOPorts() { in = new InPort < double > (this, "in", 1); out = new OutPort < double > (this, "out", 1); } void initialize() { long fulllength = samples->value(); double firprototype[fulllength]; for (long k = 0;k < fulllength;k++) firprototype[k] = 1. / double(fulllength); fir.create(fulllength, firprototype); } void go() { out->write(fir.filter(in->read())); } }; PUBLISH(FIRAverage);