To test, I made a little Pure Data patch to print incoming note data:
Then in SC:
MIDIClient.init;
// I'm in Linux, where *everything* is an IAC bus
// This is connecting to Pd in my system
m = MIDIOut(0).connect(1);
(
Pdef(\midiTest,
Pbind(
\type, \midi,
\midiout, m,
\midicmd, \noteOn,
\chan, 1,
\midinote, 60,
\amp,1,
)
).play(quant:1)
)
Pdef(\midiTest).stop;
Is it possible that you might inadvertently stopped the TempoClock? (If you hit cmd-dot, any TempoClocks that are not marked as permanent will be stopped.)
You might try adding a trace: Pdef(\name, Pbind( /* stuff... */ ).trace).play to see if the Pbind is generating data at all.
A problem you might have is that ~toAbleton is not yet initialized at the time of compiling your pattern.
If that is the case, you may want to use \midiout, Pfunc { ~toAbleton } instead, which will always use the latest value of ~toAbleton as opposed to just using the value it had when you compiled the pattern.
When I did that not so long ago I had the “very weird” behavior that I got no midi output when running my code for the first time, and normal midi output when running it a second time.
thank you for your responses! you were right, there must have been an error somewhere else, everything worked as expected after i gave it another shot today. the pfunc also seems to make it more fail-proof, thanks!
on another note: is there a trick to make a MIDIClockOut permanent? And to not have it send a “Song Position Pointer” on .start?
One other question, though – is there a reason why you’re using MIDI clock instead of Ableton Link to sync with Live? MIDI clock is the 80s way. Link is the 2010s+2020s way.