class SoundStar{ float x,y; subSoundStar[] substars; SoundStar(float x1, float y1){ substars = new subSoundStar[9]; //make nine subSoundStar instances substars[0] = new subSoundStar(x1,y1); //primary (centre) one /*substars[1] = new subSoundStar(x1-skwidth,y1-skheight); substars[2] = new subSoundStar(x1-skwidth,y1); substars[3] = new subSoundStar(x1-skwidth,y1+skheight); substars[4] = new subSoundStar(x1,y1-skheight); substars[5] = new subSoundStar(x1,y1+skheight); substars[6] = new subSoundStar(x1+skwidth,y1-skheight); substars[7] = new subSoundStar(x1+skwidth,y1); substars[8] = new subSoundStar(x1+skwidth,y1+skheight);*/ } void display(){ //for (int a = 0;a<9;a++){ substars[0].display(); //} } } class subSoundStar { float x,y,volume,sinFreq,sinPan; float distLeft,distRight,distCentre,factorLeft,factorRight; int diameter; color colour; SineWave sine; Particle sunSpot; Attraction gravity, cometgrav; subSoundStar(float x1,float y1) { //sound setup volume = 0.0; sinFreq = int(random(110,880)); sinPan = 1; sine = new SineWave(sinFreq,volume,44100); sine.portamento(100); sine.setPan(sinPan); sound.addSignal(sine); x=x1; y=y1; //particle setup sunSpot = physics.makeParticle(1,x,y,0); sunSpot.makeFixed(); gravity = physics.makeAttraction(sunSpot,orbiter,1000,15); cometgrav=physics.makeAttraction(sunSpot,comet,1000,15); //display setup colour = color(255,255,255); diameter = 10; } void display(){ // this is called display, but it's also going to be the place which // alters the volume on the signal, as well as the panning. //fill (colour); //ellipse (x,y,diameter,diameter); //sound stuff distLeft = dist(orbitx-10,orbity,x,y); distRight = dist(orbitx+10,orbity,x,y); distCentre = dist(orbitx,orbity,x,y); //println(wiiconnected); if (wiiconnected >0){ //println("wii connected"); if (distCentre < 10.0) wii.rimokon.vibrateFor(100); } tint(cr,cg,cb); image(gravfield,x-(gravfield.width/2),y-(gravfield.height/2)); tint(180, 180, 255, 126); image(starimg,x-(starimg.width/2),y-(starimg.height/2)); factorLeft=falloff(distLeft); factorRight=falloff(distRight); volume=volumeFalloff(distCentre); sinPan = panValue(factorLeft,factorRight); sine.setAmp(volume); sine.setPan(sinPan); //physics stuff gravity.setStrength(sa[axis]); } }