-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMusic_Vis.pde
56 lines (50 loc) · 1.61 KB
/
Music_Vis.pde
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import ddf.minim.analysis.*;
import ddf.minim.*;
Minim minim;
AudioPlayer mySong;
FFT fftL;
FFT fftR;
int _scale = 80;
void setup()
{
size(854, 480);
colorMode(HSB, 360, 100, 100, 256);
frameRate(60);
smooth();
strokeWeight(1);
minim = new Minim(this);
mySong = minim.loadFile("Bruno-Mars---The-Lazy-Song--OFFICIAL-VIDEO.mp3", 1024);
mySong.loop();
fftL = new FFT( mySong.bufferSize(), mySong.sampleRate() );
fftR = new FFT( mySong.bufferSize(), mySong.sampleRate() );
}
void draw()
{
background(#000000);
fftL.forward( mySong.left );
for (int i = 0; i < fftL.specSize()-1; i++)
{
float adjust = log(i+1)/log(2);
//float valueOnBand = log(fftL.getBand(i)*adjust+1)*_scale;
//float valueOnNextBand = log(fftL.getBand(i+1)*adjust+1)*_scale;
float valueOnBand = log(fftL.getBand(i)*adjust+1);
float valueOnNextBand = log(fftL.getBand(i+1)*adjust+1);
float x = map(i, 0, fftL.specSize(), 0, 853);
float xNext = map(i+1, 0, fftL.specSize(), 0, 853);
//stroke(67, 80, 90,200);
stroke(30, 40, 20, 40);
ellipse( x, height - valueOnBand, xNext, height - valueOnNextBand );
}
fftR.forward( mySong.right );
for (int i = 0; i < fftR.specSize()-1; i++)
{
float adjust = log(i+1)/log(2);
float valueOnBand = log(fftR.getBand(i)*adjust+1)*_scale;
float valueOnNextBand = log(fftR.getBand(i+1)*adjust+1)*_scale;
float x = map(i, 0, fftR.specSize(), 0, 853);
float xNext = map(i+1, 0, fftR.specSize(), 0, 853);
//stroke(179, 80, 90);
stroke(50, 40, 45);
ellipse( x, height - valueOnBand, xNext, height - valueOnNextBand );
}
}