1 | //https://github.com/fukuchi/perfumedance_p5 |
---|
2 | |
---|
3 | import ddf.minim.*; |
---|
4 | import ddf.minim.analysis.*; |
---|
5 | |
---|
6 | BvhParser parserA = new BvhParser(); |
---|
7 | PBvh bvh1, bvh2, bvh3; |
---|
8 | |
---|
9 | AudioPlayer player; |
---|
10 | Minim minim; |
---|
11 | FFT fft; |
---|
12 | |
---|
13 | float soundLevel = 0; |
---|
14 | |
---|
15 | public void setup() |
---|
16 | { |
---|
17 | size(1280, 720, P3D); |
---|
18 | background(0); |
---|
19 | noStroke(); |
---|
20 | frameRate(40); |
---|
21 | |
---|
22 | bvh1 = new PBvh(loadStrings("kashiyuka.bvh"),color(255,180,180)); |
---|
23 | bvh2 = new PBvh(loadStrings("nocchi.bvh"),color(96,96,255)); |
---|
24 | bvh3 = new PBvh(loadStrings("aachan.bvh"),color(255,0,0)); |
---|
25 | |
---|
26 | minim = new Minim(this); |
---|
27 | player = minim.loadFile("Perfume_globalsite_sound.wav"); |
---|
28 | fft = new FFT(player.bufferSize(), player.sampleRate()); |
---|
29 | |
---|
30 | player.printControls(); |
---|
31 | |
---|
32 | player.play(); |
---|
33 | player.loop(); |
---|
34 | } |
---|
35 | |
---|
36 | public void draw() |
---|
37 | { |
---|
38 | int currentTime = player.position(); |
---|
39 | |
---|
40 | fft.forward(player.mix); |
---|
41 | background(color(255,255,128)); |
---|
42 | soundLevel = 0; |
---|
43 | for (int i=0; i<fft.specSize(); i++) { |
---|
44 | soundLevel += fft.getBand(i); |
---|
45 | } |
---|
46 | |
---|
47 | //camera |
---|
48 | float _cos = cos(currentTime / 5000.f); |
---|
49 | float _sin = sin(currentTime / 5000.f); |
---|
50 | camera(width/4.f + width/4.f * _cos +200, height/2.0f-100, 550 + 150 * _sin, width/2.0f, height/2.0f, -400, 0, 1, 0); |
---|
51 | |
---|
52 | //ground |
---|
53 | fill(color(0)); |
---|
54 | stroke(127); |
---|
55 | line(width/2.0f, height/2.0f, -30, width/2.0f, height/2.0f, 30); |
---|
56 | stroke(127); |
---|
57 | line(width/2.0f-30, height/2.0f, 0, width/2.0f + 30, height/2.0f, 0); |
---|
58 | stroke(255); |
---|
59 | pushMatrix(); |
---|
60 | translate(width/2, height/2-10, 0); |
---|
61 | rotateX(PI); |
---|
62 | sphereDetail(10); |
---|
63 | lights(); |
---|
64 | directionalLight(100, 100, 100, -1, -1, 0); |
---|
65 | |
---|
66 | //model |
---|
67 | bvh1.update(currentTime); |
---|
68 | bvh2.update(currentTime); |
---|
69 | bvh3.update(currentTime); |
---|
70 | bvh1.draw(); |
---|
71 | bvh2.draw(); |
---|
72 | bvh3.draw(); |
---|
73 | popMatrix(); |
---|
74 | } |
---|
75 | |
---|