Calling .set() on group does not call .set() on contained synths?

I had believed as gospel my whole life that the point of Groups is that you can control the Synths within them by setting stuff on the Group. But this appears not to be the case:

// Run line-by-line:
~group = Group();
~synth = Synth(\default,args:[\freq,200,target:~group]);
~synth.set(\amp,0.5); // Works, of course
~group.set(\amp,0); // Err, nope
~synth.free;
~group.free;

Was I tragically mistaken the whole time, or is there a way to do this that I don’t see?

I’m sorry, the smallest syntax error and SC silently fails.

Should be:

~synth = Synth(\default,args:[\freq,200],target:~group);

Not:

~synth = Synth(\default,args:[\freq,200,target:~group]);

The wider problem I’ve been having is that I have a class that wraps a Group, and which exposes a set method of its own which is intended to simply forward to the parameters of the set method of the wrapped Group:

// Method defined by my wrapper class:
set {
   |... parameters|
   prGroup.set(parameters);
}

This forwarding is not working, and I now suspect it’s something fiddly to do with the handling of the ... parameters. Can anyone help? I’d love to go to bed at some point. :slight_smile:

Additional info: if I expose the Group from my wrapper like this:

group {
  ^prGroup;
}

Then I can set parameters on the exposed Group and that does work as expected:

myWrapper.group.set(\gate,0);

So I’m pretty sure it’s related to the syntax of my wrapper class’s set method.

Okay, so reading some of the base class source code I found out it’s this:

set {
    |... parameters|
    prGroup.set(*parameters);
}

Sorry to ask question about such basic things, but these syntactical issues are basically unsearchable.

According to the documentation, the correct code is:

~synth = Synth(\default, args: [\freq, 200], target: ~group);

Since the order of arguments corresponds to the order defined in the class method (and shown in the help documentation), it is not necessary to use argument keywords. Therefore, the following version is also correct and is recommended for its simplicity:

~synth = Synth(\default, [\freq, 200], ~group);

Please refer to the video in the link below, where group.free works correctly on my end:
https://www.dropbox.com/scl/fi/w44jani806b6juw7oh90p/group.set.mov?rlkey=tye05rfxeuq1ojfaxfvqq5otq&st=zv58bcfx&dl=0

Please let me know if I’ve misunderstood what you’re asking for.

Hi @prko, thank you, I did get to the bottom of this in the end. It was a syntax issue.

It’s true that most symbols are not searchable (and for this usage, there’s no good way to know what to search for without knowing it in advance), but, there is a Symbolic Notations help file. * syntax for distributing an array of argument values is covered in there.

hjh

1 Like

I think the explanation of *Array in the documentation is a bit too abstract, and I could not find any explanation of arg ... or |...|. So I wrote a few simple examples below.

// Use ... when the inputs are not fixed in advance,
// either in number or in keywords.
// Any extra arguments are collected into one array.


// All input values go into rest.
{ arg ... rest; rest }.(1, 2, 3, 4, 5)
-> [1, 2, 3, 4, 5]

// The same, using pipe syntax.
{ |... rest| rest }.(1, 2, 3, 4, 5)
-> [1, 2, 3, 4, 5]


// a gets the first value.
// All remaining values go into rest.
{ arg a ... rest; [a, rest] }.(1, 2, 3, 4, 5)
-> [1, [2, 3, 4, 5]]

// The same, using pipe syntax.
{ |a ... rest| [a, rest] }.(1, 2, 3, 4, 5)
-> [1, [2, 3, 4, 5]]


// a gets 1, b gets 2.
// All remaining values go into rest.
{ arg a, b ... rest; [a, b, rest] }.(1, 2, 3, 4, 5)
-> [1, 2, [3, 4, 5]]

// The same, using pipe syntax.
{ |a, b ... rest| [a, b, rest] }.(1, 2, 3, 4, 5)
-> [1, 2, [3, 4, 5]]

// Commas may be omitted here.
{ |a b ... rest| [a, b, rest] }.(1, 2, 3, 4, 5)
-> [1, 2, [3, 4, 5]]


// A function with default values.
f = { |a=0, b=1| a + b }

f.(1, 2)
-> 3

// The same call, using argument keyword.
f.(a: 1, b: 2)
-> 3

// The same call, by expanding an array into arguments.
f.(*[1, 2])
-> 3

// Different: the whole array is passed as a.
f.([1, 2])
-> [2, 3]

Yes right now it isn’t possible to search things like this. While @prko s pr is definitely an improvement, it wouldn’t have helped you much because you didn’t know what term to search for.

I think this would be where an lsp could really help as if you hover over the syntax, you could get a link to some documentation. @dscheiba what do you think?