first try for a simple repro of firefox resample fail (failed)

This commit is contained in:
2022-06-09 23:36:23 +02:00
parent 7a6dd0ab6d
commit 95d0d92a6f

35
web/opus-repro.html Normal file
View File

@@ -0,0 +1,35 @@
<html>
<button onclick="go()">Go!</button>
<script>
function go() {
let audioContext = new AudioContext({sampleRate: 44100});
let oscillator = new OscillatorNode(audioContext);
let gain = new GainNode(audioContext, {gain: 1});
oscillator.connect(gain);
gain.connect(audioContext.destination);
for(let i = 0; i < 4; ++i ) {
gain.gain.setValueAtTime(1, i / 2);
gain.gain.setValueAtTime(0, i / 2 + 0.3);
}
oscillator.start();
oscillator.stop(2);
let audioStreamNode = audioContext.createMediaStreamDestination();
gain.connect(audioStreamNode);
let recorder = new MediaRecorder(audioStreamNode.stream, { mimeType: 'audio/ogg; codecs=opus' });
let chunks = [];
recorder.ondataavailable = e => chunks.push(e.data);
recorder.onstop = () => {
let blob = new Blob(chunks, {type: 'audio/ogg; codecs=opus'});
let url = URL.createObjectURL(blob);
let audio = new Audio(url);
audio.play();
};
recorder.start();
setTimeout(() => recorder.stop(), 2000);
}
</script>
</html>