I’d like to create a GUI where the order of SynthDefs can be saved and recalled.
I know that this would be simplified by using a NodeProxy, but I ran into issues there and I’m wondering how and if the following would be possible.
The attached example has three synthdefs. Two are effects. One is an audio source.
The order that the buttons are clicked obviously determine the order-of-operations.
I’m wondering if it is possible to “save” different arrangements of these Synths in a preset that could be recalled. At the moment, the modules don’t have any particular arguments - but I would like to expand this to also store and recall arguments.
My instinct is that each button would have an additional function where it sent incremental order to a collected list, but I have no idea how that list would be formatted or recalled.
(
SynthDef("audio",
{|out|
var sig = LFTri.ar(Lag.ar(LFNoise0.ar(4).range(200, 800),1))*Decay.ar(Dust.ar(1));
Out.ar(out, sig);
}).add;
SynthDef("filter1",
{|in, out|
var sig;
sig = Decimator.ar(In.ar(in), 1000, 4);
Out.ar(out, sig);
}).add;
SynthDef("filter2",
{|in, out|
var sig;
sig = Ringz.ar(In.ar(in), 200, 2);
Out.ar(out, sig*0.2);
}).add;
)
(
w = Window("").front;
a = Button(w, Rect(20, 20, 90, 20)).states_([["audio on", Color.black, Color.white], ["audio off", Color.white, Color.black]]);
a.action_({|m|
if (m.value==1, {x = Synth("audio")},
{x.free;});
});
b = Button(w, Rect(20, 50, 90, 20)).states_([["filter1 on", Color.black, Color.white], ["filter1 off", Color.white, Color.black]]);
b.action_({|m|
if (m.value==1, {y = Synth("filter1");},
{y.free;}
);
});
c = Button(w, Rect(20, 80, 90, 20)).states_([["filter2 on", Color.black, Color.white], ["filter2 off", Color.white, Color.black]]);
c.action_({|m|
if (m.value==1, {z = Synth("filter2");},
{z.free;}
);
});
)