-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathindex.html
76 lines (73 loc) · 2.11 KB
/
index.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
73
74
75
76
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>weq8</title>
<script type="module" src="/src/ui/index.ts"></script>
<style type="text/css">
body {
background-color: #555;
color: white;
}
.viewSelect {
display: flex;
justify-content: center;
margin: 20px 0;
}
button {
display: block;
margin: 50px auto;
}
weq8-ui {
max-width: 800px;
margin: 0 auto;
}
</style>
</head>
<body>
<button id="startstop">Start</button>
<div class="viewSelect">
<label
><input type="radio" name="view" value="allBands" checked /> All
bands</label
>
<label><input type="radio" name="view" value="hud" /> HUD</label>
</div>
<weq8-ui view="allBands" />
<script type="module">
import { WEQ8Runtime } from "/src/main.ts";
let audioctx = new AudioContext();
let runtime = new WEQ8Runtime(audioctx);
runtime.connect(audioctx.destination);
fetch("/testloop.m4a")
.then((res) => res.arrayBuffer())
.then((buf) => audioctx.decodeAudioData(buf))
.then((buf) => {
let btn = document.getElementById("startstop");
let src;
btn.addEventListener("click", () => {
if (btn.textContent == "Start") {
src = audioctx.createBufferSource();
src.buffer = buf;
src.loop = true;
src.connect(runtime.input);
src.start();
btn.textContent = "Stop";
} else {
src.stop();
src.disconnect();
src = null;
btn.textContent = "Start";
}
});
});
document.querySelector("weq8-ui").runtime = runtime;
document.querySelectorAll("input[name=view]").forEach((el) =>
el.addEventListener("change", (e) => {
document.querySelector("weq8-ui").view = e.target.value;
})
);
</script>
</body>
</html>