Created
July 11, 2021 18:02
-
-
Save ryanlaws/a628525877c8b7c585ad439d7ae9e73c to your computer and use it in GitHub Desktop.
Linear Congruential Generator for Monome Crow 3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- LCG based on https://github.com/monome/dsp-kit/blob/main/noise/lcg.c by @catfact | |
-- due to differences in data types, the behavior is not the same. | |
-- int32_t values were truncated to avoid Lua converting them to inf or -inf. | |
output[1].action = loop { | |
to( | |
dyn{x=1} | |
:mul(dyn{a=-559}) | |
:step(dyn{c=21032}) | |
:wrap(-32768, 32767) | |
/ 32768 | |
* math.abs(dyn{amp=10} | |
:step(dyn{ampstep=0.01}) | |
:wrap(-10, 10)), | |
0 | |
), | |
to( | |
dyn{x=1}/ 32768 * math.abs(dyn{amp=10}), | |
dyn{time= 2.986e-5 } | |
) | |
} | |
-- some values to try out | |
output[1].dyn.a = 28772.0 | |
output[1].dyn.c = 5221.0 | |
output[1].dyn.time = 0.00233 | |
output[1].dyn.ampstep = 0.0001 | |
output[1].dyn.a = 28772.0 | |
output[1].dyn.c = 8231.0 | |
output[1].dyn.time = 0.000031 | |
output[1].dyn.a = 29272.0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment