Note that there are some explanatory texts on larger screens.

plurals
  1. POdecodeAudioData HTML5 Audio API
    text
    copied!<p>I want to play audio data from an ArrayBuffer... so I generate my array and fill it with microfone input. If I draw this data on a canvas it looks like --> <img src="https://i.stack.imgur.com/Bhb8Q.png" alt="enter image description here"></p> <p>So this works!</p> <p>But if i want to listen to this data with</p> <pre><code>context.decodeAudioData(tmp, function(bufferN) { //tmp is a arrayBuffer var out = context.createBufferSource(); out.buffer = bufferN; out.connect(context.destination); out.noteOn(0); }, errorFunction); </code></pre> <p>I dont hear anything... because the errorFunction is called. But error is null!</p> <p>I also tryed to get the buffer like that:</p> <pre><code>var soundBuffer = context.createBuffer(myArrayBuffer, true/*make mono*/); </code></pre> <p>But i get the error: Uncaught SyntaxError: An invalid or illegal string was specified. </p> <p>anybody who can give me a hint ?</p> <p><strong>EDIT 1 (More code and how I get the mic input):</strong></p> <pre><code> navigator.webkitGetUserMedia({audio: true}, function(stream) { liveSource = context.createMediaStreamSource(stream); // create a ScriptProcessorNode if(!context.createScriptProcessor){ node = context.createJavaScriptNode(2048, 1, 1); } else { node = context.createScriptProcessor(2048, 1, 1); } node.onaudioprocess = function(e){ var tmp = new Uint8Array(e.inputBuffer.byteLength); tmp.set(new Uint8Array(e.inputBuffer.byteLength), 0); //Here comes the code from above. </code></pre> <p>Thanks for your help!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload