One Pattern Playing Multiple Synths


For the instrument case, you unfortunately can’t let the flop figure it ALL out :slight_smile:
The problem is — as it is, the flop happens once you have produced an argument list from your event, e.g.:

\freq, [100, 200]

… becomes

[\freq, [100, 200]]

…which flops to:

[[\freq, 100], [\freq, 200]]

The tricky thing is, that second form is produced by the value in \instrument (via ~msgFunc): you need to get the instrument in order to produce the arg array.

I think the totally-correct answer here would require: for arrayed instrument cases, you have to (for each instrument) grab event values from each key using something like ~event[key].wrapAt((n * instrumentCount) + instrumentIndex), where your n iterates until you’re at the MAX size of the largest array in your event. THEN you flop the arrays for each instrument. So, for something like:

\instrument, [\foo, bar],
\freq, [100, 200, 300],
\amp, [1, 2, 3, 4]

…would give you roughly:

[\foo, [\freq, [100, 300], \amp, [1, 3]]],
[\bar, [\freq, [200, 100], \amp, [2, 4]]]

… which flops out to:

   [\foo, [\freq, 100, \amp, 1]],
   [\foo, [\freq, 300, \amp, 3]],
   [\bar, [\freq, 200, \amp, 2]],
   [\bar, [\freq, 100, \amp, 4]],

There may be a combinations of flops and array ops in SC already that can deal with this more elegantly… I’d love to hear if someone can figure out how to get from my initial Event example to something like that final array, which is about what we need to send a message to the server.

(This is even hiding some complexity - remember that in order to get to that second representation, e.g. one array per instrument - you have to call ~msgFunc on the Event. So, you really need to produce something like [\foo, (\freq, [100, 300], \amp, [1, 3])] in that second step - where the event needs to be passed to the ~msgFunc)