-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
example.html
42 lines (34 loc) · 1.07 KB
/
example.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>
<head>
<meta charset="utf-8">
<title>analyzer-node</title>
</head>
<body>
<script src="build/build.js"></script>
<script>
var Analyzer = require('analyzer');
var getUserMedia = require('get-user-media');
var Context = window.audioContext || window.webkitAudioContext;
getUserMedia({ audio: true }, function(err, stream) {
if (err) throw err;
var ctx = new Context;
var mic = ctx.createMediaStreamSource(stream);
var analyzer = Analyzer(ctx).add('mic', mic);
analyzer.on('float frequency data', function(data) {
console.log('float frequency data', data.mic);
});
analyzer.on('byte frequency data', function(data) {
console.log('byte frequency data', data.mic);
});
analyzer.on('byte time domain data', function(data) {
console.log('byte time domain data', data.mic);
});
setTimeout(function() {
analyzer.pause();
console.log('ended processing');
}, 1000);
});
</script>
</body>
</html>