// BOOLEAN v noCAMERA 0.2 // by Andy Doro & Tim Stutts & So Young Park // 2006 // Now with BALLOONS!!! yes. // Non-Camera version. Use mouse-over to inflate balloons. // Graphics now less taxing & using case statements. // // -------------------------------------------- LIBRARIES //import processing.video.*; import krister.Ess.*; // loads ess library ( download this from http://www.tree-axis.com/Ess/ ) // -------------------------------------------- AUDIO //float[] blackRatio = new float[12]; // ratio of black pixels to total number // ARRAY SOUND //AudioChannel[] SineChannel = new AudioChannel[12]; AudioChannel[] TriangleChannel = new AudioChannel[12]; AudioChannel[] SquareChannel = new AudioChannel[12]; //SineWave[] mySineWave = new SineWave[12]; TriangleWave[] myTriangleWave = new TriangleWave[12]; SquareWave[] mySquareWave = new SquareWave[12]; AudioChannel[] PopChannel = new AudioChannel[12]; float Pitches[] = { 1174.64, 1046.52, 987.76, 880.0, 784.0, 659.26, 523.26, 440.0, 293.66, 261.63, 246.94, 220.0 }; // -------------------------------------------- VIDEO //Capture myCapture; int[] BoxValues = new int[12]; // array stores black pixel count of every box int colWt = 45; int rowHt = 40; int coordX, coordY; //, colCount, rowCount, totalPicsBox; // --------------------- BALLOON STUFF int numBalloons = 192; // number of balloons Balloon[] theBalloons = new Balloon[numBalloons]; float[] balloonRatio = new float[12]; // current balloon size over max size. sets amplitude PImage pop; void setup() { size(720,480); frameRate(15); noStroke(); smooth(); fill(255,80); coordX = 0; for (int x=0; x<16; x++) { for (int y=0; y<12; y++) { theBalloons[y+(x*12)] = new Balloon(x*colWt, y*rowHt, y); } } pop = loadImage("popp.gif"); //println(Capture.list()); //myCapture = new Capture(this, "IIDC FireWire Video", 720, 480, 15); // -------- SOUND Ess.start(this); /* for(int i=0; i < 12; i++) { // SineWave Oscillators mySineWave[i]=new SineWave(Pitches[i],.5); SineChannel[i] = new AudioChannel(); SineChannel[i].initChannel(SineChannel[i].frames(2000)); mySineWave[i].generate(SineChannel[i]); SineChannel[i].play(Ess.FOREVER); } */ for(int i=0; i < 12; i++) { // TriangleWave Oscillators myTriangleWave[i]=new TriangleWave(Pitches[i],.5); TriangleChannel[i] = new AudioChannel(); TriangleChannel[i].initChannel(TriangleChannel[i].frames(2000)); myTriangleWave[i].generate(TriangleChannel[i]); TriangleChannel[i].volume(0.0); // eliminate annoying startup noise! TriangleChannel[i].play(Ess.FOREVER); } for(int i=0; i < 12; i++) { // SquareWave Oscillators mySquareWave[i]=new SquareWave(Pitches[i],.5); SquareChannel[i] = new AudioChannel(); SquareChannel[i].initChannel(SquareChannel[i].frames(2000)); mySquareWave[i].generate(SquareChannel[i]); SquareChannel[i].volume(0.0); // eliminate annoying startup noise! SquareChannel[i].play(Ess.FOREVER); } for(int i=0; i < 12; i++) { // PopSamples. thanks Plaid! PopChannel[i] = new AudioChannel((12-i)+".wav"); } } void draw() { background(200); //image(myCapture, 0, 0); //filter(THRESHOLD); for (int coordY = 0; coordY < 12; coordY++) { //blackRatio[coordY] = (float)BoxValues[coordY] / 1800; // gets black pic count ratio //theBalloons[coordY+(12*coordX)].BalloonValue += 3*blackRatio[coordY]; // increase Balloon values in that column //theBalloons[coordY+(12*coordX)].checkBalloon(); // check if the Balloon value exceeds maxValue, if so then pop. balloonRatio[coordY] = (theBalloons[coordY+(12*coordX)].BalloonValue) / 34.0; // balloon size ratio to use for amplitude } // ---------------------- APPLY AMPLITUDES & PLAY SAMPLES for(int i=0; i < 12; i++) { switch(theBalloons[i+(12*coordX)].colorValue) { case 0: TriangleChannel[i].volume(0.0); // amplitude of trianglewave SquareChannel[i].volume(0.0); // amplitude of squarewave break; case 1: // SineChannel[i].volume(0.0); // amplitude of sinewave TriangleChannel[i].volume(balloonRatio[i]*0.25); // amplitude of trianglewave SquareChannel[i].volume(0.0); // amplitude of squarewave break; case 2: // SineChannel[i].volume(0.0); // amplitude of sinewave TriangleChannel[i].volume(0.0); // amplitude of trianglewave SquareChannel[i].volume(balloonRatio[i]*0.25); // amplitude of squarewave, dampered because andy doesn't like it break; } /* if (theBalloons[i+(12*coordX)].colorValue == 0) { //SineChannel[i].volume(balloonRatio[i]*0.25); // amplitude of sinewave TriangleChannel[i].volume(0.0); // amplitude of trianglewave SquareChannel[i].volume(0.0); // amplitude of squarewave } else if (theBalloons[i+(12*coordX)].colorValue == 1) { // SineChannel[i].volume(0.0); // amplitude of sinewave TriangleChannel[i].volume(balloonRatio[i]*0.25); // amplitude of trianglewave SquareChannel[i].volume(0.0); // amplitude of squarewave } else if (theBalloons[i+(12*coordX)].colorValue == 2) { // SineChannel[i].volume(0.0); // amplitude of sinewave TriangleChannel[i].volume(0.0); // amplitude of trianglewave SquareChannel[i].volume(balloonRatio[i]*0.25); // amplitude of squarewave, dampered because andy doesn't like it } */ /* if (theBalloons[i+(12*coordX)].popValue == 1) { // if balloon pops play sample // println(i + " popped"); PopChannel[i].play(1); } */ } // ------------ VISUALS /* rectMode(CORNER); noStroke(); fill(255,80); rect(0,0,width,height); // draw big white translucent rect over whole image */ strokeWeight(2); //stroke(255,255,0); noStroke(); fill(255,60); //noFill(); rect((coordX*colWt), 0, colWt, height); // draw the jumping rectangle noStroke(); // no outline of balloons // draw balloons for (int i=0; i < numBalloons; i++) { theBalloons[i].touch(); theBalloons[i].checkBalloon(); theBalloons[i].drawBalloon(); /* if (theBalloons[i].popValue == 1) { //PopChannel[i%12] = new AudioChannel((12-(i%12))+".wav"); PopChannel[i%12].play(1); println(i%12+" popped"); } */ } coordX++; // increment coordX to jump to next column for next run-through coordX = coordX % 16; // but modulo 16 // ------------------------- reset values for (int i = 0; i < BoxValues.length; i++) // reset boxvalues to zero { BoxValues[i] = 0; } } void mousePressed(){ Ess.masterMute(!Ess.masterMute); // clicking anywhere causes program to mute } public void stop() { Ess.stop(); super.stop(); } // --- ends ----