// title: Re: sloth canons [Pattern Extension] // author: tom.dugovic // description: // Save this as an extension and recompile class library. You can now use `Psloth([0,1,0], 10)`, for example, instead of declaring a new routine for each pattern. // // I didn't persist the use cases, as this should be saved as a `.sc` file. Please refer to the ancestor code for usage. // // Memory/CPU usage will grow over time, but at a decreasing rate. This can be used for a large amount of repeats. Extensive testing has not been done on this though. // code: Psloth { var seed, repeats; *new { arg seed, repeats=1; ^super.newCopyArgs(seed, repeats); } storeArgs{^[seed, repeats]} embedInStream { arg inval; var size=seed.size; var pointers=List[]; repeats.value(inval).do({ arg j; j = j+1; if(j == j.nextPowerOf(size),{ pointers.add(0); }); pointers.collect{|i| seed.at(i)}.sum.embedInStream(inval); pointers.do{|x, i| if((i==0) || (pointers[0..(i-1)].sum==0), {pointers[i] = ((x+1)%size);}) }; }); ^inval } }