2009-01-02 19:06:25 +00:00
|
|
|
+ Server {
|
|
|
|
makeEmacsWindow { arg w;
|
|
|
|
var active, booter, killer, makeDefault, running, booting, stopped;
|
|
|
|
var recorder, scoper;
|
|
|
|
var countsViews, ctlr;
|
|
|
|
var dumping=false, startDump, stopDump, stillRunning;
|
2009-09-26 06:17:48 +00:00
|
|
|
|
2009-01-02 19:06:25 +00:00
|
|
|
if (emacsbuf.notNil, { ^emacsbuf.front });
|
2009-09-26 06:17:48 +00:00
|
|
|
|
2009-01-02 19:06:25 +00:00
|
|
|
if(w.isNil,{
|
|
|
|
w = emacsbuf = EmacsBuffer("*" ++ name.asString ++ " server*");
|
|
|
|
});
|
2009-09-26 06:17:48 +00:00
|
|
|
|
2009-01-02 19:06:25 +00:00
|
|
|
if(isLocal,{
|
|
|
|
booter = EmacsButton(w, ["Boot","Quit"]);
|
2009-09-26 06:17:48 +00:00
|
|
|
booter.action = { arg value;
|
2009-01-02 19:06:25 +00:00
|
|
|
if(value == 1, {
|
|
|
|
booting.value;
|
|
|
|
this.boot;
|
|
|
|
});
|
|
|
|
if(value == 0,{
|
|
|
|
this.quit;
|
|
|
|
});
|
|
|
|
};
|
2016-05-07 14:19:27 +00:00
|
|
|
booter.value=this.serverRunning.binaryValue;
|
2009-09-26 06:17:48 +00:00
|
|
|
|
2009-01-02 19:06:25 +00:00
|
|
|
killer = EmacsButton(w, ["K"], { Server.killAll });
|
|
|
|
killer.enabled = false;
|
|
|
|
});
|
2009-09-26 06:17:48 +00:00
|
|
|
|
2009-01-02 19:06:25 +00:00
|
|
|
active = EmacsText(w, this.name.asString, 12, \center);
|
|
|
|
// active.background = Color.black;
|
2016-05-07 14:19:27 +00:00
|
|
|
if(this.serverRunning,running,stopped);
|
2009-01-02 19:06:25 +00:00
|
|
|
|
|
|
|
makeDefault = EmacsButton(w, ["-> default"], {
|
|
|
|
thisProcess.interpreter.s = this;
|
|
|
|
Server.default = this;
|
|
|
|
});
|
|
|
|
|
|
|
|
w.newline;
|
2009-09-26 06:17:48 +00:00
|
|
|
|
2009-01-02 19:06:25 +00:00
|
|
|
recorder = EmacsButton(w, ["prepare rec","record >","stop []"], {
|
|
|
|
if (recorder.value == 1) {
|
|
|
|
this.prepareForRecord;
|
|
|
|
}{
|
|
|
|
if (recorder.value == 2) { this.record } { this.stopRecording };
|
|
|
|
};
|
|
|
|
});
|
2009-09-26 06:17:48 +00:00
|
|
|
|
2009-01-02 19:06:25 +00:00
|
|
|
recorder.enabled = false;
|
2009-09-26 06:17:48 +00:00
|
|
|
|
2009-01-02 19:06:25 +00:00
|
|
|
stillRunning = {
|
|
|
|
SystemClock.sched(0.2, { this.stopAliveThread });
|
|
|
|
};
|
|
|
|
w.defineKey("n", { this.queryAllNodes })
|
2016-05-07 14:19:27 +00:00
|
|
|
.defineKey(" ", { if(this.serverRunning.not) { this.boot } })
|
2009-01-02 19:06:25 +00:00
|
|
|
.defineKey("d", {
|
2009-09-26 06:17:48 +00:00
|
|
|
startDump = {
|
2009-01-02 19:06:25 +00:00
|
|
|
this.dumpOSC(1);
|
|
|
|
this.stopAliveThread;
|
|
|
|
dumping = true;
|
|
|
|
CmdPeriod.add(stillRunning);
|
|
|
|
};
|
|
|
|
stopDump = {
|
|
|
|
this.dumpOSC(0);
|
|
|
|
this.startAliveThread;
|
|
|
|
dumping = false;
|
|
|
|
CmdPeriod.remove(stillRunning);
|
|
|
|
};
|
|
|
|
if(dumping, stopDump, startDump)
|
|
|
|
});
|
2009-09-26 06:17:48 +00:00
|
|
|
|
2009-01-02 19:06:25 +00:00
|
|
|
if (isLocal, {
|
|
|
|
running = {
|
|
|
|
// active.stringColor_(Color.red);
|
|
|
|
booter.value=1;
|
|
|
|
recorder.enabled = true;
|
|
|
|
killer.enabled = true;
|
|
|
|
};
|
|
|
|
stopped = {
|
|
|
|
// active.stringColor_(Color.grey(0.3));
|
|
|
|
booter.value=0;
|
|
|
|
recorder.value=0;
|
|
|
|
recorder.enabled = false;
|
|
|
|
killer.enabled = false;
|
|
|
|
};
|
|
|
|
booting = {
|
|
|
|
// active.stringColor_(Color.yellow(0.9));
|
|
|
|
//booter.setProperty(\value,0);
|
|
|
|
};
|
2009-09-26 06:17:48 +00:00
|
|
|
|
2009-01-02 19:06:25 +00:00
|
|
|
w.onClose = {
|
|
|
|
emacsbuf = nil;
|
|
|
|
ctlr.remove;
|
|
|
|
};
|
2009-09-26 06:17:48 +00:00
|
|
|
},{
|
2009-01-02 19:06:25 +00:00
|
|
|
running = {
|
|
|
|
// active.background = Color.red;
|
|
|
|
recorder.enabled = true;
|
|
|
|
};
|
|
|
|
stopped = {
|
|
|
|
// active.background = Color.black;
|
|
|
|
recorder.value=0;
|
|
|
|
recorder.enabled = false;
|
|
|
|
};
|
|
|
|
booting = {
|
|
|
|
// active.background = Color.yellow;
|
|
|
|
};
|
|
|
|
w.onClose = {
|
|
|
|
this.stopAliveThread;
|
|
|
|
ctlr.remove;
|
|
|
|
};
|
|
|
|
});
|
2016-05-07 14:19:27 +00:00
|
|
|
if(this.serverRunning,running,stopped);
|
2009-09-26 06:17:48 +00:00
|
|
|
|
2009-01-02 19:06:25 +00:00
|
|
|
w.newline;
|
|
|
|
|
2009-09-26 06:17:48 +00:00
|
|
|
countsViews =
|
2009-01-02 19:06:25 +00:00
|
|
|
#[
|
2009-09-26 06:17:48 +00:00
|
|
|
"Avg CPU: ", "Peak CPU: ",
|
2009-01-02 19:06:25 +00:00
|
|
|
"UGens: ", "Synths: ", "Groups: ", "SynthDefs: "
|
|
|
|
].collect({ arg name, i;
|
|
|
|
var label,numView, pctView;
|
|
|
|
label = EmacsText(w, name, 12, \right);
|
2009-09-26 06:17:48 +00:00
|
|
|
|
|
|
|
if (i < 2, {
|
2009-01-02 19:06:25 +00:00
|
|
|
numView = EmacsText(w, "?", 5, \right);
|
|
|
|
pctView = EmacsText(w, "%");
|
|
|
|
},{
|
|
|
|
numView = EmacsText(w, "?", 6, \left);
|
|
|
|
});
|
|
|
|
if (i == 1) { w.newline };
|
|
|
|
numView
|
|
|
|
});
|
2009-09-26 06:17:48 +00:00
|
|
|
|
2009-01-02 19:06:25 +00:00
|
|
|
ctlr = SimpleController(this)
|
2016-05-07 14:19:27 +00:00
|
|
|
.put(\serverRunning, { if(this.serverRunning,running,stopped) })
|
2009-01-02 19:06:25 +00:00
|
|
|
.put(\counts,{
|
2016-05-07 14:19:27 +00:00
|
|
|
countsViews.at(0).string = this.avgCPU.round(0.1);
|
|
|
|
countsViews.at(1).string = this.peakCPU.round(0.1);
|
|
|
|
countsViews.at(2).string = this.numUGens;
|
|
|
|
countsViews.at(3).string = this.numSynths;
|
|
|
|
countsViews.at(4).string = this.numGroups;
|
|
|
|
countsViews.at(5).string = this.numSynthDefs;
|
2009-01-02 19:06:25 +00:00
|
|
|
})
|
|
|
|
.put(\cmdPeriod,{
|
|
|
|
recorder.value=0;
|
2009-09-26 06:17:48 +00:00
|
|
|
});
|
2009-01-02 19:06:25 +00:00
|
|
|
w.gotoBob;
|
|
|
|
w.front;
|
|
|
|
this.startAliveThread;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
+ SynthDesc {
|
2011-12-08 12:29:49 +00:00
|
|
|
makeEmacsWindow {
|
2009-01-02 19:06:25 +00:00
|
|
|
var w, s, startButton, sliders;
|
|
|
|
var id, cmdPeriodFunc;
|
|
|
|
var synthDesc;
|
|
|
|
var usefulControls, numControls;
|
|
|
|
var getSliderValues;
|
|
|
|
|
|
|
|
s = Server.default;
|
2009-09-26 06:17:48 +00:00
|
|
|
|
2009-01-02 19:06:25 +00:00
|
|
|
usefulControls = controls.select {|controlName, i|
|
|
|
|
var ctlname;
|
|
|
|
ctlname = controlName.name;
|
|
|
|
(ctlname != "?") && (ctlname != "gate")
|
|
|
|
};
|
2009-09-26 06:17:48 +00:00
|
|
|
|
2009-01-02 19:06:25 +00:00
|
|
|
numControls = usefulControls.size;
|
|
|
|
sliders = Array.newClear(numControls);
|
2009-09-26 06:17:48 +00:00
|
|
|
|
2009-01-02 19:06:25 +00:00
|
|
|
id = s.nextNodeID; // generate a note id.
|
2009-09-26 06:17:48 +00:00
|
|
|
|
2009-01-02 19:06:25 +00:00
|
|
|
// make the window
|
|
|
|
w = EmacsBuffer("*SynthDesc"+name++"*");
|
|
|
|
// add a button to start and stop the sound.
|
|
|
|
startButton = EmacsButton(w, ["Start","Stop"]);
|
|
|
|
w.newline;
|
|
|
|
getSliderValues = {
|
|
|
|
var envir;
|
|
|
|
|
|
|
|
envir = ();
|
|
|
|
usefulControls.do {|controlName, i|
|
|
|
|
var ctlname;
|
|
|
|
ctlname = controlName.name.asSymbol;
|
|
|
|
envir.put(ctlname, sliders[i].value);
|
|
|
|
};
|
|
|
|
envir.use {
|
|
|
|
msgFunc.valueEnvir
|
|
|
|
};
|
|
|
|
};
|
2009-09-26 06:17:48 +00:00
|
|
|
|
2009-01-02 19:06:25 +00:00
|
|
|
startButton.action = {|value|
|
|
|
|
if (value == 1) {
|
|
|
|
// start sound
|
|
|
|
s.sendBundle(s.latency, ["/s_new", name, id, 0, 0] ++ getSliderValues.value);
|
|
|
|
};
|
|
|
|
if (value == 0) {
|
|
|
|
if (hasGate) {
|
|
|
|
// set gate to zero to cause envelope to release
|
|
|
|
s.sendMsg("/n_set", id, "gate", 0);
|
|
|
|
}{
|
|
|
|
s.sendMsg("/n_free", id);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
2009-09-26 06:17:48 +00:00
|
|
|
|
2009-01-02 19:06:25 +00:00
|
|
|
// create controls for all parameters
|
|
|
|
usefulControls.do {|controlName, i|
|
|
|
|
var ctlname, ctlname2, capname, spec;
|
|
|
|
ctlname = controlName.name;
|
2009-09-26 06:17:48 +00:00
|
|
|
capname = ctlname.copy;
|
2009-01-02 19:06:25 +00:00
|
|
|
capname[0] = capname[0].toUpper;
|
|
|
|
spec = ctlname.asSymbol.asSpec;
|
|
|
|
sliders[i] = EmacsNumber(w, capname, spec?ControlSpec(-1e8,1e8),
|
|
|
|
{|ez| s.sendMsg("/n_set", id, ctlname, ez); }, controlName.defaultValue);
|
|
|
|
};
|
2009-09-26 06:17:48 +00:00
|
|
|
|
2009-01-02 19:06:25 +00:00
|
|
|
// set start button to zero upon a cmd-period
|
|
|
|
cmdPeriodFunc = { startButton.value = 0; };
|
|
|
|
CmdPeriod.add(cmdPeriodFunc);
|
2009-09-26 06:17:48 +00:00
|
|
|
|
2009-01-02 19:06:25 +00:00
|
|
|
// stop the sound when window closes and remove cmdPeriodFunc.
|
|
|
|
w.onClose = {
|
|
|
|
s.sendMsg("/n_free", id);
|
|
|
|
CmdPeriod.remove(cmdPeriodFunc);
|
|
|
|
};
|
|
|
|
w.front; // make window visible and front window.
|
|
|
|
}
|
|
|
|
}
|