May 29 2019 11:28 PM
Hello,
When trying the HTML below on Edge Dev, on a slow or busy machine, the tone produced by the oscillator changes. The easiest way to reproduce it is to set the affinity of all the msedge.exe processes to a single, same, CPU/core/thread press the "Toggle Play" to start the tone and then play with the size of the window.
2 things may happen in this case:
1. The tone is interrupted at some points
2. After a while the tone changes
#2 is the problematic issue.
Can anyone confirm/explain/suggest a fix?
<html>
<head>
<title>Reuse Audio Stream</title>
<script
src="https://code.jquery.com/jquery-1.9.1.min.js"
integrity="sha256-wS9gmOZBqsqWxgIVgA8Y9WcQOa7PgSIX+rPA0VL2rbQ="
crossorigin="anonymous">
</script>
<script type="text/javascript">
$(window).load(function(){
var ac = new AudioContext();
var dest = ac.createMediaStreamDestination();
var empty = ac.createBufferSource();
empty.connect(dest);
var audio = new Audio();
audio.srcObject = dest.stream;
var graph = {
dest:dest,
audio:audio
};
function play(){
var source = ac.createOscillator();
graph.source = source;
var gainNode = ac.createGain();
source.connect(gainNode);
gainNode.connect(graph.dest);
graph.gainNode = gainNode;
source.start();
graph.isPlaying = true;
}
function stop(){
graph.source.stop();
graph.gainNode.disconnect();
graph.isPlaying = false;
}
function toggle(){
if (graph.isPlaying) {
stop();
}
else {
play();
}
}
$('#toggle').click(function(e) {
audio.play();
toggle();
});
});
</script>
</head>
<body>
<button id="toggle">Toggle Play</button>
</body>
</html>
Aug 26 2019 12:33 PM
That is a very surprising activity, are you running other programs at the same time?
Gabriel
Aug 26 2019 12:56 PM