Using \legato-argument in Pmono

hey there,

does anybody know a way to use the \legato argument in a Pmono, so that note lengths can be shorter than the \dur? :slight_smile:

(
SynthDef(\test, {|out = 0, gate = 1, amp = 1, freq = 342| 
	var sig = SinOsc.ar(freq) * EnvGen.kr(Env.adsr(), gate);
	Out.ar(out, sig);
}).add;
)

// does not work as i intended to...
Pmono(\test, \degree, Pxrand([1,2,3], inf), \dur, 0.5, \legato, 0.1).play;

all the best,
moritz

You need PmonoArtic for that - quoting from the Pmono help file:

Plays one instance of a Synth. […] There is just one node for the duration of the entire pattern, and it will sustain through each event. If a monophonic phrase requires staccato notes or re-articulation between some notes, see PmonoArtic.

(
SynthDef(\test, {|out = 0, gate = 1, amp = 1, freq = 342| 
	var sig = SinOsc.ar(freq) * EnvGen.kr(Env.asr(releaseTime: 0.05), gate); // slight tweak to the Envelope, so the legato amount can be heard more clearly
	Out.ar(out, sig ! 2 * -15.dbamp);
}).add;
)

// works
PmonoArtic(\test, \degree, Pxrand([1,2,3], inf), \dur, 0.5, \legato, 0.1).play;

Also, I recommend using EnvGen.ar, not .kr - it’s always caused weird issues for me down the line, and the CPU hit is usually negligible…

That’s correct – PmonoArtic.

FWIW, Pmono and PmonoArtic are for slurs. If all the notes are shorter than \dur, then there are no slurs and PmonoArtic will behave exactly like Pbind (because each short note requires a new attack for the following note). The difference becomes apparent for notes where legato > dur.

~nodesEnded = 0;

OSCdef(\rel, { ~nodesEnded = ~nodesEnded + 1; "Num nodes: %\n".postf(~nodesEnded) }, '/n_end', s.addr);

p = Pbind(\degree, Pseries(0, 1, 5), \dur, 0.5, \legato, 0.1).play;
Num nodes: 1
Num nodes: 2
Num nodes: 3
Num nodes: 4
Num nodes: 5

p = PmonoArtic(\default, \degree, Pseries(0, 1, 5), \dur, 0.5, \legato, 0.1).play;
Num nodes: 6
Num nodes: 7
Num nodes: 8
Num nodes: 9
Num nodes: 10

// but this may be fewer than 5 nodes
p = PmonoArtic(
	\default,
	\degree, Pseries(0, 1, 5),
	\dur, 0.5,
	\legato, Pwrand([0.1, 1.01], [0.7, 0.3], inf)
).play;

hjh

1 Like

thank you @bovil43810 @jamshark70!!! :slight_smile: