You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

random.hpp 622B

1234567891011121314151617181920212223242526272829
  1. #pragma once
  2. #include <common.hpp>
  3. #include <cstdint>
  4. namespace rack {
  5. /** Random number generator
  6. */
  7. namespace random {
  8. /** Initializes the thread-local RNG state.
  9. Must call per-thread, otherwise the RNG will always return 0.
  10. */
  11. void init();
  12. /** Returns a uniform random uint32_t from 0 to UINT32_MAX */
  13. uint32_t u32();
  14. /** Returns a uniform random uint64_t from 0 to UINT64_MAX */
  15. uint64_t u64();
  16. /** Returns a uniform random float in the interval [0.0, 1.0) */
  17. float uniform();
  18. /** Returns a normal random number with mean 0 and standard deviation 1 */
  19. float normal();
  20. } // namespace random
  21. } // namespace rack