![]() |
Mozzi
alpha 0.01.1t
sound synthesis library for Arduino
|
Functions | |
unsigned long | xorshift96 () |
Random number generator. | |
void | randSeed (unsigned long seed) |
Initialises Mozzi's (pseudo)random number generator xorshift96(), which is used in Mozzi's rand() function. | |
void | randSeed () |
Initialises Mozzi's (pseudo)random number generator xorshift96(), which is used in Mozzi's rand() function. | |
void | xorshiftSeed (unsigned long seed) |
Initialises Mozzi's (pseudo)random number generator xorshift96(). | |
char | rand (char minval, char maxval) |
Ranged random number generator, faster than Arduino's built-in random function, which is too slow for Mozzi. | |
unsigned char | rand (unsigned char minval, unsigned char maxval) |
Ranged random number generator, faster than Arduino's built-in random function, which is too slow for Mozzi. | |
int | rand (int minval, int maxval) |
Ranged random number generator, faster than Arduino's built-in random function, which is too slow for Mozzi. | |
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 Mozzi. | |
char | rand (char maxval) |
Ranged random number generator, faster than Arduino's built-in random function, which is too slow for Mozzi. | |
unsigned char | rand (unsigned char maxval) |
Ranged random number generator, faster than Arduino's built-in random function, which is too slow for Mozzi. | |
int | rand (int maxval) |
Ranged random number generator, faster than Arduino's built-in random function, which is too slow for Mozzi. | |
unsigned int | rand (unsigned int maxval) |
Ranged random number generator, faster than Arduino's built-in random function, which is too slow for Mozzi. | |
unsigned char | randMidiNote () |
Generates a random number in the range for midi notes. | |
unsigned int | randPrime (unsigned int n) |
Generates a random prime number between 0 and the n-1th prime number. | |
unsigned int | randPrimeUpTo (unsigned int n) |
Generates a random prime number between 0 and the given input number inclusive. |
char rand | ( | char | minval, |
char | maxval | ||
) |
Ranged random number generator, faster than Arduino's built-in random function, which is too slow for 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 123 of file mozzi_rand.cpp.
unsigned char rand | ( | unsigned char | minval, |
unsigned char | maxval | ||
) |
Ranged random number generator, faster than Arduino's built-in random function, which is too slow for 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 135 of file mozzi_rand.cpp.
int rand | ( | int | minval, |
int | maxval | ||
) |
Ranged random number generator, faster than Arduino's built-in random function, which is too slow for 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 147 of file mozzi_rand.cpp.
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 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 159 of file mozzi_rand.cpp.
char rand | ( | char | maxval | ) |
Ranged random number generator, faster than Arduino's built-in random function, which is too slow for 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 170 of file mozzi_rand.cpp.
unsigned char rand | ( | unsigned char | maxval | ) |
Ranged random number generator, faster than Arduino's built-in random function, which is too slow for 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 181 of file mozzi_rand.cpp.
int rand | ( | int | maxval | ) |
Ranged random number generator, faster than Arduino's built-in random function, which is too slow for 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 192 of file mozzi_rand.cpp.
unsigned int rand | ( | unsigned int | maxval | ) |
Ranged random number generator, faster than Arduino's built-in random function, which is too slow for 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 203 of file mozzi_rand.cpp.
unsigned char randMidiNote | ( | ) |
Generates a random number in the range for midi notes.
Definition at line 213 of file mozzi_rand.cpp.
unsigned int randPrime | ( | unsigned int | n | ) | [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. |
unsigned int randPrimeUpTo | ( | unsigned int | n | ) | [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. |
void randSeed | ( | unsigned long | seed | ) |
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 | an int to use as a seed. |
Definition at line 44 of file mozzi_rand.cpp.
void randSeed | ( | ) |
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 94 of file mozzi_rand.cpp.
unsigned long xorshift96 | ( | ) |
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 17 of file mozzi_rand.cpp.
void xorshiftSeed | ( | unsigned long | seed | ) |
Initialises Mozzi's (pseudo)random number generator xorshift96().
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().
seed | an int to use as a seed. |
Definition at line 110 of file mozzi_rand.cpp.