Skip to content

Instantly share code, notes, and snippets.

@fennecdjay
Created March 29, 2021 09:40
Show Gist options
  • Save fennecdjay/f25dd2428d5c4a45b847951841c0dd2a to your computer and use it in GitHub Desktop.
Save fennecdjay/f25dd2428d5c4a45b847951841c0dd2a to your computer and use it in GitHub Desktop.
#require Sporth
#require Math
110 => const float bpm;
(60.0 / bpm) :: second => const dur t;
[0, 1, 5, 7, 8] @=> const int scale[];
fun void loop_me(const int root) {
var int stp;
var int nbars;
var int block;
var Sporth s => dac;
s.parse("0 p 0.01 port mtof 1 p 0.003 port 1 1 2 p 0.01 port fm 0.5 * dup dup 0.94 10000 revsc drop 0.1 * +");
s.p(1, 0.2);
root => var int base;
while(true) {
if(stp == 0) {
s.p(1, 0.4);
nbars++;
} else
s.p(1, 0.4);
if(nbars > block) {
if(base == root)
53 => base;
else
60 => base;
1 => nbars;
}
s.p(0, base + scale[stp] + 12 * Math.rand2(-1, 1));
s.p(2, Math.rand2f(0.1, 3));
0.25::t => now;
(stp + 1) % scale.size() => stp;
}
}
spork loop_me(60);
spork loop_me(36);
minute => now;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment