\midi event type with Pdefs

hey there,

I’ve been struggling to get a combination of Pdef and the \midi event type working.
This produces no midi output:

MIDIClient.init;
t = TempoClock.new((110/60));
m = MIDIClockOut("IAC-Treiber", "SC2Ableton", t)

Pdef(\midiTest,
	Pbind(
		\type, \midi,
		\midiout, ~toAbleton,
		\midicmd, \noteOn,
		\chan, 1,
		\midinote, 60,
		\amp,1,
	)
).play(t, quant:1)

while this is working perfectly:

(
p = Pbind(
		\type, \midi,
		\midiout, ~toAbleton,
		\midicmd, \noteOn,
		\chan, 1,
	\midinote, 60,
	\legato, 0.1
).play(t, quant:1)
)

p.stop

am i overlooking something very obvious? :slight_smile:

thank you!
schmolmo

I can’t reproduce the behavior.

To test, I made a little Pure Data patch to print incoming note data:

midi-in-test-pd

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;

And Pd prints:

print:  60 127
print:  60 0
print:  60 127
print:  60 0

So there is no problem with Pdef and MIDI output.

The problem must be something else.

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.

hjh

1 Like

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.

2 Likes

hey @jamshark70 and @shiihs,

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? :slight_smile: And to not have it send a “Song Position Pointer” on .start?

thanks again for the wonderful answers!

You would have to add a CmdPeriod function to reinitialize the MIDIClockOut on cmd-period. See CmdPeriod’s help file.

This is hardcoded into the start method:

And the author didn’t make it configurable.

The easiest way would be just to put // at the beginning of the songPtr line, save the file, and recompile the class library.

Or you could file a feature request at GitHub - crucialfelix/crucial-library: SuperCollider music programming library., though crucialfelix hasn’t been actively maintaining it for a while.

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.

hjh