Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rand #51

Closed
joekingTheThird3 opened this issue Jan 24, 2021 · 3 comments
Closed

Rand #51

joekingTheThird3 opened this issue Jan 24, 2021 · 3 comments

Comments

@joekingTheThird3
Copy link

Can I have it please? rand(). If we have rand then we need srand() - srand (time(NULL));
Thank you.

@julianstorer
Copy link
Contributor

https://soul-lang.github.io/SOUL/docs/soul_library.html#mod_soul_random

P.S. please don't be someone who encourages the use of rand() or srand(), even in C code! It's an ancient, poorly-designed function and would have disappeared years ago if it wasn't for legacy support in the C library. There are far better alternatives in every language now.

@joekingTheThird3
Copy link
Author

Thanks. I am getting lost in the documentation. Didn't see it there. Random repeats after a cycle or with the same seed. I wonder if sound of a long cycle of notes is actually easier to deduce than a visual rendering of a cycle of integers. I am not very familiar with C++. I know in js

  var array = new Uint32Array(1);
window.crypto.getRandomValues(array);

is more secure.

@julianstorer
Copy link
Contributor

Sorry, but I don't really understand your question... Obviously any pseudo-random RNG will repeat eventually, but this one will take billions of iterations to do so.

Like the docs very clearly say, this isn't in any way intended to be a secure crypto-level RNG, it's a simple, fast one that's designed for audio purposes. If you need something secure, then you'd need to write that yourself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants