3 if (Platform.makeSynthDescWindowAction.notNil) {
4 ^Platform.makeSynthDescWindowAction.value(this)
11 var w, startButton, sliders;
12 var synth, cmdPeriodFunc;
13 var usefulControls, numControls;
14 var getSliderValues, gui;
18 usefulControls = controls.select {|controlName, i|
20 ctlname = controlName.name.asString;
21 (ctlname != "?") && (msgFuncKeepGate or: { ctlname != "gate" })
24 numControls = usefulControls.collect(_.defaultValue).flatten.size;
25 sliders = IdentityDictionary(numControls);
28 w = gui.window.new("another control panel", Rect(20, 400, 440, numControls * 28 + 32));
29 w.view.decorator = FlowLayout(w.view.bounds);
31 w.view.background = Color.rand(0.5, 1.0);
33 // add a button to start and stop the sound.
34 startButton = gui.button.new(w, 75 @ 24);
35 startButton.states = [
36 ["Start", Color.black, Color.green],
37 ["Stop", Color.white, Color.red]
44 usefulControls.do {|controlName, i|
45 var ctlname = controlName.name.asString;
47 if(ctlname[1] == $_ and: { "ti".includes(ctlname[0]) }) {
48 ctlname = ctlname[2..];
51 if (sliderEntry.isArray) {
52 envir.put(controlName.name, sliderEntry.collect(_.value));
54 envir.put(controlName.name, sliderEntry.value);
63 startButton.action = {|view|
64 if (view.value == 1) {
66 synth = Synth(name, getSliderValues.value.postln).register;
78 // create controls for all parameters
79 usefulControls.do {|controlName|
80 var ctlname, ctlname2, capname, spec, controlIndex, slider;
81 ctlname = controlName.name;
82 capname = ctlname.asString;
83 capname[0] = capname[0].toUpper;
84 w.view.decorator.nextLine;
85 ctlname = ctlname.asSymbol;
86 if((spec = metadata.tryPerform(\at, \specs).tryPerform(\at, ctlname)).notNil) {
89 spec = ctlname.asSpec;
93 slider = EZSlider(w, 400 @ 24, capname, spec,
95 if(synth.isPlaying) { synth.set(ctlname, ez.value) }
96 }, controlName.defaultValue);
98 spec = ControlSpec(-1e10, 1e10);
99 if (controlName.defaultValue.isNumber) {
100 slider = EZNumber(w, 400 @ 24, capname, spec,
102 if(synth.isPlaying) { synth.set(ctlname, ez.value) }
103 }, controlName.defaultValue)
105 slider = Array(controlName.defaultValue.size);
106 controlName.defaultValue.do {|value, i|
107 slider.add(EZNumber(w, 400 @ 24, "%[%]".format(capname, i), spec,
109 if(synth.isPlaying) { synth.set(controlName.index + i, ez.value) }
114 sliders.put(ctlname, slider)
117 // set start button to zero upon a cmd-period
118 cmdPeriodFunc = { startButton.value = 0; };
119 CmdPeriod.add(cmdPeriodFunc);
121 // stop the sound when window closes and remove cmdPeriodFunc.
124 CmdPeriod.remove(cmdPeriodFunc);
127 ^w.front; // make window visible and front window.