Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import ddf.minim.*;
- import ddf.minim.analysis.*;
- Minim minim;
- AudioPlayer song;
- BeatDetect beat;
- float bottomSpeed = random(1.0);
- float topSpeed = random(1.0);
- int t = 0;
- color[] COLORS = {
- color(255, 0, 0),
- color(255, 255, 0),
- color(0, 255, 0),
- color(0, 255, 255),
- color(0, 0, 255),
- color(255, 0, 255)
- };
- boolean leftShape = true;
- int leftOpacity = 0;
- int leftTopPos = 0;
- int leftBottomPos = 0;
- color leftCurrentColor = COLORS[(int) random(COLORS.length)];
- int rightOpacity = 0;
- int rightTopPos = 0;
- int rightBottomPos = 0;
- color rightCurrentColor = COLORS[(int) random(COLORS.length)];
- void setup() {
- fullScreen();
- minim = new Minim(this);
- song = minim.loadFile("/Users/timco/Music/The Necks - Body/The Necks - Body - 01 Body.mp3", 2048);
- song.play();
- beat = new BeatDetect();
- }
- void draw() {
- beat.detect(song.mix);
- if(beat.isOnset()) {
- if(leftShape) {
- leftBottomPos = floor(width /2 + sin(bottomSpeed*t) * width / 2);
- leftTopPos = floor(width / 2 + sin(topSpeed*t) * width / 2);
- leftCurrentColor = COLORS[(int) random(COLORS.length)];
- leftOpacity = 255;
- } else {
- rightBottomPos = floor(width /2 + cos(bottomSpeed*t) * width / 2);
- rightTopPos = floor(width / 2 + cos(topSpeed*t) * width / 2);
- rightCurrentColor = COLORS[(int) random(COLORS.length)];
- rightOpacity = 255;
- }
- leftShape = !leftShape;
- }
- background(0);
- fill(leftCurrentColor, leftOpacity);
- beginShape();
- vertex(0, 0);
- vertex(leftTopPos, 0);
- vertex(leftBottomPos, height);
- vertex(0, height);
- endShape(CLOSE);
- fill(rightCurrentColor, rightOpacity);
- beginShape();
- vertex(rightTopPos, 0);
- vertex(width, 0);
- vertex(width, height);
- vertex(rightBottomPos, height);
- endShape(CLOSE);
- t++;
- leftOpacity *= 0.95;
- rightOpacity *= 0.95;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement