// // Programmer: Craig Stuart Sapp // Creation Date: Wed Mar 25 00:38:06 GMT-0800 1998 // Last Modified: Wed Mar 25 14:51:36 GMT-0800 1998 // Filename: ...sig/maint/code/Filter/DCBlock/DCBlock.cpp // Web Address: http://sig.sapp.org/src/sigSignal/DCBlock.cpp // Documentation: http://sig.sapp.org/doc/classes/DCBlock // Syntax: C++ // #include "DCBlock.h" ////////////////////////////// // // DCBlock::DCBlock -- // DCBlock::DCBlock(void) { setName("DCBlock"); brandname = FILTER; setPolePosition(0.995); clear(); } ////////////////////////////// // // DCBlock::~DCBlock -- // DCBlock::~DCBlock() { // do nothing } ////////////////////////////// // // DCBlock::action -- // void DCBlock::action(void) { // difference equation: y[n] = x[n] - x[n-1] + a * y[n-1] // where a = pole position on the z-plane outputValue = getInput() - previousInput + getPolePosition() * outputValue; previousInput = getInput(); } ////////////////////////////// // // DCBlock::clear -- // void DCBlock::clear(void) { outputValue = 0.0; previousInput = 0.0; } ////////////////////////////// // // DCBlock::getInput -- returns the current value of the input signal // on channel 0 // sampleType DCBlock::getInput(void) { return inputs[0]; } ////////////////////////////// // // DCBlock::getPolePosition -- returns the current value of the pole // position on channel 1. // sampleType DCBlock::getPolePosition(void) { return inputs[1]; } ////////////////////////////// // // DCBlock::output -- // sampleType DCBlock::output(int channel) { return outputValue; } ////////////////////////////// // // DCBlock::printState -- // void DCBlock::printState(void) { cout << "Signal input = " << getInput() << endl; cout << "Pole position = " << getPolePosition() << endl; cout << "Current output = " << output(0) << endl; } ////////////////////////////// // // DCBlock::setInput -- // default value: outputChannel = 0 // void DCBlock::setInput(sampleType aValue) { connect(aValue, 0); } void DCBlock::setInput(Signal& aSignal, int outputChannel) { connect(aSignal, 0, outputChannel); } void DCBlock::setInput(Signal* aSignal, int outputChannel) { connect(aSignal, 0, outputChannel); } ////////////////////////////// // // DCBlock::setPolePosition -- // default value: outputChannel = 0 // void DCBlock::setPolePosition(sampleType aValue) { connect(aValue, 1); } void DCBlock::setPolePosition(Signal& aSignal, int outputChannel) { connect(aSignal, 1, outputChannel); } void DCBlock::setPolePosition(Signal* aSignal, int outputChannel) { connect(aSignal, 1, outputChannel); } // md5sum: 7afcb3b83fbdd590a26a0badbcd9bd56 DCBlock.cpp [20010708]