I made a small John Cage-ish piano tune, and then I programmed a video for it, nothing huge. Just wanted to learn a little about opengl in processing.
Anyway, here it is:
and here’s the code:
import ddf.minim.*;
Minim minim;
AudioPlayer player;
PImage img;
int diff = 40;
int daff = 40;
void setup() {
minim = new Minim(this);
size(640, 360, P3D);
frameRate(20);
img = loadImage("lines.png");
noStroke();
player = minim.loadFile("mister_mister.mp3");
noLoop();
}
float cnt =0;
float cntInc =0.05;
float cntIncIncer =0.05;
void draw() {
background(0);
int trianglesize = width-(diff*2);
int meanpos = height-diff;
daff = (int)random(4);
beginShape();
cnt+=cntInc;
if (cnt>(9*2))
{
cnt=0;
cntInc+=cntIncIncer;
}
if (cntInc > 8)
{
img = loadImage("lines2.png");
cntIncIncer-=cntIncIncer*2.0;
}
texture(img);
vertex(width/2, diff, 0, (300/2)+cnt, 0+cnt);
vertex(0+diff, height-diff, 0, 0+cnt, 300+cnt);
for (int i = 0; i < player.bufferSize() - 1; i+=1)
{
float x1 = map( i, 0, player.bufferSize(), 0, trianglesize );
float x2 = map( i+1, 0, player.bufferSize(), 0, trianglesize );
vertex( x1+diff, meanpos + player.left.get(i)* ((cntInc*3)+10), 0, 00+cnt, 300+cnt);
vertex( x2+diff, meanpos + player.left.get(i+1)*((cntInc*3)+10), 0, 00+cnt, 300+cnt);
}
vertex(width-diff, height-diff, 0, 00+cnt, 300+cnt);
endShape();
if (player.isPlaying())
{
saveFrame("frames/########.tif");
}
else
{
println("DONE");
noLoop();
}
}
void keyPressed() {
println("start!");
player.play();
loop();
}
Riktigt schysst. Jag gillar både låten och visualiseringen.