Single quantized events: Best practice? Muting Pdefs possible?

Hi list,

in some live-coding setup, I have the need to schedule a single crash
cymbal hit at the next bar’s downbeat. I wonder what the best way to do
this would be?

My clock runs at bars per minute, so its tempo is 130/60/4 = 0.4516

My currently perfered way is to specify a single-event Pdef in advance,
playing a sampler SynthDef:

(Pdef(\ppCrsh, Pbind(
        \instrument, \pheely, \out, ~toLimiter, \buf, ~bCrsh,
        \amp, Pseq([-12]),
        \dur, 1,
        \legato, 4
)););

and call that later using

Pdef(\ppCrsh).play(quant:1);

Using an Event I can not seem to find a quantization argument for
().play;
However, the docs for Event mention an undocumented .synchWithQuant(quant)
method.

Oh, and how would I mute a Pdef? It does not seem to have a .mute
method.

Thanks for all ideas!
Peter

This method is for handling the timingOffset property, and doesn’t influence clock scheduling.

The current design is that patterns are scheduled on the clock (with quant control), while the events produced by a pattern play at the time that is controlled by the pattern (“Right Now”).

You could write a function to schedule the play of an event (untested):

~playEventAtQuant = { |event, quant, clock(thisThread.clock)|
    clock.schedAbs(
        quant.nextTimeOnGrid(clock),
        {
            event.play;
            nil  // prevent rescheduling (maybe not necessary, but, ok for safety)
        }
    );
};

That is, that Event:play doesn’t natively support it shouldn’t be taken as a limitation.

hjh

You can do this, a bit wasteful but does the job:

(
~mute = 0;

x = Pbind(
	\dur, 0.2,
	\amp, 0.1 * Pfunc { 1 - ~mute }
).play
)


~mute = 1;

~mute = 0;

x.stop

best

Daniel

I usually do \isOn, Pfunc { if (~mute == 0) { \note } { \rest } } which does the same job but without sending the values to the synth (if it is a synth-playing pattern) which for my use is preferable.

1 Like

That looks indeed better for simple muting, never considered it !
With the amp approach, stepped muting or fades would be further options, but I actually didn’t use it that way.

1 Like

For future readers:

I realize it might be slightly confusing to use the \note symbol here as this a special meaning for the \type key, and because the Event prototype ‘type’ defaults to \note.

In reality you can put any string other than \ or \rest (both interpreted as a rest) or number instead of \note, \note is just a dummy value. You also have to make sure that you do NOT have a synth input named \isOn (or whatever you choose to name you mute key).

When ~mute == 0, all values produced by the pattern (on those under the hood by Event protoype) will be sent to the synth. Since none of my SynthDefs have a synth input (arg) named \isOn (very intentionally), the values are simply ignored, which is common practice and very handy in many cases.

So \isOn, Pfunc{ if (~mute == 0) { 9987.2 } { \rest } } will have the same effect, here the dummy value ignored by the synth happens to be 9987.2.

1 Like