mirror of
https://github.com/thestk/stk
synced 2026-01-17 06:41:51 +00:00
Version 4.1.2
This commit is contained in:
committed by
Stephen Sinclair
parent
6e0d1955a8
commit
586b0add5f
@@ -12,9 +12,19 @@
|
||||
|
||||
#include "Noise.h"
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
|
||||
Noise :: Noise() : Stk()
|
||||
{
|
||||
{
|
||||
// Seed the random number generator with system time.
|
||||
this->setSeed( 0 );
|
||||
lastOutput = (MY_FLOAT) 0.0;
|
||||
}
|
||||
|
||||
Noise :: Noise( unsigned int seed ) : Stk()
|
||||
{
|
||||
// Seed the random number generator
|
||||
this->setSeed( seed );
|
||||
lastOutput = (MY_FLOAT) 0.0;
|
||||
}
|
||||
|
||||
@@ -22,6 +32,14 @@ Noise :: ~Noise()
|
||||
{
|
||||
}
|
||||
|
||||
void Noise :: setSeed( unsigned int seed )
|
||||
{
|
||||
if ( seed == 0 )
|
||||
srand( (unsigned int) time(NULL) );
|
||||
else
|
||||
srand( seed );
|
||||
}
|
||||
|
||||
MY_FLOAT Noise :: tick()
|
||||
{
|
||||
lastOutput = (MY_FLOAT) (2.0 * rand() / (RAND_MAX + 1.0) );
|
||||
|
||||
Reference in New Issue
Block a user