[5 in 7] “Visualize Music!”

[Sketch]

IMG_6689-2

[Code]

import ddf.minim.*;
import ddf.minim.analysis.*;
import ddf.minim.effects.*;
import ddf.minim.signals.*;
import ddf.minim.spi.*;
import ddf.minim.ugens.*;

PImage n; // Declare variable “a” of type PImage
PImage c;
PImage s;
PImage b;
PImage d;
Minim minim;
AudioSample ny;
AudioSample city;
AudioSample such;
AudioSample beautiful;
AudioSample disease;

void setup() {
size(800, 800);

n = loadImage(“1.png”);
noLoop();
c = loadImage(“2.png”);
noLoop();
s = loadImage(“3.png”);
noLoop();
b = loadImage(“4.png”);
noLoop();
d = loadImage(“5.png”);
noLoop();

minim = new Minim(this);

// The background image must be the same size as the parameters
// into the size() method. In this program, the size of “milan_rubbish.jpg”
// is 200 x 200 pixels.

// load BD.wav from the data folder
ny = minim.loadSample( “1.mp3”, // filename
512 // buffer size
);

city = minim.loadSample(“2.mp3”, 512);
such = minim.loadSample(“3.mp3”, 512);
beautiful = minim.loadSample(“4.mp3”, 512);
disease = minim.loadSample(“5.mp3”, 512);
}

void draw() {
// Displays the image at its actual size at point (0,0)
background(0, 0, 0);
image(n, 10, 0);
image(c, 100, 150);
image(s, 150, 300);
image(b, 250, 450);
image(d, 300, 600);

// use the mix buffer to draw the waveforms.
for (int i = 0; i < ny.bufferSize() – 1; i++) { } } void keyPressed() { if ( key == ‘n’ ) ny.trigger(); if ( key == ‘c’ ) city.trigger(); if ( key == ‘s’ ) such.trigger(); if ( key == ‘b’ ) beautiful.trigger(); if ( key == ‘d’ ) disease.trigger(); } void mousePressed() { if (mouseX>100 && mouseX<150) ny.trigger(); if (mouseX>200 && mouseX<250) city.trigger(); if (mouseX>300 && mouseX<400) such.trigger(); if (mouseX>450 && mouseX<650) beautiful.trigger(); if (mouseX>700 && mouseX<800) disease.trigger();
/*if ( mousePressed ) ny.trigger();*/

}

void stop()
{
// always close Minim audio classes when you are done with them
ny.close();
city.close();
such.close();
beautiful.close();
city.close();

minim.stop();

super.stop();
}

Advertisements
[5 in 7] “Visualize Music!”

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