The Molecular Music Box in SuperCollider
Via Reaktor tutorials I came across this video. I have already talked about generative systems that create rich patterns (see here, and here), and how simple rules can give rise to emergent complexity.
Watch the video to know what the simple rules are in this case (and to see why it is called “molecular” ), or look at the following SuperCollider code, which, I must say, took me a bit more than I thought
~mOut = MIDIOut.new(3);
(
var seed = 48;
var degrees, deg;
var length = Pseq([4, 3], inf).asStream;
var dur = length.next();
var bars = 25;
var quant = 16;
var notes = [];
var loop = [];
var pos = [];
var next = 0;
degrees = [];
//Building the MIDI values for the white keys
9.do({|i|
degrees = degrees++([0, 2, 4, 5, 7, 9, 11] + (12*i));
});
//Starting notes from the seed
deg = Pseq(degrees, inf, degrees.indexOf(seed)).asStream;
(bars * quant).do({|i|
var note;
if((i%quant == 0) && (notes != []),
{
loop = loop.add(notes);
notes = [];
});
if((i%quant == next) && (pos.includes(next) == false),{
notes = notes.add([deg.next(), dur/4]);
pos = pos.add(next);
next = (next + dur)%quant;
});
if ( (i%quant == next) && (pos.includes(next) == true),{
dur = length.next();
notes = notes.add([deg.next(), dur/4]);
next = (next + dur)%quant;
});
});
loop.do({|patt, i|
patt.postln;
patterns = patterns++([i * 4, Pbind(*[\type,\midi,\chan,0,
\midiout,~mOut,
[\midinote, \dur]: Pseq(patt, inf),
\legato: 1,
\amp: rrand(0.1,0.5)])]);
});
Ptpar(patterns, 1).trace.play;
)
Notice that you can very easily change any of the rules (duration length, scale used, etc.) with a few keyboard strokes: the power of a text based programming language!
I have sent the output of this to the Grand Piano instrument in Ableton Live 9.
Here is the result for 4C3
Audio clip: Adobe Flash Player (version 9 or above) is required to play this audio clip. Download the latest version here. You also need to have JavaScript enabled in your browser.
and here is the one for 9C14½
Audio clip: Adobe Flash Player (version 9 or above) is required to play this audio clip. Download the latest version here. You also need to have JavaScript enabled in your browser.