Pbind(def) - ensuring minimum release time

I’m working with a disklavier, controling it with patterns (Pbindef) via midi. A mechanical nature of the instrument causes that there is minimum time between NoteOn and NoteOff in order to hammer actually strike the string in the piano. If the NoteOff arrives too soon after NoteOn the motor already starts retracting the mechanism of hammer before it had touched the string. This means that very fast sequences cannot be played via a single Pbind unless there’s a legato of more than 1 (possibly 2 or more) which ensures that NoteOff arrives late enough despite the fact that other notes were already being played further on. This legato then does not work well if there are longer notes (durations) in the sequence, and it seems tedious to track short / long notes.

I was wondering if there’s any possible way to make this absolute time between NoteOn and NoteOff (gate 1 and 0?) somehow limited with some kind of minimum? This would make it very simple to have very short and long notes in a (algorithmic) sequence without extra tracking.

Why? I think it’s the way to go.

(
SynthDef(\synth_saw, {|out = 0, freq = 440, att = 0.01, rel = 0.01, pan = 0, amp = 0.1, gate = 1|
	var src = Saw.ar(freq, mul: amp);
	var env = EnvGen.ar(Env.asr(att, 1, rel), gate, doneAction: 2);
	OffsetOut.ar(out, Pan2.ar(src, pan) * env)
}).add;
)

(
Pbind(
	\instrument, \synth_saw,
	\dur, Pseq([0.05, 0.7], inf) * Pwhite(0.5, 2),
	\legato, Pif(Pkey(\dur) > 0.2, 1, 0.3 / Pkey(\dur)),
	\midinote, Pseq([50, Pwhite(60.0, 90, 1)], inf)
).trace.play
)

// maybe even more intuitive with sustain key
(
Pbind(
	\instrument, \synth_saw,
	\dur, Pseq([0.05, 0.7], inf) * Pwhite(0.5, 2),
	\sustain, Pif(Pkey(\dur) > 0.2, Pkey(\dur), 0.3),
	\midinote, Pseq([50, Pwhite(60.0, 90, 1)], inf)
).trace.play
)

The examples assume tempo 1 (beats equal seconds), the principle should work similarily with MIDI.

// 50 ms minimum, you can use a different value
\sustain, Pfunc { |ev| max(0.05, ev.use { ~sustain.value }) }

I don’t think there’s a need for Pif here. (Or, if use is ugly, perhaps: \sustain, max(0.05, Pkey(\dur) * Pkey(\legato) * Pkey(\stretch)).)

BTW I’m guessing about the minimum sustain time – you said “very fast sequences cannot be played… unless there’s a legato of more than 1 (possibly 2 or more)” but the \dur of these very fast sequences is not stated anywhere, so I don’t know exactly what “legato = 2” translates to. Not a difficult problem, though – just substitute a reasonable value in the above function.

hjh