How to get the argument dfaults of a SynthDef?

I have a synthdef

SynthDef.new(\new, { arg a=34, b=23 ; ... } 

How can i retrieve the argument defaults for the synthdef?

If you .add the SynthDef, then you can get the controls out of the SynthDescLib:

SynthDescLib.at(\myDefName).controls  // or .controlDict

The thing here is that SynthDef is not a repository of instruments. SynthDef’s job is to transmit synthesis structures to the server. In that, it’s a low-level object – a very complex object, but low-level. Its job is not to keep metadata about the instruments in a collection that you can poke through. So the question of “getting argument defaults from a SynthDef” is a reasonable idea, but the wrong target object.

SynthDescLib does store information about SynthDefs and their controls, so here is a better place to look.

hjh

Awesome! I’ll take a look.

One thing about the built in browser tutorials and tutorials, I’ve not come across this in them, but this has to be a common use case, getting argument defaults.

One thing that is common in SC culture is that users often expect, after they created something, for that thing to remember everything about its state.

This conflicts with the fact that many of the objects we use (Synth, Bus, Buffer) are thin abstraction layers for server data structures and these do not provide synchronous access (well, there’s bus.getSynchronous with a couple of caveats). For synths, NodeProxy does it right: every time you set a control, it remembers in its own nodeMap collection what you set. So you have immediate access through this collection. For buses, I have a class in my library that syncs the server and client side values.

The point is that just because it’s commonly asked “how to get stuff from server-related objects” doesn’t mean getting them in that way is the best idea. If the client is setting the value, then it’s the client’s job to remember that. The fact that we don’t have something in between Synth and NodeProxy to do this is a weakness.

For SynthDefs, I think it does make sense to look up argument names and their defaults. They naturally form a collection, but they may not have been written as a collection, and it’s reasonable to want access to the collection.

But FWIW this hasn’t been an “every new user” type of question.

hjh