1 EventTypesWithCleanup {
2 classvar <>cleanupTypes, <>ugenInputTypes, <>notNodeType;
4 Class.initClassTree(Event);
5 Event.default[\eventTypes].putAll(
7 // ~bufnum has a default of 0, so we use ~bufNum instead....
11 if ( (bufNum = ~bufNum).notNil) {
12 ~schedBundle.value(~lag, ~timingOffset, server, [\b_setn, bufNum.asUGenInput, 0, ~amps.size] ++ ~amps)
15 bufNum = ~bufNum = server.bufferAllocator.alloc;
16 ~numFrames = ~amps.size;
18 ~schedBundle.value(~lag, ~timingOffset, server,
19 [\b_alloc, bufNum, ~numFrames, ~numChannels,
20 [\b_setn, bufNum.asUGenInput, 0, ~amps.size] ++ ~amps
27 if ( (bufNum = ~bufNum).notNil) {
28 ~schedBundle.value(~lag, ~timingOffset, server, [\b_gen, bufNum.asUGenInput, \cheby, ~genflags ? 7] ++ ~amps)
31 bufNum = ~bufNum = server.bufferAllocator.alloc;
32 ~numFrames = ~numFrames ? 1024;
33 ~numChannels = ~numChannels ? 1;
34 ~schedBundle.value(~lag, ~timingOffset, server,
35 [\b_alloc, bufNum, ~numFrames, ~numChannels,
36 [\b_gen, bufNum, \cheby, ~genflags ? 7] ++ ~amps
43 if ( (bufNum = ~bufNum).notNil) {
44 ~schedBundle.value(~lag, ~timingOffset, server, [\b_gen, bufNum.asUGenInput, \sine1, ~genflags ? 7] ++ ~amps)
47 bufNum = ~bufNum = server.bufferAllocator.alloc;
48 ~numFrames = ~numFrames ? 1024;
49 ~numChannels = ~numChannels ? 1;
50 ~schedBundle.value(~lag, ~timingOffset, server,
51 [\b_alloc, bufNum, ~numFrames, ~numChannels,
52 [\b_gen, bufNum, \sine1, ~genflags ? 7] ++ ~amps
59 array = [~freqs, ~amps].lace(~freqs.size * 2);
60 if ( (bufNum = ~bufNum).notNil) {
61 ~schedBundle.value(~lag, ~timingOffset, server, [\b_gen, bufNum.asUGenInput, \sine2, ~genflags ? 7] ++ array)
64 bufNum = ~bufNum = server.bufferAllocator.alloc;
65 ~numFrames = ~numFrames ? 1024;
66 ~numChannels = ~numChannels ? 1;
67 ~schedBundle.value(~lag, ~timingOffset, server,
68 [\b_alloc, bufNum, ~numFrames, ~numChannels,
69 [\b_gen, bufNum, \sine1, ~genflags ? 7] ++ array
76 array = [~freqs, ~amps, ~phases].lace(~freqs.size * 3);
77 if ( (bufNum = ~bufNum).notNil) {
78 ~schedBundle.value(~lag, ~timingOffset, server, [\b_gen, bufNum.asUGenInput, \sine3, ~genflags ? 7] ++ array)
81 bufNum = ~bufNum = server.bufferAllocator.alloc;
82 ~numFrames = ~numFrames ? 1024;
83 ~numChannels = ~numChannels ? 1;
84 ~schedBundle.value(~lag, ~timingOffset, server,
85 [\b_alloc, bufNum, ~numFrames, ~numChannels,
86 [\b_gen, bufNum, \sine1, ~genflags ? 7] ++ array
92 ~bufNum = server.bufferAllocator.alloc(~numBufs ?? { ~numBufs = 1});
93 ~schedBundle.value(~lag, ~timingOffset, server, [\b_alloc, ~bufNum, ~numFrames, ~numChannels]);
96 freeBuffer: #{|server|
97 ~schedBundle.value(~lag, ~timingOffset, server, [\b_free, ~bufNum]);
98 server.bufferAllocator.free(~bufNum);
101 allocRead: #{|server|
103 if ( (bufNum = ~bufNum).isNil ) { bufNum = ~bufNum = server.bufferAllocator.alloc; ~type = \allocReadID };
104 ~schedBundle.value(~lag, ~timingOffset, server, [\b_allocRead, bufNum, ~path, ~firstFileFrame, ~numFrames]);
108 var bufNum, bndl, completion;
109 if ( (bufNum = ~bufNum).isNil ) { bufNum = ~bufNum = server.bufferAllocator.alloc; ~type = \cueID };
111 completion = ["/b_read", bufNum, ~path, ~firstFileFrame, ~bufferSize, ~firstBufferFrame, ~leaveOpen];
112 bndl = ["/b_alloc", bufNum, ~bufferSize, ~numChannels, completion];
113 ~schedBundle.value(~lag, ~timingOffset, server, bndl);
116 freeAllocRead: #{|server|
117 ~schedBundle.value(~lag, ~timingOffset, server, [\b_free, ~bufNum]);
120 freeCue: #{ | server |
121 var bufNum = ~bufNum;
122 server.schedBundleArray.value(~lag, ~timingOffset, server, [["/b_close", bufNum], ["/b_free", bufNum ] ] );
125 freeCueID: #{ | server |
126 var bufNum = ~bufNum;
127 server.schedBundleArray.value(~lag, ~timingOffset, server, [["/b_close", bufNum], ["/b_free", bufNum ] ] );
128 server.bufferAllocator.free(bufNum);
131 audioBus: #{ | server |
132 ~out = server.audioBusAllocator.alloc(~channels ? 1)
135 controlBus: #{ | server |
136 ~out = server.controlBusAllocator.alloc(~channels ? 1)
139 freeAudioBus: #{ | server |
140 server.audioBusAllocator.free(~out)
143 freeControlBus: #{ | server |
144 server.controlBusAllocator.free(~out)
150 // if (~id.isNil) { ~id = server.nextNodeID };
151 // bundle = [\g_new, ~id.asArray, Node.actionNumberFor(~addAction), ~group.asUGenInput].flop;
152 // ~schedBundleArray.value(~lag, ~timingOffset, server, bundle);
166 table: \freeBuffer, // free buffer and deallocate bufNum
167 buffer: \freeBuffer, // free buffer and deallocate bufNum
168 allocRead: \freeAllocRead, // free buffer
169 cue: \freeCue, // free buffer, close file
170 allocReadID: \freeBuffer, // free buffer and deallocate bufNum
171 cueID: \freeCueID, // free buffer, close file, and deallocate bufNum
172 audioBus: \freeAudioBus, // deallocate bus
173 controlBus: \freeControlBus, // deallocate bus
176 // load: \free, // bufNum was allocated elsewhere, let the source clean it up
190 allocReadID: \bufNum,
199 *cleanup { | ev, flag = true |
202 notNode = notNodeType[type] ? true;
203 if (flag || notNode) {
205 type: cleanupTypes[type]