VCV Rack API v2
rack::random Namespace Reference

Random number generation. More...

Classes

struct  Xoroshiro128Plus
 xoroshiro128+. More...
 

Functions

void init ()
 Initializes the thread-local RNG state. More...
 
Xoroshiro128Pluslocal ()
 Returns the thread-local generator. More...
 
template<typename T >
get ()
 
template<>
uint32_t get ()
 
uint64_t u64 ()
 Returns a uniform random uint64_t from 0 to UINT64_MAX. More...
 
uint32_t u32 ()
 Returns a uniform random uint32_t from 0 to UINT32_MAX. More...
 
float uniform ()
 Returns a uniform random float in the interval [0.0, 1.0) More...
 
float normal ()
 Returns a normal random number with mean 0 and standard deviation 1. More...
 
void buffer (uint8_t *out, size_t len)
 Fills an array with random bytes. More...
 
std::vector< uint8_t > vector (size_t len)
 Creates a vector of random bytes. More...
 

Detailed Description

Random number generation.

Function Documentation

◆ init()

void rack::random::init ( )

Initializes the thread-local RNG state.

Must call when creating a thread, otherwise random state is undefined (might always return 0).

◆ local()

Xoroshiro128Plus & rack::random::local ( )

Returns the thread-local generator.

◆ get() [1/2]

template<typename T >
T rack::random::get ( )

◆ get() [2/2]

template<>
double rack::random::get ( )
inline

◆ u64()

uint64_t rack::random::u64 ( )
inline

Returns a uniform random uint64_t from 0 to UINT64_MAX.

◆ u32()

uint32_t rack::random::u32 ( )
inline

Returns a uniform random uint32_t from 0 to UINT32_MAX.

◆ uniform()

float rack::random::uniform ( )
inline

Returns a uniform random float in the interval [0.0, 1.0)

◆ normal()

float rack::random::normal ( )
inline

Returns a normal random number with mean 0 and standard deviation 1.

◆ buffer()

void rack::random::buffer ( uint8_t *  out,
size_t  len 
)
inline

Fills an array with random bytes.

◆ vector()

std::vector< uint8_t > rack::random::vector ( size_t  len)
inline

Creates a vector of random bytes.