sorry, not in a position to test easily (i don’t use MIDI much myself) but typically pitch bend data is 14 bits so [0, 16383]
@qwoned ok yea, couple things
-
seems that midi bindings for pattern can only deal with one midi message type at once. or that’s all i can see so far. too bad. there might be a way to do it or you might just need an explicit updae function. (i tried Pchain but no dice.)
-
so e.g. it works to have one pattern doing \noteon and one doing \bend.
-
for \bend msg type, you want to use \val for the value. it’s in [0, 16383] with 8191 at center. this is normal for pitchbend.
MIDIClient.init;
m = MIDIOut(0);
(
~note = Pbind(
\type, \midi,
\midicmd, \noteOn,
\midiout, m,
\chan, 0,
\midinote, Prand([66, 67, 69, 65, 68],inf),
\sustain, Pbrown(0.01, 1.0, 0.125, inf),
\amp, Pexprand(30,90,inf)/127,
\dur, Pexprand(1.05, 0.07, inf)
);
~bend = Pbind(
\type, \midi,
\midicmd, \bend,
\midiout, m,
\val, Pexprand(30,16383,inf),
);
)
// this works fine...
~bend.play;
~note.play;
//....
~bend.stop;
~note.stop;
// but this unfortunately doesn't work.
// (AFAICT just creates a new Pattern,
// with all the key/value pairs medged from the first two,
// same as you had originally.)
Pchain(~note, ~bend).play;
i’m neither a big MIDI user or a big Pattern user myself, so that’s about all i got right now. (i would just use a raw Routine or Clock.sched - more verbose but easier for me as a procedural caveman.
(oh, also: your duration function is weird 'cause it has lo value bigger than hi value.)
@qwoned ok, here’s a caveman version that seems to basically work (though i haven’t closely checked for hung notes)
~note_stream = Prand([66, 67, 69, 65, 68], inf).asStream;
~sus_stream = Pbrown(0.01, 1.0, 0.125, inf).asStream;
~vel_stream = Pexprand(30,90,inf).asStream;
~bend_stream = Pexprand(30,16383,inf).asStream;
~dur_stream = Pexprand( 0.07, 1.05, inf).asStream;
r = Routine { inf.do {
var chan, note, vel, bend, sus, dur;
chan = 0;
note = ~note_stream.next;
sus = ~sus_stream.next;
vel = ~vel_stream.next;
bend = ~bend_stream.next;
dur = ~dur_stream.next;
[note, vel, bend, dur].postln;
m.bend(chan, bend);
// kinda dumb/bad way to do sustain. make this a function at least.
m.noteOn(chan, note, vel);
SystemClock.sched(sus, {m.noteOff(chan, note); nil});
dur.wait;
} }.play;