I was actually thinking of posting this.
- Ctrl-Esc a – open a VST frequency analyzer
- Ctrl-Esc b – open the class browser
- Ctrl-Esc g – attach gdb to sclang
- Ctrl-Esc k – scd file bookmarks
- Ctrl-Esc p – emergency release port 57120
- Ctrl-Esc q – query all nodes
- Ctrl-Esc s – open SynthDescLib browser
// do not init GUI when launching from command line
if(Platform.ideName != "none") {
if(GUI.get(\qt).notNil) {
fork({
var w, title;
var ntpStatus = false, cond = CondVar.new;
'QtGUI'.asClass.palette = 'QPalette'.asClass.dark;
}, AppClock);
};
// ctrl-esc hotkey commands
StartUp.add({
var e = Environment.make {
~cmds = (
$q: "Query all nodes" -> { Server.default.queryAllNodes },
$s: "Browse SynthDescLib" -> { SynthDescLib.global.browse },
$b: "Class browser" -> { Object.browse },
$d: "Dismiss" -> { ~win.visible = false },
$k: "Bookmarks" -> { ~openBookmark.() },
$p: "Free 57120" -> { "fuser -k 57120/udp".unixCmd; "Please reboot interpreter".postln },
$g: "Attach gdb" -> {
"sudo gdb -p %"
.format(
thisProcess.pid
)
.debug("running")
.runInTerminal
},
$a: "Analyzer" -> {
if(Library.at(\freqSynth).notNil) {
Library.at(\freqSynth).free;
Library.put(\freqSynth, nil);
} {
if(s.serverRunning) {
fork {
var synth, ctl;
var cond = CondVar.new;
var chan = s.options.numOutputBusChannels;
var name = ("vstAna" ++ chan).asSymbol;
SynthDef(name, { |out = 0|
VSTPlugin.ar(In.ar(out, chan), chan);
}).add;
s.sync;
synth = Synth(name, target: s.defaultGroup, addAction: \addAfter);
ctl = VSTPluginController(synth);
// Linux native but not really freq analyzer:
// TB_Spectrogram_v1.vst3
ctl.open("Spectrum Analyzer.vst3", action: { |c, ok|
if(ok) {
c.editor;
Library.put(\freqSynth, synth);
} {
"Could not open plugin".warn;
};
});
};
} {
"Default server isn't running, can't open analyzer".warn;
};
};
};
);
~makeWin = {
~win = Window("util", Rect(800, 679, ~cmds.size * 30 + 10, 70));
~win.layout = HLayout(*
~cmds.keys.asArray.sort.collect { |key|
Button().fixedWidth_(20)
.states_([[key]])
.action_(inEnvir { ~win.close; ~cmds[key].value.value; })
.toolTip_(~cmds[key].key)
.keyDownAction_(false);
}
);
~win.view.keyDownAction = inEnvir { |view, char|
if(~cmds[char].notNil) {
~win.close; //.visible = false;
~cmds[char].value.value;
};
};
~win.front;
~bkShutdownFunc = nil;
Library.put(\ddwBookmarksDirty, false);
~openBookmark = {
var file, line, book = Library.at(\ddwBookmarks),
win, list, openBtn, addBtn, removeBtn, cancelBtn, lastClick = 0;
if(book.isNil) {
file = File(Platform.userConfigDir +/+ "ddwBookmarks.txt", "r");
if(file.isOpen) {
while {
line = file.getLine;
line.notNil
} {
book = book.add(line);
};
} {
"Could not read bookmarks file".warn;
book = Array.new;
};
};
if(~bkShutdownFunc.isNil) {
~bkShutdownFunc = {
var file;
if(Library.at(\ddwBookmarksDirty) ?? { false }) {
file = File(Platform.userConfigDir +/+ "ddwBookmarks.txt", "w");
if(file.isOpen) {
protect {
Library.at(\ddwBookmarks).do { |path|
file << path << "\n";
};
} { file.close };
} {
"Could not write bookmarks file".warn;
};
};
};
ShutDown.add(~bkShutdownFunc);
};
win = Window("Bookmarks",
Rect.aboutPoint(Window.screenBounds.center, 200, 150));
win.layout = HLayout(
list = ListView(),
VLayout(
nil,
openBtn = Button().fixedWidth_(80),
addBtn = Button().fixedWidth_(80),
removeBtn = Button().fixedWidth_(80),
cancelBtn = Button().fixedWidth_(80),
nil
)
);
list.items_(book.collect(_.basename)).value_(0)
.enterKeyAction_({ |view|
openBtn.doAction
})
.mouseDownAction_({ |view|
if(AppClock.seconds - lastClick < 0.3) {
openBtn.doAction
} {
lastClick = AppClock.seconds;
};
});
openBtn.states_([["Open"]])
.action_({
book[list.value].openDocument;
win.close;
});
addBtn.states_([["Add"]])
.action_({
var new = 'Document'.asClass.current.path, base, i;
if(new.isNil) {
"Document is unsaved; can't bookmark".warn;
} {
if(book.size == 0) {
book = [new];
i = 0;
} {
base = new.basename;
i = book.detectIndex { |path| base < path.basename };
if(i.notNil) {
book = book.insert(i, new);
} {
book = book.add(new);
i = book.size - 1;
};
};
};
Library.put(\ddwBookmarks, book);
Library.put(\ddwBookmarksDirty, true);
list.items_(book.collect(_.basename)).value_(i);
});
removeBtn.states_([["Remove"]])
.action_({
var saveItem;
book.removeAt(list.value);
saveItem = book[list.value];
Library.put(\ddwBookmarks, book);
Library.put(\ddwBookmarksDirty, true);
list.items_(book.collect(_.basename))
.value_(book.indexOfEqual(saveItem) ?? { book.size - 1 })
});
cancelBtn.states_([["Exit"]])
.action_({ win.close });
win.front;
};
};
};
{
if('Document'.asClass.respondsTo(\globalKeyDownAction_)) {
'Document'.asClass.globalKeyDownAction = 'Document'.asClass.globalKeyDownAction.addFunc({ |doc, char, modifiers, ascii|
// on my linux machine, this is ctrl-esc
// change as you see fit
if(ascii == 27 and: { modifiers.bitAnd(262144) != 0 }) {
~makeWin.value; // ~win.front;
};
}.inEnvir(e));
};
}.defer(3.0);
Library.put(\utilityEnvir, e);
});
};
Class browser, SynthDescLib browser, and bookmarks, I use a lot.
Some bits assume Linux.
hjh