Skip to content

Instantly share code, notes, and snippets.

@ryanlaws
ryanlaws / crow3-lcg.lua
Created July 11, 2021 18:02
Linear Congruential Generator for Monome Crow 3
-- 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
-- an imaginary verbose REPL
-- ------------------
-- inspired by the ii help in crow/druid
-- most examples based on https://gist.github.com/trentgill/84ec5b68816eb03508566addb5a41dd4
s = sequins
-- comments below are hypothetical log output (via e.g. print() or a REPL)
cs = s"abcd"
// each channel has its own trigger stream
// which is a slow Impulse and a faster CombN
// delay threshold is a regular trigger for an envelope
// the source is controlled by a Select (many:1)
// binary math takes triggers on several control channels
// and outputs the index of which channel was last triggered
(Ndef(\spaghettiArp, {|root=45, triggerThreshold=0.08, brightness=1.5, atk=0, dec=2.5|