Created
January 29, 2019 11:12
-
-
Save chadochan/cbe6dc788f2ce2ca536b322afb6c3ce6 to your computer and use it in GitHub Desktop.
Nbit creates a rhythmic array a specified beatdivision, of length numbeats, with adjustable event density.
This file contains 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
// Nbit creates a rhythmic array a specified beatdivision, of length numbeats, with adjustable event density | |
Nbit { | |
var beatdiv, numbeats, density; | |
*new { | beatdiv = 5, numbeats = 2, density = 0.5 | | |
var pulse = 1 / beatdiv; | |
var array = Array.fill(beatdiv*numbeats, { (density.coin).binaryValue }); | |
while( | |
{ array.includes(1).not }, { array = Array.fill(beatdiv*numbeats, { (density.coin).binaryValue }) } | |
); | |
^array; | |
} | |
} | |
// Similar to Nbit, but for use with Patterns; replaces any 0 with Rest(). | |
NbitPat { | |
var beatdiv, numbeats, density; | |
*new { | beatdiv = 5, numbeats = 2, density = 0.5 | | |
var pulse = 1 / beatdiv; | |
var array = Array.fill(beatdiv*numbeats, { (density.coin).binaryValue }); | |
while( | |
{ array.includes(1).not }, { array = Array.fill(beatdiv*numbeats, { (density.coin).binaryValue }) } | |
); | |
array.do({ |item, i| | |
if(item == 0, { array.put(i, Rest()) }) | |
}) | |
^array; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment