// // Programmer: Craig Stuart Sapp // Creation Date: Wed Apr 30 14:17:37 GMT-0800 1997 // Last Modified: Mon Jan 19 04:21:15 GMT-0800 1998 // Filename: ...sig/maint/code/Generator/WhiteNoise/WhiteNoise.cpp // Web Address: http://sig.sapp.org/src/sigSignal/WhiteNoise.cpp // Documentation: http://sig.sapp.org/doc/classes/WhiteNoise // Syntax: C++ // #include "WhiteNoise.h" #include #include #include #ifndef OLDCPP #include using namespace std; #else #include #endif ////////////////////////////// // // WhiteNoise::WhiteNoise -- // default values: aMaxAmplitude = 1.0, randomSeed = 0 // WhiteNoise::WhiteNoise(sampleType aMaxAmplitude, int randomSeed) { setName("WhiteNoise"); setAmplitude(aMaxAmplitude); seed(randomSeed); outputValue = 0; brandname = GENERATOR; action(); } ////////////////////////////// // // WhiteNoise::~WhiteNoise -- // WhiteNoise::~WhiteNoise() { } ////////////////////////////// // // WhiteNoise::action -- // void WhiteNoise::action(void) { outputValue = amplitude * ((float)rand()/RAND_MAX*2.0 - 1.0); } ////////////////////////////// // // WhiteNoise::getAmplitude -- // sampleType WhiteNoise::getAmplitude(void) { return amplitude; } ////////////////////////////// // // WhiteNoise::output -- // sampleType WhiteNoise::output(int channel) { return outputValue; } ////////////////////////////// // // WhiteNoise::printState -- // void WhiteNoise::printState(void) { cerr << "WhiteNoise amplitude = " << amplitude << endl; } ////////////////////////////// // // WhiteNoise::seed -- // default value: aSeed = 0 // void WhiteNoise::seed(int aSeed) { if (aSeed == 0) { srand(time(NULL)); } else { srand(aSeed); } #ifdef LINUX if (aSeed == 0) { srand(time(NULL)); } else { srand(aSeed); } #endif } ////////////////////////////// // // WhiteNoise::setAmplitude -- // void WhiteNoise::setAmplitude(sampleType anAmplitude) { amplitude = anAmplitude; } // md5sum: b14b29aa555426a5cd3fff5989cdd5e3 WhiteNoise.cpp [20010708]