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.

29 lines
603B

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