I’m trying to work on a GUI where I can type in a synthDef name and then link that to a sequence. I have the input loading from the textField in the post window, but can’t seem to get the named synthDef to play when I press the button. Am I getting something wrong about data types? Synths are definitely on the server.
And follow up question - as part of the sequencer I’m trying to get certain points of the sequences to trigger multiple Synths or other changes. I’m from a Pure Data background, and I’m used to just sending a “bang”. Is there any kind of equivalent that might be useful for this problem? Starting to get a handle on some aspects of Supercollider after a few years, but still miss this quite direct way of connecting events. I’m using language-side routines using s.bind for synths as I prefer the flexibility (somewhat following Nathan Ho’s approach), but open to suggestions.
(
SynthDef(\test1,{|freq=100|
var sig, env;
sig = SinOsc.ar(freq,mul: 0.1);
env = Env.perc(0.001,0.1,curve: -4).ar(Done.freeSelf);
Out.ar(0, sig*env);
}).add;
SynthDef(\test2,{|freq=200|
var sig, env;
sig = SinOsc.ar(freq,mul: 0.1);
env = Env.perc(0.001,0.1,curve: -4).ar(Done.freeSelf);
Out.ar(0, sig*env);
}).add;
)
(
var window,textField2,loadSynthDef;
Window.closeAll;
//overall window
window = Window.new("Sequencer", Rect(10, 10, 500, 500),scroll: true)
.front
.alwaysOnTop_(true);
//wide sequencer options panel
e = CompositeView(window, Rect(25, 25, 400, 300)).background_(Color.rand);
e.decorator = FlowLayout(e.bounds, 15@15, 0@0);
e.visible_(1);
loadSynthDef = ({
var synthName, btn;
textField2 = TextField(e,Rect(25, 225, 200, 50))
.action_({|textContent|
synthName = textContent.value;
("synthName name is: "++synthName).postln;
});
btn = Button(e, Rect(25, 25, 20, 50))
.action_({
{
Synth(synthName.asSymbol);
}.defer;
});
});
loadSynthDef.();
)
//test synths work
Synth(\test1);
Synth(\test2);