class library: DUGen - the server now handles audio-rate inputs correctly
[supercollider.git] / SCClassLibrary / Common / Control / ScopeBuffer.sc
blobf0d07bfcbc0373f18670cc43b33159aa3c534def
1 ScopeBuffer {
2         var <index, <numChannels, <server;
4         *alloc { arg server, numChannels=1;
5                 var alloc;
6                 server = server ? Server.default;
7                 alloc = server.scopeBufferAllocator.alloc(numChannels);
8                 if (alloc.isNil) {
9                         error("Meta_ScopeBuffer:alloc: failed to get a scope buffer allocated."
10                                 + "numChannels:" + numChannels + "server:" + server.name);
11                         ^nil
12                 };
13                 ^this.new(alloc, numChannels, server)
14         }
16         *new { arg index=0, numChannels=1, server;
17                 ^super.newCopyArgs(index, numChannels, server ? Server.default)
18         }
20         // compatibility method
21         bufnum {
22                 ^index;
23         }
25         free {
26                 if (index.isNil) {
27                         (this.asString + " has already been freed").warn;
28                         ^this
29                 };
31                 server.scopeBufferAllocator.free(index);
32                 index = nil;
33                 numChannels = nil;
34         }
36         printOn { arg stream;
37                 stream << this.class.name << "(" <<*
38                         [index, numChannels, server]  <<")"
39         }
41         storeOn { arg stream;
42                 stream << this.class.name << "(" <<*
43                         [index, numChannels, server.asCompileString]  <<")"
44         }
46         hash { ^index.hash bitXor: numChannels.hash bitXor: server.hash }