There is something strange here. I create an audio buffer that stores it in a variable and try to reuse it several times - but it seems to be damaged
I make a few buttons
<button onclick="play();">play(0)</button> <button onclick="playsection();">play section</button> <button onclick="stop();">stop()</button>
Get some audio
context = new AudioContext(); var getWav = new XMLHttpRequest(); var wavbuf; getWav.open("GET", "/wav/test.wav", true); getWav.responseType = "arraybuffer"; getWav.onload = function() { context.decodeAudioData(getWav.response, function(buffer){ wavbuf = buffer; }); } getWav.send(); var p;
I can evaluate play () several times without error
function play(){ p = context.createBufferSource(); p.buffer = wavbuf; p.connect(context.destination); p.start(0); }
reproduced seems to work only once - or sometimes more than once if I stop before stopping (10), evaluating
function playsection(){ p = context.createBufferSource(); p.buffer = wavbuf; p.connect(context.destination); p.start(0, 6);
It looks like p.buffer = wavbuf is creating a pointer to the buffer, not a copy
Is this a bug or function?
source share