Convert AudioBuffer to ArrayBuffer

I’ve been looking all over the internet for an answer to this question and I can’t find any resources. Does anyone know how to use JavaScript to convert and AudioBuffer object to an ArrayBuffer? This is my current attempt

//Send audio data to websockets server
function callback(stream) {

var ws = new WebSocket("ws://localhost:8080");
ws.binaryType = 'arraybuffer';

var context = new webkitAudioContext();
var mediaStreamSource = context.createMediaStreamSource(stream);
console.log(mediaStreamSource);

var request = new XMLHttpRequest();
request.open('GET', 'http://s3.amazonaws.com/fldrMusic/01_-%20Fire%20Walker.mp3', true);    
request.responseType = 'arraybuffer'; 

console.log("Current 'request.response' value");  
console.log(request.response);

request.onload = function() {
  context.decodeAudioData(request.response, function(buffer){

    console.log("sent message");
    console.log(buffer); 
    ws.send(buffer);

    //Serialize javascript object
    console.log("sent message encoded");       
    var buff = Base64Binary.decodeArrayBuffer(buffer.toString());       
    console.log(buff);


  }, 
  function(buffer){ 
    alert("decode failed!");
  })
} 

request.send();
}//end 'callback' function

  • how can I reverse playback in web audio API but keep a forward version as well?
  • AudioBufferSourceNode.buffer deprecated?
  • merging / layering multiple ArrayBuffers into one AudioBuffer using Web Audio API
  • merging / layering multiple ArrayBuffers into one AudioBuffer using Web Audio API
  • AudioBufferSourceNode.buffer deprecated?
  • how can I reverse playback in web audio API but keep a forward version as well?
  • One Solution collect form web for “Convert AudioBuffer to ArrayBuffer”

    AudioBuffer.getChannelData(channel_number);
    

    You can get the number of channels from AudioBuffer.numberOfChannels

    EDIT:
    For more details, you can check the MDN docs for AudioBuffer and the getChannelData method.