Noticeable latency/delay in playing Pdef


So, I’ve been developing some code for controlling things like synths and patterns with my Akai MPK mini. Today I wrote a simple MIDIdef that listens to noteOn msgs and .plays a Pdef I gave the fn previosly.
The thing is that I’m noticeing (noticing?) some delay between playing a key and the pattern being launched. The delay time variates randomly but goes up to something like half a second, which is really inconvenient. Its not a midi problem since I’ve tried launching a Pdef when evaluating a code block and it produces some similar delay, also the pdef is not quantized in any way.
My laptop is a Lenovo E470, running Antergos -> Gnu/Linux and supercollider 3.10
So, any thoughts/help/suggestion? (I’ve tried lowering the s.latency property with no luck :frowning: )



this is an interesting thing I haven’t noticed so far:

s.latency = 1;

Pdef(\a, Pbind(\dur, Pn(1, 1))).play

// resetting latency, not taken over by Pdef
s.latency = 0.05;

Pdef(\a, Pbind(\dur, Pn(1, 1))).play

// but taken over by Pbind !

Pbind(\dur, Pn(1, 1)).play

// workaround: clear the Pdef

Pbind(\dur, Pn(1, 1)).play

I don’t know if this is intended or a bug, Julian would have to say.
I don’t know if he’s around here, I’ll ask on the mailing list.

#3 is quantized to the nearest beat of whatever Clock you’re playing the Pdef on by default (similar to launching clips in Ableton). So if you haven’t specified otherwise, the Pdef will play on TempoClock.default, with its default tempo of one beat per second (60bpm), resulting in a delayed start of up to one second. You can override this behavior for an individual case by calling e.g.

Pdef(\foo).play(quant: 0)

You can change quantization behavior for all Pdefs with class method defaultQuant:


… or for an individual Pdef like so:


The documentation for Class Pdef has lots more regarding Pdefs and scheduling. Hope that helps.


OOOhhhh, I didn’t think the default quant was 1, rather than 0. Just tried it and it works! Thanks!
Guess I should’ve dig deeper in the Pdef help file :confused:


I did not know either, thanks