From 33aba9c91351c62891f452bf3c02037855dd703f Mon Sep 17 00:00:00 2001 From: Javier Serrano Polo Date: Sun, 13 Aug 2006 14:06:50 +0000 Subject: [PATCH] added fast pseudo-random integer generator git-svn-id: https://lmms.svn.sf.net/svnroot/lmms/trunk/lmms@319 0778d3d1-df1d-0410-868b-ea421aaaa00d --- include/lmms_math.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/include/lmms_math.h b/include/lmms_math.h index f54a3c196..71de4a1fc 100644 --- a/include/lmms_math.h +++ b/include/lmms_math.h @@ -27,6 +27,8 @@ #define _LMMS_MATH_H + + // Equivalent to _x - floorf( _x ) static inline float fraction( const float _x ) { @@ -35,4 +37,17 @@ static inline float fraction( const float _x ) } + + +#define FAST_RAND_MAX 32767 +static inline int fast_rand( void ) +{ + static unsigned long next = 1; + next = next * 1103515245 + 12345; + return( (unsigned)( next / 65536 ) % 32768 ); +} + + + + #endif