These replace Arduino random() which is so slow it will stop your audio. More...
These replace Arduino random() which is so slow it will stop your audio.
They can even be used to generate audio noise.
Functions | |
uint32_t | xorshift96 () |
Random number generator. More... | |
void | randSeed (uint32_t seed) |
Initialises Mozzi's (pseudo)random number generator xorshift96(), which is used in Mozzi's rand() function. More... | |
void | randSeed () |
Initialises Mozzi's (pseudo)random number generator xorshift96(), which is used in Mozzi's rand() function. More... | |
void | xorshiftSeed (uint32_t seed) |
Initialises Mozzi's (pseudo)random number generator xorshift96() with a chosen seed number. More... | |
int8_t | rand (int8_t minval, int8_t maxval) |
Ranged random number generator, faster than Arduino's built-in random function, which is too slow for generating at audio rate with Mozzi. More... | |
int8_t | rand (int8_t maxval) |
Ranged random number generator, faster than Arduino's built-in random function, which is too slow for generating at audio rate with Mozzi. More... | |
uint8_t | rand (uint8_t minval, uint8_t maxval) |
Ranged random number generator, faster than Arduino's built-in random function, which is too slow for generating at audio rate with Mozzi. More... | |
uint8_t | rand (uint8_t maxval) |
Ranged random number generator, faster than Arduino's built-in random function, which is too slow for generating at audio rate with Mozzi. More... | |
int | rand (int minval, int maxval) |
Ranged random number generator, faster than Arduino's built-in random function, which is too slow for generating at audio rate with Mozzi. More... | |
int | rand (int maxval) |
Ranged random number generator, faster than Arduino's built-in random function, which is too slow for generating at audio rate with Mozzi. More... | |
unsigned int | rand (unsigned int minval, unsigned int maxval) |
Ranged random number generator, faster than Arduino's built-in random function, which is too slow for generating at audio rate with Mozzi. More... | |
unsigned int | rand (unsigned int maxval) |
Ranged random number generator, faster than Arduino's built-in random function, which is too slow for generating at audio rate with Mozzi. More... | |
uint8_t | randMidiNote () |
Generates a random number in the range for midi notes. More... | |
unsigned int | randPrime (unsigned int n) |
Generates a random prime number between 0 and the n-1th prime number. More... | |
unsigned int | randPrimeUpTo (unsigned int n) |
Generates a random prime number between 0 and the given input number inclusive. More... | |
|
inline |
Ranged random number generator, faster than Arduino's built-in random function, which is too slow for generating at audio rate with Mozzi.
maxval | the maximum signed int value of the range to be chosen from. Maxval-1 will be the largest value possibly returned by the function. |
Definition at line 130 of file mozzi_rand.h.
|
inline |
Ranged random number generator, faster than Arduino's built-in random function, which is too slow for generating at audio rate with Mozzi.
minval | the minimum signed int value of the range to be chosen from. Minval will be the minimum value possibly returned by the function. |
maxval | the maximum signed int value of the range to be chosen from. Maxval-1 will be the largest value possibly returned by the function. |
Definition at line 118 of file mozzi_rand.h.
|
inline |
Ranged random number generator, faster than Arduino's built-in random function, which is too slow for generating at audio rate with Mozzi.
maxval | the maximum signed byte value of the range to be chosen from. Maxval-1 will be the largest value possibly returned by the function. |
Definition at line 84 of file mozzi_rand.h.
|
inline |
Ranged random number generator, faster than Arduino's built-in random function, which is too slow for generating at audio rate with Mozzi.
minval | the minimum signed byte value of the range to be chosen from. Minval will be the minimum value possibly returned by the function. |
maxval | the maximum signed byte value of the range to be chosen from. Maxval-1 will be the largest value possibly returned by the function. |
Definition at line 74 of file mozzi_rand.h.
|
inline |
Ranged random number generator, faster than Arduino's built-in random function, which is too slow for generating at audio rate with Mozzi.
maxval | the maximum unsigned byte value of the range to be chosen from. Maxval-1 will be the largest value possibly returned by the function. |
Definition at line 105 of file mozzi_rand.h.
|
inline |
Ranged random number generator, faster than Arduino's built-in random function, which is too slow for generating at audio rate with Mozzi.
minval | the minimum unsigned byte value of the range to be chosen from. Minval will be the minimum value possibly returned by the function. |
maxval | the maximum unsigned byte value of the range to be chosen from. Maxval-1 will be the largest value possibly returned by the function. |
Definition at line 95 of file mozzi_rand.h.
|
inline |
Ranged random number generator, faster than Arduino's built-in random function, which is too slow for generating at audio rate with Mozzi.
maxval | the maximum unsigned int value of the range to be chosen from. Maxval-1 will be the largest value possibly returned by the function. |
Definition at line 153 of file mozzi_rand.h.
|
inline |
Ranged random number generator, faster than Arduino's built-in random function, which is too slow for generating at audio rate with Mozzi.
minval | the minimum unsigned int value of the range to be chosen from. Minval will be the minimum value possibly returned by the function. |
maxval | the maximum unsigned int value of the range to be chosen from. Maxval-1 will be the largest value possibly returned by the function. |
Definition at line 141 of file mozzi_rand.h.
|
inline |
Generates a random number in the range for midi notes.
Definition at line 162 of file mozzi_rand.h.
|
inline |
Generates a random prime number between 0 and the n-1th prime number.
This uses a stored array of primes, which takes about 2.5k of progmem.
n | the maximum index in the series of primes up to which numbers will be returned. The maximum is 1128. |
|
inline |
Generates a random prime number between 0 and the given input number inclusive.
This uses a stored array of primes up to 10000, which takes about 2.5k of progmem.
n | the upper limit of the random prime number to be generated. The maximum is 10000. |
|
inline |
Initialises Mozzi's (pseudo)random number generator xorshift96(), which is used in Mozzi's rand() function.
This can be useful if you want random sequences to be different on each run of a sketch, by seeding with a fairly random input. randSeed() called without a parameter uses noise from reading the Arduino's internal temperature as the seed, a technique discussed at http://arduino.cc/forum/index.php/topic,38091.0.html, borrowing code put there by Rob Tillaart.
Definition at line 59 of file mozzi_rand.h.
|
inline |
Initialises Mozzi's (pseudo)random number generator xorshift96(), which is used in Mozzi's rand() function.
This can be useful if you want random sequences to be different on each run of a sketch, by seeding with fairly random input, such as analogRead() on an unconnected pin (as explained in the Arduino documentation for randomSeed(). randSeed is the same as xorshift96Seed(), but easier to remember.
seed | a number to use as a seed. |
Definition at line 41 of file mozzi_rand.h.
|
inline |
Random number generator.
A faster replacement for Arduino's random function, which is too slow to use with Mozzi. Based on Marsaglia, George. (2003). Xorshift RNGs. http://www.jstatsoft.org/v08/i14/xorshift.pdf
Definition at line 30 of file mozzi_rand.h.
|
inline |
Initialises Mozzi's (pseudo)random number generator xorshift96() with a chosen seed number.
seed | a number to use as a seed. TODO: duplicate deprecate / remove |
Definition at line 66 of file mozzi_rand.h.