-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
25 lines (25 loc) · 931 Bytes
/
index.js
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
const button = document.getElementById('button')
button.onclick = () => {
const audioContext = new window.AudioContext()
navigator.mediaDevices.getUserMedia({ audio: {
echoCancellation: false,
googEchoCancellation: false,
googAutoGainControl: false,
googAutoGainControl2: false,
googNoiseSuppression: false,
googHighpassFilter: false,
googTypingNoiseDetection: false
}}).then((stream) => {
console.log('got media sources')
// Create an AudioNode from the stream.
const mediaStreamSource = audioContext.createMediaStreamSource(stream)
// Create a new volume meter and connect it.
const meter = createAudioMeter(audioContext)
mediaStreamSource.connect(meter)
}).catch((e) => {
document.getElementById('status').innerText =
`Error getting mic input: ${e}`
})
button.style.display = 'none'
document.getElementById('status').innerText = 'Make some noise...'
}