Merge pull request #506 from andrewcsmith/patch-2
[supercollider.git] / SCClassLibrary / Common / GUI / PlusGUI / Control / UGen-scope.sc
blobad1059182b2699fc43fe7c9c59c28b3a00735b68
1 + UGen {
2         scope { arg name = "UGen Scope", bufsize = 4096, zoom = 1.0;
3                 var gui, server;
4                 gui = GUI.current;
5                 server = gui.stethoscope.defaultServer;
6                 ^SynthDef.wrap({ var bus, numChannels, rate, scope;
7                         numChannels = this.numChannels;
8                         rate = this.rate;
9                         bus = Bus.perform(rate, server, numChannels);
10                         switch(rate,
11                                 \audio, {Out.ar(bus.index, this)},
12                                 \control, {Out.kr(bus.index, this)}
13                         );
15                         {
16                                 scope = gui.stethoscope.new( server, numChannels, bus.index, bufsize, zoom, rate );
17                                 scope.window.name_(name.asString).bounds_( gui.stethoscope.tileBounds);
18                                 gui.stethoscope.ugenScopes.add(scope);
19                                 scope.window.onClose = { scope.free; bus.free;
20                                         gui.stethoscope.ugenScopes.remove(scope) };
21                                 CmdPeriod.doOnce({ {scope.window.close}.defer });
22                         }.defer(0.001);
23                         this;
24                 })
25         }
29 + Array {
30         scope { arg name = "UGen Scope", bufsize = 4096, zoom = 1.0;
31                 var gui, server;
32                 gui = GUI.current;
33                 server = gui.stethoscope.defaultServer;
34                 ^SynthDef.wrap({ var bus, numChannels, rate, scope;
35                         numChannels = this.numChannels;
36                         rate = this.rate;
37                         bus = Bus.perform(rate, server, numChannels);
38                         switch(rate,
39                                 \audio, {Out.ar(bus.index, this)},
40                                 \control, {Out.kr(bus.index, this)}
41                         );
43                         {
44                                 scope = gui.stethoscope.new( server, numChannels, bus.index, bufsize, zoom, rate );
45                                 scope.window.name_(name.asString).bounds_( gui.stethoscope.tileBounds);
46                                 gui.stethoscope.ugenScopes.add(scope);
47                                 scope.window.onClose = { scope.free; bus.free;
48                                         gui.stethoscope.ugenScopes.remove(scope) };
49                                 CmdPeriod.doOnce({ {scope.window.close}.defer });
50                         }.defer(0.001);
51                         this;
52                 })
53         }