Friday, January 26, 2007

noise: Sample class version 1.0

#include stdlib
#include vector
#include iostream

//---------------------------------------------------------------------------
// Sample: Fills an array of doubles with random integers. This is an example of digital noise
// One obvious use of a non recursive digital filter would be to scale
// the random ints into a specified range of doubles.
// e.g. a filter with a single coefficient of 0.001
class Sample
{
std::vector Samples;
int SampleSize;
public:
void Fill(int sampleSize)
{

Samples.resize(sampleSize); // resize STL "Array"
randomize(); // initialize random number generator.
SampleSize = sampleSize; // keep track in the class
for( int n = 0; n < sampleSize; n ++) // fill
{
Samples[n]=rand();
}
}

void PrintSamples()
{
for( int n = 0 ; n < SampleSize; n++)
{
std::cout << n << ": " << Samples[n] << std::endl;
}
}


};


int main(int argc, char* argv[])
{

Sample test;
test.Fill(3);

test.PrintSamples();
int wait;

std::cin >> wait;

return 0;
}

No comments: