I developed a small object (GitHub - tai-studio/NPModules: registry of small reusable module functions for NodeProxy) to allow to reuse predefined snippets in NodeProxy instances using the mechanism described in NodeProxy roles:
AbstractPlayControl.proxyControlClasses.put(\module, SynthDefControl);
AbstractPlayControl.buildMethods.put(\module, {
// ...
<something>.buildForProxy(proxy, channelOffset, index);
})
Everything works quite nicely, however, there is something I’d like to do that is is not possible, it seems:
AFAICS, the buildMethod needs to return something that is buildForProxy which sensible objects can be converted to by calling buildForProxy on them with appropriate parameters.
However, for some reason (well, to create a default behaviour), I would like to be able to remove the object altogether from within the definition, i.e. e.g.
Ndef(\a)[10] = \module -> nil
should remove the slot 10 of the Ndef.
Now, buildForProxy is not implemented on nil, therefore I am not able to do that…
Any help much appreciated ![]()
for testing purposes, here is a simplified version of the intended behavior not depending on my code:
AbstractPlayControl.proxyControlClasses.put(\nilTest, SynthDefControl);
AbstractPlayControl.buildMethods.put(\nilTest, #{ | func, proxy, channelOffset = 0, index |
func.buildForProxy(proxy, channelOffset, index);
});
// works as expected e.g.. for a function
Ndef(\a, \nilTest -> {SinOsc.ar})
Ndef(\a).sources
// -> there is something in the slot
Ndef(\a).clear; //clear everything in \a
// breaks for nil
Ndef(\a)[0] = \nilTest -> nil
// -> 'prepareForProxySynthDef' should have been implemented by Nil.
// would like it to mimick this behaviour
Ndef(\a)[0] = nil
// this works
Ndef(\a).clear; //clear everything in \a
Ndef(\a)[0] = \nilTest -> {nil}
// however, there is some source still in the slot:
Ndef(\a).sources