Why setting \id in Event \finish doesn't seem to work (for type: \set anwyay)?

I’ve tried to do a simplified version of

which would not register an event type but use \finish instead. Alas it doesn’t seem to work: \set doesn’t seem to see the id set, even though I can read it later in the callback. Any ideas why (neither of these) works properly?

// Make a dummy Ndef for testing
(Ndef(\jpjp, {|a1, a2|
	[a1, a2].poll(0.5);
}))

(Pbind(
	\type, \set,
	\ndef, \jpjp,
	\finish, { ~id = Ndef(~ndef).group.nodeID; ~id.postln }, 
	\a1, Pwhite(0.0,1.0, 3),
	\a2, Pwhite(0.0,1.0),
	\callback, { (~id.asString + "called back" + Main.elapsedTime).postln }
).play;) // doesn't set

Output like

-> Ndef('jpjp')
UGen Array [0]: 0
UGen Array [1]: 0
UGen Array [0]: 0
UGen Array [1]: 0
-> an EventStreamPlayer
1077
1077 called back 174952.1678335
UGen Array [0]: 0
UGen Array [1]: 0
1077
1077 called back 174953.16815606
1077
1077 called back 174954.16821785
UGen Array [0]: 0
UGen Array [1]: 0

The id clearly gets set, but that doesn’t actually seem to influence the actual \set event… Any ideas why this doesn’t work?

Also, I’ve tried:

(Pbind(
	\type, \set,
	\ndef, \jpjp,
	\finish, { |ev| ev.id = Ndef(~ndef).group.nodeID; ev.id.postln }, // still not set in the actual event!
	\a1, Pwhite(0.0,1.0, 4),
	\a2, Pwhite(0.0,1.0),
	\callback, { |ev| (ev.id.asString + "called back" + Main.elapsedTime).postln }
).play;)

but it doesn’t work either.

The problem was that \set seems undable to figure out args for node produced by Ndef, so args is needed in the Event

(Pbind(
	\type, \set,
	\ndef, \jpjp,
	\finish, { ~id = Ndef(~ndef).group.nodeID; ~id.postln }, // not set in the actual event; not valueEnvir
	\a1, Pwhite(0.0,1.0, 3),
	\a2, Pwhite(0.0,1.0),
	\args, [\a1, \a2], //needed!
	\callback, { (~id.asString + "called back" + Main.elapsedTime).postln }
).play;)

The code I tried to simplify did have something like

~args = Ndef(~ndef).controlKeys(except: ~exceptArgs);

Yeah, we should definitely improve the documentation on this.

It’s basically always better to specify args for the set event type, to avoid event default values.

hjh

2 Likes