Hi James, here's an example that shows how you can get/set values when dealing with arrays:
[0.25, -0.5, 1., 0.25] @=> float rates[]; <<< "GET VALUES\n---------" >>>; // get values from the array for(0 => int c; c < rates.size(); c++) { <<< rates[c] >>>; } <<< "\nSET VALUES\n---------" >>>; // set values for(0 => int c; c < rates.size(); c++) { Math.random2f(-1, 1) => rates[c]; <<< rates[c] >>>; } if you want to randomize the whole array, of course you'd need to have something like a for loop in which you randomize all the elements. Just one thing, looking at the script you attached, I would take the line of code where you load the audio file out of the while loop. You only need to load it once. The same with the line where you set the delay size (d.max()). You could simply pick a length that is never shorter than the 'delay' value (d.delay()) you randomize in the while loop. Cheers, Mario On Fri, 10 Jan 2020 at 12:28, Matthew.Noone <matthew.no...@ul.ie> wrote: > Hi all, > I'm trying to figure out the easiest way to setup an array of the same > SndBuf playing at different rates. > > I'm using a Gong sample. Playing that back at different rates to make > basic melodic patterns. > > I can make a random function but I don't know who I can set an array of > rates which I can then randomise. > > Any ideas? > > Here is my existing code with random function. (I tried writing an array > at the start but not sure how to call that?) > > Sorry for such an easy question... > MJ > > //Sndbuf > > > //4 => int gongs; > > //[.25, 0.5, 1.0, .25] @=> float rates[];//array of possible rates > (changing will change harmony) > > > //program > > SndBuf mySound => Delay d => JCRev rev => Gain g => dac; > > > 0.8 => rev.mix; > > > //delay and rev setup > > > d => Gain feedback => d; > > > > > while (true) > > { > > .02 => g.gain; > > me.dir()+"Samples/MotherGong.wav" =>mySound.read; > > > > > > > > 0 =>mySound.pos; > > Math.random2f ( 20.1, 22.01 ) => mySound.rate; > > Math.random2f( 0.3, 0.5) ::second => d.max; > > Math.random2( 30, 70) ::ms =>d.delay; > > > > Math.random2f( 0.3, .8) => feedback.gain; > > > > 0.50 ::second => now; > > > > > > > > } > > > Dr. Matthew James Noone > *Sarode Artist & Irish Research Council Postdoctoral Fellow* > *Irish World Academy of Music and Dance* > *University of Limerick* > > _______________________________________________ > chuck-users mailing list > chuck-users@lists.cs.princeton.edu > https://lists.cs.princeton.edu/mailman/listinfo/chuck-users >
_______________________________________________ chuck-users mailing list chuck-users@lists.cs.princeton.edu https://lists.cs.princeton.edu/mailman/listinfo/chuck-users