mirror of
https://github.com/thestk/stk
synced 2026-01-18 23:21:53 +00:00
Version 4.4.0
This commit is contained in:
committed by
Stephen Sinclair
parent
d199342e86
commit
eccd8c9981
@@ -6,44 +6,29 @@
|
||||
C rand() function. The quality of the rand()
|
||||
function varies from one OS to another.
|
||||
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2009.
|
||||
*/
|
||||
/***************************************************/
|
||||
|
||||
#include "Noise.h"
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
|
||||
Noise :: Noise() : Generator()
|
||||
{
|
||||
// Seed the random number generator with system time.
|
||||
this->setSeed( 0 );
|
||||
lastOutput_ = (StkFloat) 0.0;
|
||||
}
|
||||
namespace stk {
|
||||
|
||||
Noise :: Noise( unsigned int seed ) : Generator()
|
||||
Noise :: Noise( unsigned int seed )
|
||||
{
|
||||
// Seed the random number generator
|
||||
this->setSeed( seed );
|
||||
lastOutput_ = (StkFloat) 0.0;
|
||||
}
|
||||
|
||||
Noise :: ~Noise()
|
||||
{
|
||||
}
|
||||
|
||||
void Noise :: setSeed( unsigned int seed )
|
||||
{
|
||||
if ( seed == 0 )
|
||||
srand( (unsigned int) time(NULL) );
|
||||
srand( (unsigned int) time( NULL ) );
|
||||
else
|
||||
srand( seed );
|
||||
}
|
||||
|
||||
StkFloat Noise :: computeSample()
|
||||
{
|
||||
lastOutput_ = (StkFloat) (2.0 * rand() / (RAND_MAX + 1.0) );
|
||||
lastOutput_ -= 1.0;
|
||||
return lastOutput_;
|
||||
}
|
||||
} // stk namespace
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user