-
Notifications
You must be signed in to change notification settings - Fork 0
/
taylor.html
72 lines (58 loc) · 1.62 KB
/
taylor.html
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<!DOCTYPE html>
<html>
<head>
<script src="js/jquery-2.1.1.min.js"></script>
<link rel="stylesheet" type="text/css" href="css/style.css" />
<meta charset="UTF-8">
<title>An audio experiment.</title>
</head>
<body>
<div class="someDiv">
<canvas id="someCanvas"></canvas>
</div>
<script type="text/javascript" src="js/ParticleMachineTaylor.js"></script>
<script type="text/javascript" src="js/utils.js"></script>
<script type="text/javascript" src="libs/gs/TweenMax.min.js"></script>
<script language="javascript" src="js/p5.js"></script>
<script language="javascript" src="js/addons/p5.dom.js"></script>
<script language="javascript" src="js/addons/p5.sound.js"></script>
<script>
var p0Machine, mic, fft, inited=false;
var pos = 0;
setTimeout(startup, 2000);
function setup() {
mic = new p5.AudioIn()
mic.start()
fft = new p5.FFT();
fft.setInput(mic, 128);
p0Machine = new ParticleMachine(
'data/taylor-logo-red-yellow-border.json', '.someDiv',
'#someCanvas');
}
function startup() {
p0Machine.init();
inited = true;
}
function draw() {
var volume = mic.getLevel();
var spectrum = fft.analyze();
/* for (i = 0; i < spectrum.length; i++) {
console.log(spectrum[i]);
} */
/* if (volume > .02) {
if (inited) pos += volume/10;
if (inited) p0Machine.setPosition(pos);
} */
if (volume > .02) {
if (inited) p0Machine.setSpectrum(spectrum, volume);
} else {
if (inited) p0Machine.setPosition(1);
}
}
/* function didRiseAbove(volume) {
var threshold = 0.1;
return (volume > threshold)
} */
</script>
</body>
</html>