-
Notifications
You must be signed in to change notification settings - Fork 62
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
added linear congruential generator for streams and lists #56
base: master
Are you sure you want to change the base?
Conversation
Looks nice to have! If it's not going to noises.lib, then I think random-number generators in both files should have SEE ALSO comments pointing to each other. In principle, noise should be reimplemented as a special case of lcg. However, it looks like it would be more expensive, and the current simple noise function is nice to keep for its clarity and simplicity. |
Nice hearing from you, Julius. :-) Sure, I can cross-reference the functions. For completeness, perhaps we can also add the following in noises.lib for a seeded noise generator: noiseed(S) = random / RANDMAX Best, |
I think that's a great idea!
Thanks,
Julius
…On Wed, Oct 28, 2020 at 4:33 PM Dario Sanfilippo ***@***.***> wrote:
Nice hearing from you, Julius. :-)
Sure, I can cross-reference the functions.
For completeness, perhaps we can also add the following in noises.lib for
a seeded noise generator:
noiseed(S) = random / RANDMAX
with{
mask = 4294967295; // 2^32-1
random = +(S) ~ *(1103515245) & mask; // "linear congruential"
RANDMAX = 2147483647.0; // = 2^31-1 = MAX_SIGNED_INT in 32 bits
};
Best,
Dario
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#56 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAQZKFMRBOMCBEULCAYSNKTSNCS5JANCNFSM4TAZXR6A>
.
--
Julius O. Smith III <[email protected]>
Professor of Music and, by courtesy, Electrical Engineering
CCRMA, Stanford University
http://ccrma.stanford.edu/~jos/
|
@sletz @josmithiii does this PR need any further improvements? Best, |
Looks good to me... |
By the way, changing the increment as I did in the noiseed function does not seem to affect the uniformity of the generated stream: I tried averaging the streams over 1e+08 samples at 48kHz SR and I get these values (test code below): 5.9520071088884344e-05, -1.3798191843195161e-05, -2.0827678791606534e-05, 1.8723615871972751e-05 import("stdfaust.lib"); |
@orlarey can you have a look and comment ? |
Hello, people.
If I'm not wrong, there was no random numbers generator accepting a seed in the libraries so I added this basic LCG. There are both a function to generate streams of values in the sequence, as well as a function to generate N values in the sequence in parallel (lists, so to speak).
Depending on the parameters, the sequences can have short periods, and the values are outside of the digital audio range. So I thought that maths.lib was a better place than noises.lib.
Best,
Dario