clean up indentation and spacing
[supercollider.git] / SCClassLibrary / Common / GUI / PlusGUI / Control / server-scope.sc
blobdadf77c079d0adfd7bec1a0e4e226475915ff797
1 + Server {
2         scope { arg numChannels, index = 0, bufsize = 4096, zoom = 1, rate = \audio;
3                 numChannels = (numChannels ? 2).min(16);
4                 zoom = zoom ? 1.0;
6                 if(scopeWindow.isNil) {
7                         if ((GUI.id == \qt) and: (this.isLocal)) {
8                                 scopeWindow = \QStethoscope2.asClass.new(this, numChannels, index, bufsize, zoom, rate);
9                         } {
10                                 scopeWindow = Stethoscope(this, numChannels, index, bufsize, zoom, rate, nil,
11                                         this.options.numBuffers);
12                                 // prevent buffer conflicts by using reserved bufnum
13                         };
14                         scopeWindow.window.onClose = scopeWindow.window.onClose.addFunc({ scopeWindow = nil });
15                         ServerTree.add(this, this);
16                 } {
17                         scopeWindow.setProperties(numChannels, index, bufsize, zoom, rate);
18                         scopeWindow.run;
19                         scopeWindow.window.front;
20                 };
21                 ^scopeWindow
22         }
24         freqscope {
25                 GUI.freqScope.new;
26         }
29 + Bus {
30         scope { arg bufsize = 4096, zoom;
31                 ^server.scope(numChannels, index, bufsize, zoom, rate);
32         }
36 + Function {
37         scope { arg numChannels, outbus = 0, fadeTime = 0.05, bufsize = 4096, zoom;
38                 var synth, synthDef, bytes, synthMsg, outUGen, server;
40                 if (GUI.id == \qt) {
41                         server = Server.default;
42                 } {
43                         server = GUI.stethoscope.defaultServer;
44                         if(server.serverRunning.not) {
45                                 (server.name.asString ++ " server not running!").postln;
46                                 ^nil
47                         }
48                 };
49                 synthDef = this.asSynthDef(name: SystemSynthDefs.generateTempName, fadeTime:fadeTime);
50                 outUGen = synthDef.children.detect { |ugen| ugen.class === Out };
52                 numChannels = numChannels ?? { if(outUGen.notNil) { (outUGen.inputs.size - 1) } { 1 } };
53                 synth = Synth.basicNew(synthDef.name, server);
54                 bytes = synthDef.asBytes;
55                 synthMsg = synth.newMsg(server, [\i_out, outbus, \out, outbus], \addToHead);
56                 server.sendMsg("/d_recv", bytes, synthMsg);
57                 server.scope(numChannels, outbus, bufsize, zoom, outUGen.rate);
58                 ^synth
59         }
61         freqscope {
62                 var server = if (GUI.id == \qt) { Server.default } { GUI.stethoscope.defaultServer };
63                 this.play(server);
64                 ^GUI.freqScope.new
65         }