#include #include using namespace std; int main(void) { unsigned short int note, velocity; int32_t salt; struct random_data seed; char rand_state[256]; note = 63; velocity = 120; salt = ((velocity & 0x7F) << 7) | (note & 0x7F); // See http://lists.debian.org/debian-glibc/2006/01/msg00037.html seed.state = (int32_t*)rand_state; initstate_r(salt, rand_state, sizeof(rand_state), &seed); int32_t res; for(int k=0 ; k<20 ; ++k) { random_r(&seed, &res); cout << res << endl; } return 0; }