Skip to content

Instantly share code, notes, and snippets.

@Anduin2017
Created June 22, 2020 06:13
Show Gist options
  • Save Anduin2017/a420896b61a3881cfae3de42716088c8 to your computer and use it in GitHub Desktop.
Save Anduin2017/a420896b61a3881cfae3de42716088c8 to your computer and use it in GitHub Desktop.
Echo back microphone.
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>capture microphone audio into buffer</title>
<script type="text/javascript">
var audioContext = new AudioContext();
if (navigator.getUserMedia) {
navigator.getUserMedia({ audio: true }, function (stream) {
var streamSource = audioContext.createMediaStreamSource(stream);
var gain = audioContext.createGain();
gain.connect(audioContext.destination);
streamSource.connect(gain);
document.getElementById('volume').addEventListener('change', function () {
gain.gain.value = this.value;
});
}, function () {
});
}
</script>
</head>
<body>
<p>Volume</p>
<input id="volume" type="range" min="0" max="1" step="0.1" value="0.5" />
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment