-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
49 lines (45 loc) · 1.17 KB
/
main.js
File metadata and controls
49 lines (45 loc) · 1.17 KB
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
const PADDING = 20;
function setup() {
const radius = min(windowHeight * .8, windowWidth);
createCanvas(radius, radius)
.parent('canvas-div');
canvas.start();
}
function draw() {
handleAmpRotate();
for (let i = 0; i < parameters.trace_multi; i ++) {
canvas.draw();
}
}
const debug = () => {
piano.setActivation(60, 1);
piano.setActivation(67, 1);
};
const userInteract = () => {
document.getElementById('welcome').style.display = 'none';
document.getElementById('main').style.display = 'block';
const head = document.getElementById('head');
const p5Script = document.createElement('script');
head.appendChild(p5Script);
p5Script.onload = () => {
const sound = document.createElement('script');
head.appendChild(sound);
sound.onload = () => {
for (let i = 0; i < 128; i ++) {
piano.sine.push(new p5.Oscillator('sine'));
}
onMenuChange();
};
sound.src = 'p5.sound.min.js';
};
p5Script.src = 'p5.min.js';
if (window.innerWidth > 700) {
buildPiano(60 - 24, 60 + 24);
} else {
if (window.innerWidth > 380) {
buildPiano(60 - 12, 60 + 12);
} else {
buildPiano(60, 60 + 12);
}
}
};