Visual Music- Winter

Song used- “Johto Ice Path Remix” by Glitchxcity

The Code-

import net.java.games.input.*;
import org.gamecontrolplus.*;
import org.gamecontrolplus.gui.*;

import ddf.minim.*;
import ddf.minim.analysis.*;
import ddf.minim.effects.*;
import ddf.minim.signals.*;
import ddf.minim.spi.*;
import ddf.minim.ugens.*;
ControlIO control;
ControlDevice stick;
ControlIO control2;
ControlDevice stick2;
Minim minim;
AudioPlayer player;
AudioInput input;
AudioPlayer song1;
AudioPlayer song2;
AudioPlayer song3;
BeatDetect beat;
float px, py;
float ox, oy;
float eRadius;
float valueR;
float valueG;
float valueB;
float distance=100;
float rotation1;
float rotation2;
float rotation3;
float rotation4;
float rotation5;
float cX=100;
float cX2=200;
float cX3=300;
float cX4=400;
float cX5=500;
float cY=0;
float cY2=0;
float cY3=0;
float cY4=0;
float cY5=0;
float rX=0;
float rX2=600;
color cani;
int counter=0;
int i=1;
int backbackC=5;
int sC=255;
float snowSpeed = 0.8;

public void setup() {
size (600, 600);
control = ControlIO.getInstance(this);
stick = control.getMatchedDevice(“VisualMusicProject”);
frameRate (60);

minim = new Minim(this);
ellipseMode(RADIUS);
rectMode(CENTER);
eRadius= 20;
song1 = minim.loadFile(“icepath.mp3”, 600);
song1.play();
beat= new BeatDetect();
}

public void draw() {

background (backbackC);
//constraints
if (backbackC>=230) {
backbackC=230;
}
if (backbackC<=20) {
backbackC=20;
}
if (sC<=5) {
sC=5;
}
if (sC>=250) {
sC=250;
}
if ((stick.getButton(“Dup”).pressed())) {
backbackC= backbackC+2;
sC= sC-2;
} else if ((stick.getButton(“Ddown”).pressed())) {
backbackC= backbackC-2;
sC=sC+2;
}
//orbital1

pushMatrix();
stroke(sC);
fill(100, 100, 250);
translate(width/2, height/2);
rotate(radians(rotation1));

if ((stick.getButton(“aButton”).pressed())) {
ellipse(distance, 0, 10, 10);
}
popMatrix();

rotation1+=4;

//orbital2
pushMatrix();
fill(75, 75, 200);
translate(width/2, height/2);
rotate(radians(-rotation2));

if ((stick.getButton(“bButton”).pressed())) {
ellipse(distance+30, 0, 10, 10);
}
popMatrix();

rotation2+=3.5;

//orbital3
pushMatrix();
fill(50, 50, 150);
translate(width/2, height/2);
rotate(radians(rotation3));

if ((stick.getButton(“xButton”).pressed())) {
ellipse(distance+50, 0, 10, 10);
}
popMatrix();

rotation3+=3;

//orbital4
pushMatrix();
fill(25, 25, 100);
translate(width/2, height/2);
rotate(radians(-rotation4));

if ((stick.getButton(“yButton”).pressed())) {
ellipse(distance+70, 0, 10, 10);
}
popMatrix();

rotation4+=2.5;

pushMatrix();
stroke(sC);
fill(sC, sC*backbackC, backbackC);
translate(width/2, height/2);
rotate(radians(rotation5));

if (millis()>=116000 && millis()<=140000) {
ellipse(distance+90, 0, song1.left.get(i+1)*50, song1.left.get(i+1)*50);
}
popMatrix();
rotation5+=1;

if (millis()>=31000 && millis()<= 43000) {
fill(sC);
stroke(backbackC);
ellipse(300, 150, song1.left.get(i+1)*50, song1.left.get(i+1)*50);
}
if (millis()>=37000 && millis()<= 43000) {
fill(sC);
stroke(backbackC);
ellipse(300, 450, song1.left.get(i+1)*50, song1.left.get(i+1)*50);
}

if (millis()>=43000 && millis()<= 77000) {//43000

fill(255);
stroke(0, 0, 100);
ellipse(cX, cY, 10, 10);
cX += snowSpeed;
cY=cY+2;
if (cX>=120) {
snowSpeed = snowSpeed*-1;
}
if (cX<=80) {
snowSpeed = snowSpeed*-1;
}
if (cY>=610) {
cY=0;
}
fill(255);
stroke(0, 0, 100);
ellipse(cX3, cY3, 10, 10);
cX3 += snowSpeed;
cY3=cY3+2;
//if (cX3>=320) {
// snowSpeed = snowSpeed*-1;
//}
//if (cX3<=280) {
// snowSpeed = snowSpeed*-1;
//}
if (cY3>=610) {
cY3=0;
}
fill(255);
stroke(0, 0, 100);
ellipse(cX5, cY5, 10, 10);
cX5 += snowSpeed;
cY5=cY5+2;
if (cY5>=610) {
cY5=0;
}
}
if (millis()>=45000 && millis()<=77000) {//snowflake1 (default: 45000)
fill(255);
stroke(0, 0, 100);
ellipse(cX2, cY2, 5, 5);
cX2 += snowSpeed;
cY2=cY2+2;
if (cY2>=610) {
cY2=0;
}
fill(255);
stroke(0, 0, 100);
ellipse(cX4, cY4, 5, 5);
cX4 += snowSpeed;
cY4=cY4+2;
if (cY4>=610) {
cY4=0;
}
}
if (millis()>= 77500 && millis()<=116000) {
fill(backbackC/2, 0, backbackC);
stroke(sC,sC, sC);
ellipse(100, 100, song1.left.get(i+1)*50, song1.left.get(i+1)*50);
fill(backbackC/2, 0, backbackC);
stroke(sC,sC, sC);
ellipse(500, 500, song1.left.get(i+1)*50, song1.left.get(i+1)*50);
}
if (millis()>= 90000 && millis()<=116000) {
fill(sC, sC, sC);
stroke(backbackC, backbackC/2, backbackC);
ellipse(500, 100, song1.left.get(i+1)*50, song1.left.get(i+1)*50);
fill(sC, sC, sC);
stroke(backbackC, backbackC/2, backbackC);
ellipse(100, 500, song1.left.get(i+1)*50, song1.left.get(i+1)*50);
}

if (millis()>=85000 && millis()<=97000) {
fill(0,0,sC);
stroke(0,0,backbackC);
ellipse(100, 300, song1.left.get(i+1)*50, song1.left.get(i+1)*50);
fill(0,0,sC);
stroke(0,0,backbackC);
ellipse(500, 300, song1.left.get(i+1)*50, song1.left.get(i+1)*50);
}
for (int i = 1; i < song1.bufferSize() – 1; i++)
{
stroke(random(song1.right.get(i+1)*random(500)), random(song1.left.get(i+1)*random(5000)), random(song1.left.get(i+1)*random(5000)));
line(10 + song1.left.get(i+1)*100, i+1, 10 + song1.left.get(i+1), i+1);
line(590 + song1.left.get(i-1)*100, i-1, 590 + song1.left.get(i-1), i-1);
beat.detect(song1.mix);

float a = map(eRadius, 20, 80, 60, 255);
fill(0, random(100), random(255), random(a));
if ( beat.isOnset() ) eRadius = 50;
}
stroke(sC);
ellipse(width/2, height/2, song1.left.get(i+1)*200, song1.left.get(i+1)*200);
fill(0, random(50), random(250));
rect(width/2, height/2, song1.left.get(i+1)*100, song1.left.get(i+1)*70);
//eRadius *= 1;
if ( eRadius <= 40) eRadius = 40;
else if (eRadius >= 50) eRadius= 40;
}
//cut off at 218

Advertisements
This entry was posted in Non-Time Based 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