Markov Chain SynthDef
Wednesday, December 15, 2004, 11:28 PM
//example markov chain SynthDef
a = SynthDef("markov_chain",{ arg w1=0.0, w2=0.5, w3=0.5;
var trig, index, derPitch, previousIndex;
trig = Impulse.kr(6);
// access the last cycle's index output
previousIndex = LocalIn.kr(1);
derPitch=[
[0,0,1], //w1
[1,0,0], //w2
[0,1,0] //w3
];
index = TWindex.kr(trig, Select.kr(previousIndex, derPitch));
// make the new index available to the next cycle
LocalOut.kr(index);
Out.ar(0,
SinOsc.ar(
Select.kr(index,[400, 500, 600]),
0, 0.2
)
)
}).play;