﻿ pattern « Coding, Sounds and Colors | A blog about algorithmic experiments in music and visual art. Sort of.

## Piano, patterns and gestures

posted by on 2013.02.12, under Supercollider
12:

I always loved piano as a kid, but for life circumstances I could never study it.  Ended studying guitar instead. Here’s a little code in Supercollider, exploring piano improvisation and “gestural” phrasing.

MIDIClient.init;

~mOut = MIDIOut.new(3);

//Set the scale to be Cmajor
~scale=[0,2,4,5,7,9,11];

//Define pattern proxies which will be modified by the task t below

a=PatternProxy(Pxrand([3,3,3,1,3,3],inf));
b=PatternProxy(Pseq([1/2],inf));
r=PatternProxy(Pseq([12],inf));
n=Prand([4,8,16],inf).asStream;

Pdef(\x,Pbind(\type,\midi,\chan,0,
\midiout,~mOut,
\scale,~scale,
\root,-12,
\degree,Pxrand([[0,3,5],[3,5,7],[4,6,8],[5,7,11]],inf),
\legato,1,
\amp,[{rrand(0.6,0.8)},{rrand(0.5,0.6)},{rrand(0.5,0.6)}]*0.7,    \dur,Prand([Pseq([1,1,1,1],1),Pseq([1,1,2],1),Pseq([1,2,1],1)],inf))).play(quant:1);

Pdef(\y,Pbind(\type,\midi,\chan,0,
\midiout,~mOut,
\scale,~scale,
\root,r,
\degree,a,
\legato,1,
\amp,{rrand(0.5,0.6)},
\dur,b)).play(quant:1);

10.wait;

inf.do({
if (0.7.coin,{
c=[[3,0,7,1,9,11,0,4],[[3,7],0,7,Rest,9,[0,11],0,4]].choose.scramble;
r.source=Pseq([[12,24].wchoose([0.7,0.3])],inf);
d=n.next;
a.source=Pseq([Pxrand(c,d),Pxrand([3,3,3,1,3,3],inf)]);
b.source=Pseq([Pseq([1/8],d),Pseq([1/2],inf)]);
});
rrand(3,4).wait;})}).play(quant:1);
};
).play(quant:1);

I’ve used a PatternProxy for the various notes degrees, velocity and duration, so to be able to modify it on the fly via the Task t, which controls the improvised part.

I came later to realize that it would be probably better to use Pfindur, instead that a Pseq to release the phrasing… I’ll try that soon. 😉

The MIDI has been routed to Ableton Live, and what you can hear in the following is its standard piano instrument.