-
Notifications
You must be signed in to change notification settings - Fork 0
/
audiopan.html
executable file
·40 lines (38 loc) · 1.03 KB
/
audiopan.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<script>
var context
window.addEventListener('load', init, false)
function init() {
console.log('init')
try {
window.AudioContext = window.AudioContext||window.webkitAudioContext
context = new AudioContext()
console.log('getting media')
navigator.webkitGetUserMedia({audio: true}, function(localMediaStream) {
console.log('got media, connecting')
var microphone = context.createMediaStreamSource(localMediaStream)
var filter = context.createStereoPanner()
microphone.connect(filter)
filter.connect(context.destination)
var t = 0
window.setInterval(function() {
var a = Math.sin(2 * 3.142 * t/1000)
console.log(a)
filter.pan.value = a
t++
}, 1)
}, function(e) {console.log(e)})
}
catch (e) {
alert(e)
}
}
</script>
</body>
</html>