Submit
Browse
Anonymous
Login
RSS
SuperCollider Code
Fork Code: Re: sloth canons [Pattern Extension]
name
code content
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 } }
code 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.
use markdown for formating
category tags
comma separated, i.g. "wild, siren" (do not enter default SC class names, please)
ancestor(s)
comma separated identificators, i.g. "1-C,1-1,1-4M,1-x"
Private?
the code will be accessible by direct url and not visible in public activity
signup to submit public code without captcha
comment of change