Sorry for posting this a second time - I realized I posted in the wrong area of the forum before.
I’m attempting to make a simple routing matrix. My thinking was the following code would work… but it seems that there is a problem starting and stopping a particular instance of a Synth within a toggle (g.free doesn’t seem to work)… Maybe I’m missing something obvious?
SynthDef(\routing,
{|busNum, inPort|
Out.ar(busNum, SoundIn.ar(inPort));
}).add;
({|inNum=64, outNum=64|
var win, inMenu, outMenu;
win = Window("", Rect(100, 200, 600, 600)).front;
h = StaticText(win, Rect(100, 0, 200, 30))
.string_("input to bus");
o = Array.fill(24, {|x| StaticText(win, Rect(10, 35+(20*x), 15, 15))
.string_(x)});
m= Array.fill2D(24, 24, {|x, y| Button(win, Rect(30+(20*x), 30+(20*y), 20, 20))
.states_([ ["", Color.black, Color.white], ["x", Color.white, Color.black]])
.action_({|v| var g;
if (v.value==1, {
g = Synth("routing", [x, y]);}, {g.free;});
});
});
e = Array.fill(24, {|x| StaticText(win, Rect(30+(20*x), 510, 25, 15))
.string_("m_"++x)});
s.plotTree;
}.value);