Skip to content

Instantly share code, notes, and snippets.

@micromeeeter
Last active August 29, 2015 14:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save micromeeeter/13cbc2cbf9e1ed43b58a to your computer and use it in GitHub Desktop.
Save micromeeeter/13cbc2cbf9e1ed43b58a to your computer and use it in GitHub Desktop.
myVisalizer_02_projection
//https://www.youtube.com/watch?v=_gfaIGxQ-Dg
//http://micromeeeter.hateblo.jp/entry/2014/11/29/000706
import ddf.minim.*;
Minim minim;
AudioPlayer player;
final int turnNumber = 45; //Rotational speed 0f the record (33, 45, ...)
final int fps = 60;
final int sampleRate = 512;
final int N = 8; //Number of ellipse
float waveHA;
float waveHB;
void setup(){
size(800, 800);
frameRate(fps);
colorMode(HSB, 360, 100, 100);
minim = new Minim(this);
player = minim.loadFile("14 Dream Land.mp3", sampleRate); //insert the name of music number between " " after you add it in 'data' file.
waveHA = width / 3;
waveHB = width / 9;
smooth();
background(0, 0, 0);
}
void draw(){
background(0, 0, 0);
translate(width / 2, height / 2);
rotate(- (2 * turnNumber * PI) / (60 * fps) * frameCount);
//Draw ellipse
for(int i = 0; i < N; i++){
noStroke();
fill(360 / N * i, 99, 99, (player.mix.get(i * sampleRate / N) + 1) * 150);
ellipse(waveHA * cos(PI / (N / 2) * i), waveHA * sin(PI / (N / 2) * i), (player.mix.get(i * sampleRate / N) + 1) * 150, (player.mix.get(i * sampleRate / N) + 1) * 150);
}
//Draw grain
for(int i = 0; i < sampleRate / 2; i++){
float theta = PI / (sampleRate / 4) * i;
float data = player.mix.get(2 * i);
noStroke();
fill(0, 0, 99);
ellipse(waveHB * cos(theta) * (data + 1 + 1.6), waveHB * sin(theta) * (data + 1 + 1.6), (data + 1 )* 7, (data + 1 )* 7);
}
}
void keyPressed(){
if(key == 'a'){
player.loop();
}
}
void stop(){
player.close();
minim.stop();
super.stop();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment