forked from foobar404/wave.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathanalyser.html
42 lines (34 loc) · 1.25 KB
/
analyser.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
<script src="../dist/bundle.js"></script>
<style>
html,
body {
margin: 0;
padding: 0;
}
</style>
</head>
<body>
<canvas height="200" width="200"></canvas>
<audio src="./audio.mp3" controls style="position: fixed; right: 0px"></audio>
<script>
let canvas = document.querySelector("canvas");
let audio = document.querySelector("audio");
const context = new AudioContext();
const source = context.createMediaElementSource(document.querySelector("audio"));
const analyser = context.createAnalyser();
source.connect(analyser);
analyser.connect(context.destination);
let wave = new Wave(analyser, canvas);
canvas.height = window.innerHeight - 30;
canvas.width = window.innerWidth - 30;
wave.addAnimation(new wave.animations.Cubes());
</script>
</body>
</html>