⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 noise.cpp

📁 Mobile STK for Symbian OS V0.1
💻 CPP
字号:
/***************************************************//*! \class Noise    \brief STK noise generator.    Generic random number generation using the    C rand() function.  The quality of the rand()    function varies from one OS to another.    by Perry R. Cook and Gary P. Scavone, 1995 - 2005.*//***************************************************/#include "Noise.h"#if !defined(SYMBIAN)#include <stdlib.h>#include <time.h>#else#include "symbmath.h"#include "debug.h"#undef DEBUG#endifNoise :: Noise() : Generator(){  // Seed the random number generator with system time.  this->setSeed( 0 );  lastOutput_ = (StkFloat) 0.0;  dcnt = 0;}Noise :: Noise( unsigned int seed ) : Generator(){  // Seed the random number generator  this->setSeed( seed );  lastOutput_ = (StkFloat) 0.0;  dcnt = 0;}Noise :: ~Noise(){}void Noise :: setSeed( unsigned int seed ){  if ( seed == 0 )#if !defined(SYMBIAN)    srand( (unsigned int) time(NULL) );#else  {	  unsigned int seed = (unsigned int) User::TickCount();	  srand( seed );  }#endif  else    srand( seed );}StkFloat Noise :: computeSample(){	TUint32 trnd;	trnd = rand();	trnd = trnd & 0x7fffffff;  lastOutput_= (StkFloat) (2.0 * trnd / (RAND_MAX + 1.0) );  lastOutput_ -= 1.0;#ifdef DEBUG    if(dcnt < 5)	{  	CStaticDebug::WriteIntN((TInt)(lastOutput_*1000));
	dcnt ++;
	}
#endif  return lastOutput_;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -