Last active
March 9, 2020 15:09
-
-
Save madskjeldgaard/bb93f0dbb1c4926c0ef17fb481be0e74 to your computer and use it in GitHub Desktop.
Generative SuperCollider files containing random patterns
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
/* | |
Generate SuperCollider file containing simple random pattern | |
*/ | |
( | |
// Time stamp | |
~stamp = Date.getDate.stamp; | |
// This goes in the duration key of the pattern | |
~dur = "Pseq(%)".format(Array.rand(10, 0.1,10.0)); | |
// The degree key | |
~degree = "Pwhite(%, %)".format(10.rand2, 10.rand2); | |
// The actual string that will be written to the file | |
~patternString = " | |
// Pattern generated % | |
Pbind( | |
\dur, %, | |
\degree, % | |
).play".format(~stamp, ~dur, ~degree); | |
// Path + filename | |
~path = "~/code/sc/gen_pat%.scd".format(~stamp).standardizePath; | |
// Open a file | |
~file = File(~path, "w"); | |
// Write to it | |
~file.write(~patternString); | |
"Writing % to file %".format(~string, ~path).postln; | |
// Close the file | |
~file.close; | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment