Playing a parametrizable Pdef


I’ve got this Pdef that takes a couple of parameters, and I want to specify those parameters before playing it:

Pdef(\metronome, { |bars=1, tickdur=1|
	format("% - %",tickdur,bars).postln;
	Pbind(\instrument, \default,

What’s the best way to do this ?

My current solution is the following one, but I don’t like it:

Pbind(\type,\phrase,\instrument,Pn(\metronome,1),\bars,3,\tickdur,1,\dur,Pfunc({|ev| ev.bars*4}).trace(prefix:"total dur:")).play;

I don’t like because
1/ the duration is determined by the Pbind level and not by the Pdef
2/ even if computing what should be the right duration at the Pbind level, the Pdef doesn’t play till its end.

Actually I’m looking for a solution as neat as


Is this somehow achievable ?

Use the <> operator:

// the function is called in the incoming event as current environment, so parameters can be passed:
Pdef(\metronome, {
	var bars = ~bars ? 1;
	var tickdur = ~tickdur ? 1;
	format("% - %",tickdur,bars).postln;
		\instrument, \default,
		\dur, tickdur,
		\amp, Pn(Pser([1,0.5,0.5,0.5],4/tickdur),bars).trace

Pdef(\metrplayer, Pdef(\metronome) <> (bars: 1, tickdur: 0.1)).play

I tried a lot of versions, but not this one. Thanks.