Created
October 28, 2015 15:07
-
-
Save danaabs/cd7f1c88ff77f812c9c7 to your computer and use it in GitHub Desktop.
klaus
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var song; | |
var klaus; | |
var fft; | |
function preload() { | |
klaus = createVideo('klaus.mp4'); | |
song = loadSound("Klaus.mp3"); | |
} | |
function setup() { | |
canvas = createCanvas(1500, 800); | |
klaus.position(0, 0); | |
klaus.size(300, 200); | |
klaus.addCue(0, pauseSong); | |
// klaus.addCue(1, playSong); | |
klaus.loop(); | |
// song.play(); | |
for (var i = 0; i < 170; i+=5) { | |
klaus.addCue(i, addVideo); | |
} | |
klaus.addCue(170, bigVideo); | |
for (var i = 253; i < 300; i+=4) { | |
klaus.addCue(i, addVideo); | |
} | |
// klaus.addCue(20, addVideo); | |
song.loop(); | |
fft = new p5.FFT(); | |
} | |
function draw() { | |
background(0); | |
var spectrum = fft.analyze(); | |
for (var i = 0; i < spectrum.length; i++) { | |
stroke(255); | |
// The FFT range is between 0 and 1, we map it to pixels | |
var y = map(spectrum[i], 0, 255, height, 0); | |
line(i, height, i, y); | |
} | |
fill(0); | |
noStroke(0); | |
textSize(40); | |
textStyle(BOLD); | |
textFont('Helvetica'); | |
text("klaus obermaier", 0, 650, 600, 600); | |
fill(100); | |
for (var i = 1; i < width; i+=20) { | |
ellipse(i, mouseY, 10, 2); | |
} | |
map(mouseY, 0, 700, 0, 1); | |
song.amp(mouseY); | |
} | |
function addVideo() { | |
klaus | |
klaus.position(random(0, 900), random(0, 200)); | |
} | |
function playSong() { | |
song.play(); | |
song.loop(); | |
} | |
function bigVideo() { | |
klaus.size(800, 700); | |
} | |
function pauseSong() { | |
song.stop(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment