Mozzi  version v2.0
sound synthesis library for Arduino
mozzi_rand_p.h
1 /*
2  * mozzi_rand_p.h
3  *
4  * This file is part of Mozzi.
5  *
6  * Copyright 2012-2024 Tim Barrass and the Mozzi Team
7  *
8  * Mozzi is licensed under the GNU Lesser General Public Licence (LGPL) Version 2.1 or later.
9  *
10 */
11 
12 #ifndef MOZZI_RAND_P_H
13 #define MOZZI_RAND_P_H
14 
15 namespace MozziPrivate {
16 
18 friend void randSeed();
19 friend void randSeed(uint32_t);
20 friend uint32_t xorshift96();
21  static uint32_t x;
22  static uint32_t y;
23  static uint32_t z;
24 public:
25  static uint32_t xorshift96() {
26  //period 2^96-1
27  uint32_t t;
28 
29  x ^= x << 16;
30  x ^= x >> 5;
31  x ^= x << 1;
32 
33  t = x;
34  x = y;
35  y = z;
36  z = t ^ x ^ y;
37 
38  return z;
39  }
40  static void autoSeed(); // defined in hardware specific MozziGuts_impl-files
41 };
42 
43 inline void randSeed(uint32_t seed) { MozziRandPrivate::x = seed; };
44 
45 }
46 
47 #endif
friend uint32_t xorshift96()
Random number generator.
Definition: mozzi_rand.h:30
friend void randSeed()
Initialises Mozzi's (pseudo)random number generator xorshift96(), which is used in Mozzi's rand() fun...
Definition: mozzi_rand.h:59
Internal.
Definition: mozzi_rand_p.h:15