Processing Audio Project

When starting the program a song will begin to play and a smoke/flame will appear wherever the mouse is positioned in the program. When clicking, not only will the flame change color but the song will change, In the video the two songs are two different versions of the same song. When the mouse is released the song and flame will return to their original states.

//Made using the extension PixelFlow 0.21 by Thomas Diewald\\
//Made with help from Aidan Wilson and Jordan Williams\\
//Songs used; Battle Themes from the Playstation and\\
//Playstation Portable versions of Persona 2\\

import com.thomasdiewald.pixelflow.java.DwPixelFlow;
import com.thomasdiewald.pixelflow.java.fluid.DwFluid2D;

import ddf.minim.*;
import ddf.minim.analysis.*;
int innerSize=30;
int XPos = mouseX;
int songa = 0;
int songb = 1;
Minim minim;
AudioPlayer song;
AudioPlayer song2;
FFT fft;
BeatDetect beat;
float eRadius;
boolean toggle = false;

DwFluid2D fluid;
PGraphics2D pg_fluid;
public void setup()
{
size(512, 700, P2D);
DwPixelFlow context = new DwPixelFlow(this);
fluid = new DwFluid2D(context, width, height, 1);
fluid.param.dissipation_velocity = 1f;
fluid.param.dissipation_density = 1f;

pg_fluid = (PGraphics2D) createGraphics(width, height, P2D);

minim = new Minim(this);
song = minim.loadFile(“Persona2.mp3”, 512);
song2 = minim.loadFile(“Persona 22.mp3”, 512);
fft = new FFT(song.bufferSize(), song.sampleRate());
beat = new BeatDetect();
eRadius=20;
}

public void draw()
{
song.play();
song2.play();
background(0);
if (toggle == false) {
song.unmute();
song2.mute();
if ( beat.isOnset() ) eRadius = 80;
float px = mouseX; //places smoke in Xposition
float py = -mouseY+700; //subtract because sim Y is flipped
float vx = random(-300, 300);
float vy = eRadius + random(-50, 500);
if ( eRadius < 20 ) eRadius = 20;
fluid.addVelocity(px, py, 30, vx, vy);
fluid.addDensity (px, py, 50, 1f, 0f, 0f, 1f, 1); //outer smoke
fluid.addDensity (px, py, innerSize, 0f, 0f, 0f, 1.0f, 1); //inner smoke
}
if (toggle == true) {
song.mute();
song2.unmute();
if ( beat.isOnset() ) eRadius = 80;
float px = mouseX;
float py = -mouseY+700;
float vx = random(-300, 300);
float vy = eRadius + random(-50, 50);
if ( eRadius < 20 ) eRadius = 20;
fluid.addVelocity(px, py, 24, vx, vy);
fluid.addDensity (px, py, 50, .5f, 0f, 1f, 1f, 1);
fluid.addDensity (px, py, innerSize, 1f, 1f, 1f, 1.0f, 1);
}

if (key == ‘z’) {
song.mute();
song2.mute();
}
if (key == ‘x’) {
song.unmute();
song2.mute();
}

fft.forward(song.mix);
beat.detect(song.mix);
if (beat.isOnset() ) eRadius = 400;
innerSize=100;
eRadius*=.90;
innerSize*=.3;
if (eRadius<80) eRadius=30;
if (innerSize<30) innerSize=30;
fluid.addCallback_FluiData(new DwFluid2D.FluidData() {
public void update(DwFluid2D fluid) {

//brightsmoke
}
}
);

fluid.update();

// clear render target
pg_fluid.beginDraw();
pg_fluid.background(0);
pg_fluid.endDraw();

// render fluid stuff
fluid.renderFluidTextures(pg_fluid, 0);

// display
image(pg_fluid, 0, 0);
}
void mousePressed() {
toggle = true;
}
void mouseReleased() {
toggle = false;
}

Advertisements
This entry was posted in Interactive Authoring and tagged , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s