[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[sc-users] help sorting?



I'm trying to collect and sort 2 randomly generated variables across a variable array of iterations, and I can't make it work!

Baically, I have somthing like


numIterations = (0..10).choose;

numIterations.do{|i|

specify a playing duration
specify a number of loops
specify a wait before the next iteraiton

}

here i want to specify a total wait by 
allWaits.sum.wait;

and then

(longestDur + (longestDur*numRepeats)).wait;


but I can't figure out how to sort the Durs and have the number of repeats variable go with it....!



faulty, half-baked code is below, this version is w/ a little class that stores durs and repeats,
previously I tried an array like [[dur, repeat],[dur, repeat]] but I couldn't figure out syntax..

thanks in advance!
ck




~catalogEntriesFullScreenRand = { var catalogSet,numEntries,fields,catalogFiles,allWaits,allFWs,allRepeats;
var allDurs;

if (randCatalogCounter>(allRandCatalogSoundSets.size-1),{randCatalogCounter=0});
catalogSet=allRandCatalogSoundSets[randCatalogCounter].value;
catalogSet.inPath.postln;
catalogSet.namesArray.postln;
numEntries=catalogSet.number.postln;
if (numEntries > totalFields, {numEntries=totalFields});


fields=(0..numEntries);
catalogFiles=(0..numEntries);
allWaits=(0..numEntries);
allDurs=(0..numEntries);
allFWs=(0..numEntries);


allFWs.do{|i|
allFWs[i]=FileWaitData.new
};

numEntries.do{ |i| var mult,dur,playLength,choice,vol,repeat,buf;
choice=rrand(catalogSet.start,(catalogSet.start+(catalogSet.number-1))).postln;
"CHOICE ABOVE".postln;
//if(choice<(chainStart+1), {choice=chainStart+1});
catalogFiles[i] =catalogSet.namesArray[(choice-catalogSet.start)].postln;
allFWs[i].dur = catalogSet.dursArray[i];
if (allFWs[i].dur  > 10,{allFWs[i].dur = 10});
if (allFWs[i].dur < 1,{allFWs[i].dur = 1});
playLength=(allFWs[i].dur - 0.5);




FTBViewLondon3.catalog(w,((i*40)+10),catalogFiles[i],1);


buf=((catalogSet.start)+i);


repeat=[1,2,3,4].choose;
("REPEAT"+repeat).postln;


allFWs[i].repeat = repeat;


fork{ var buffer=buf;
repeat.do{|i|
vol=rrand(0.2,1.0);
Synth(\guiPlayer, [\fxBuf, buffer, \chan, rrand(0,(totalChans-1)),\loop,0,\playLength, playLength,\fxVol,vol]).play;
rrand(3.0,12.0).wait;
//20.wait;
"LOOPING".postln;
};
};
allWaits[i] = rrand(0.3,1.5).wait;
};


"ALLWAITS".postln;
allWaits.sum.postln;
allWaits.wait;


allFWs.do{|i|
allDurs[i]=allFWs[i].dur
};


allDurs.sort({|a,b| a>b}).postln;



"XXXXXXXXXXXXXXXXXXcatalogcounterXXXXXXXXXXXXXXXX".postln;
randCatalogCounter=(randCatalogCounter+1).postln;
};