Hi all -
I am building off a recent discussion of how to use incoming MIDI to use in Pattern language: Control Patterns with MIDI
I’ve added some scaffolding to the initial code - to make a button that “records” incoming MIDI to an array - and then plays it back, as a pattern, when clicked again.
I’ll add the code below.
My questions, though: How might one record rhythms in a similar manner? Also, is it possible to record incoming MIDI as chords?
(
var ko, butt1, mfun;
ko = Window("clerk", Rect(0, 450, 250, 300));
MIDIClient.initialized.isNil.or(MIDIClient.initialized.not).if {
MIDIClient.init;
MIDIIn.connectAll
};
butt1 = Button(ki, Rect(10, 30, 40, 40));
butt1.states = [["", Color.green, Color.green], ["", Color.red, Color.red]];
butt1.action = ({|valo, arri, mid, new|
valo.value.postln;
case
{valo.value == 0} { ~arri = [];
~baz.stop;
mfun = MIDIFunc.noteOn({
|vel, mnote|
~arri= ~arri.add(mnote);
~arri.postln;
})}
{valo.value == 1} {mfun.free;
~baz = Pbind(
\midinote, Plazy({Pseq(~arri, 1) })
).asEventStreamPlayer;
~baz.play;
};
});
ko.background = Color.black;
ko.front;
);