Using Ndef as instrument in Pbind

That’s actually desirable most of the time, i.e. not getting the kitchen sink in every Pdef; keep in mind that the Pdef object/source isn’t always a simple Pbind, so there’s not even a obvious way to do this in general as it’s not clear what the instrument is. (The Pbind could be wrapped in a Pchain, Ppar etc.)

When I got started I used to use Ndefs directly, but that’s actually less flexible than defining SynthDefs first. You can easily use syndefs in Ndefs, but getting the sythnDesc for a Ndef (defined directly) is a pain. I don’t even rember how it’s done, if I ever figured it out. On the other hand you can get the key/values for a Ndef. I.e. if you want to auto-import all the SynthDef (or Ndef) params into a Pdef.envir (or any Environment for that matter) you can do something like

Ndef(\bah, \default) // uses SynthDef \default

k = Ndef(\bah).controlKeysValues() // -> [ freq, 440.0, amp, 0.10000000149012, pan, 0.0 ]

e = ()

e.putAll(k) // -> ( 'freq': 440.0, 'pan': 0.0, 'amp': 0.10000000149012 )

Pdef(\meh).envir = e

Pdef(\meh).gui

// Getting them from the SynthDesc (directly) instead

e = ()

SynthDescLib.global.synthDescs.at(\default).controls do: { |c| e[c.name] = c.defaultValue };

e // -> ( 'out': 0.0, 'gate': 1.0, 'freq': 440.0, 'amp': 0.10000000149012,  'pan': 0.0 )

The latter approach has no “smarts” like Ndef.controlKeysValues which filters out some things like out and gate by default.

2 Likes