Sample son; Agent[] groupA, groupB, drum; /////////////////////////////////////////// /////////////////////////////////////////// //--( SetUp )-- /////////////////////////////////////////// void setup(){ size(800,100); Sonia.start(this); //smooth(); noStroke(); ellipseMode(CENTER_DIAMETER); initDrum(); reset(); } /////////////////////////////////////////// /////////////////////////////////////////// //--( Reset )-- Init Agents /////////////////////////////////////////// void reset() { //int a = 10; //int b = 20; int a = (int)random(20); int b = (int)random(20); groupA = new Agent[a]; groupB = new Agent[b]; for (int i = 0; i5000); } void update(){ if(count++>countMax) { count=0; play(); moovSample(); } } //Increment or decrement the sample boundary randomly //Make test to keep coherent sample void moovSample(){ int maxFrame = son.getNumFrames(); if(random(100)>50) startFrame+=inc; else startFrame-=inc; if(startFrame<0) startFrame=0; else if(startFrame>=endFrame) startFrame=endFrame-2; if(random(100)>50) endFrame+=inc; else endFrame-=inc; if(endFrame<=startFrame) endFrame=startFrame+2; else if(endFrame>maxFrame) startFrame=maxFrame-2; } //Play the part of the sound when is not playing void play(){ if(!son.isPlaying()) son.play(startFrame,endFrame); //debug(); } //Draw the agent (here is an ellipse for the sequence. void draw(){ update(); float esz=((countMax-count)/(float)countMax)*bsz; ellipse(x,y,esz,esz); } //Text based infos on the each agent. void debug(){ print("["+ID+"]"); print("\t[PAN]:"+son.getPan()); print("\t[RATE]:"+son.getRate()); print("\t[LENGTH]:"+(endFrame-startFrame)); print("\t[POS]X:"+x+" Y:"+y); println(); } } /////////////////////////////////////////// /////////////////////////////////////////// //Sonia things that I don't really understand(?) /////////////////////////////////////////// public void stop(){ Sonia.stop(); super.stop(); }