1 Array[slot] : ArrayedCollection {
4 // return an array of the arguments given
5 // cool! the interpreter does it for me..
36 pyramid { arg patternType=1; // an integer from 1-10
40 pyramidg { arg patternType=1;
42 var lastIndex = this.lastIndex;
43 if (patternType == 1) {
44 for (0,lastIndex) {|i| list = list.add(this[0..i]) };
47 if (patternType == 2) {
48 for (0,lastIndex) {|i| list = list.add(this[lastIndex-i..lastIndex]) };
51 if (patternType == 3) {
52 for (lastIndex,0) {|i| list = list.add(this[0..i]) };
55 if (patternType == 4) {
56 for (0,lastIndex) {|i| list = list.add(this[i..lastIndex]) };
59 if (patternType == 5) {
60 for (0,lastIndex) {|i| list = list.add(this[0..i]) };
61 for (lastIndex-1,0) {|i| list = list.add(this[0..i]) };
64 if (patternType == 6) {
65 for (0,lastIndex) {|i| list = list.add(this[lastIndex-i..lastIndex]) };
66 for (lastIndex-1,0) {|i| list = list.add(this[lastIndex-i..lastIndex]) };
69 if (patternType == 7) {
70 for (lastIndex,0) {|i| list = list.add(this[0..i]) };
71 for (1,lastIndex) {|i| list = list.add(this[0..i]) };
74 if (patternType == 8) {
75 for (0,lastIndex) {|i| list = list.add(this[i..lastIndex]) };
76 for (lastIndex-1,0) {|i| list = list.add(this[i..lastIndex]) };
79 if (patternType == 9) {
80 for (0,lastIndex) {|i| list = list.add(this[0..i]) };
81 for (1,lastIndex) {|i| list = list.add(this[i..lastIndex]) };
84 if (patternType == 10) {
85 for (0,lastIndex) {|i| list = list.add(this[lastIndex-i..lastIndex]) };
86 for (lastIndex-1,0) {|i| list = list.add(this[0..i]) };
90 sputter { arg probability=0.25, maxlen = 100;
94 probability = 1.0 - probability;
95 while { (i < size) and: { list.size < maxlen }}{
96 list = list.add(this[i]);
97 if (probability.coin) { i = i + 1; }
104 ^this.primitiveFailed
106 permute { arg nthPermutation;
108 ^this.primitiveFailed
110 allTuples { arg maxTuples = 16384;
112 ^this.primitiveFailed
114 wrapExtend { arg length;
116 ^this.primitiveFailed
118 foldExtend { arg length;
120 ^this.primitiveFailed
122 clipExtend { arg length;
124 ^this.primitiveFailed
126 slide { arg windowLength=3, stepSize=1;
128 ^this.primitiveFailed
131 _ArrayContainsSeqColl
132 ^this.primitiveFailed
135 //************** inconsistent argnames, see SequenceableColllection unlace!
136 unlace { arg clumpSize=2, numChan=1, clip=false;
138 super.unlace(clumpSize, numChan)
140 this.prUnlace(clumpSize, numChan) // clip not yet implemented in primitive
143 prUnlace { arg clumpSize=2, numChan=1;
145 ^this.primitiveFailed;
147 interlace { arg clumpSize=1;
149 //^this.primitiveFailed;
150 Error("interlace was replaced by lace\n").throw
152 deinterlace { arg clumpSize=2, numChan=1;
154 //^this.primitiveFailed;
155 Error("deinterlace was replaced by unlace\n").throw
158 // multiChannelExpand and flop do the same thing.
160 _ArrayMultiChannelExpand
164 _ArrayMultiChannelExpand
168 // given an array of symbols, this returns an array of pairs of symbol, value
169 // from the current environment
172 var value = name.envirGet;
173 value !? { result = result.add(name).add(value); };
178 shift { arg n, filler = 0.0;
179 var fill = Array.fill(n.abs, filler);
180 var remain = this.drop(n.neg);
181 ^if (n<0) { remain ++ fill } { fill ++ remain }
185 var arrSize = this.size;
186 var powersize = (2 ** arrSize).asInteger;
187 var powersOf2 = ({ |i| 2 ** i }).dup(arrSize);
189 ^Array.fill(powersize, { |i|
190 var elemArr = Array.new;
191 powersOf2.do { |mod, j|
192 if (i div: mod % 2 != 0) {
193 elemArr = elemArr.add(this[j])
202 // returns the source UGen from an Array of OutputProxy(s)
203 var elem = this.at(0);
204 if (elem.isKindOf(OutputProxy), {
207 Error("source: Not an Array of OutputProxy(s)\n").throw;
210 asUGenInput { arg for; ^this.collect(_.asUGenInput(for)) }
211 asControlInput { ^this.collect(_.asControlInput) }
213 isValidUGenInput { ^true }
214 numChannels { ^this.size }
216 // multichannel UGen-poll
217 poll { arg trig = 10, label, trigid = -1;
218 if(label.isNil){ label = this.size.collect{|index| "UGen Array [%]".format(index) } };
219 ^Poll(trig, this, label, trigid)
221 dpoll { arg label, run = 1, trigid = -1;
222 if(label.isNil){ label = this.size.collect{|index| "UGen Array [%]".format(index) } };
223 ^Dpoll(this, label, run, trigid)
228 ^this.primitiveFailed
231 // // 2D array support
232 // *newClear2D { arg rows=1, cols=1;
233 // ^super.fill(rows, { Array.newClear(cols) });
235 // *new2D { arg rows=1, cols=1;
236 // ^this.newClear2D(rows, cols);
238 // at2D { arg row, col; ^this.at(row).at(col) }
239 // put2D { arg row, col, val; ^this.at(row).put(col, val) }
241 // this.do({ arg row;
242 // row.size.do({ arg i;
249 // IdentitySet support
250 atIdentityHash { arg argKey;
251 _Array_AtIdentityHash
252 ^this.primitiveFailed
254 // IdentityDictionary support
255 atIdentityHashInPairs { arg argKey;
256 _Array_AtIdentityHashInPairs
257 ^this.primitiveFailed
260 asSpec { ^ControlSpec( *this ) }
263 fork { arg join (this.size), clock, quant=0.0, stackSize=64;
265 var cond = Condition({ count >= join });
271 }).play(clock, quant);
277 madd { arg mul = 1.0, add = 0.0;
278 ^MulAdd(this, mul, add);
284 ^this.primitiveFailed;
287 printOn { arg stream;
288 if (stream.atLimit, { ^this });
290 this.printItemsOn(stream);
293 storeOn { arg stream;
294 if (stream.atLimit, { ^this });
296 this.storeItemsOn(stream);
299 prUnarchive { arg slotArray;
300 slotArray.pairsDo {|index, slots| this[index].setSlots(slots) };
301 this.do {|obj| obj.initFromArchive };