mardi 5 septembre 2017

web audio api sampling rate always return 48000

I used Web Audio API to load a wave file.

the format of input wave files maybe 44.1Khz/16bit or 48khz/24bit or....

but when I try to fetch the sampling rate,

It always return 48000?

and how do I to fetch the bit depth of the wave file ?

please help..

here is a part of code. or http://ift.tt/2wDj7FS

  var audioCtx = new (window.AudioContext || window.webkitAudioContext)();

  var source = audioCtx.createBufferSource();
  var request = new XMLHttpRequest();
  request.open('GET', fileurl, true);
  request.responseType = 'arraybuffer';
  
  request.onload = function() {
  
  var audioData = request.response;
    
  audioCtx.decodeAudioData(audioData, function(buffer) {
    
        source.buffer = buffer;
        source.connect(audioCtx.destination);
        source.loop = true;
       
        console.log(source.buffer.sampleRate);
                     
      },

     function(e){ console.log("Error with decoding audio data" + e.err); });

  }

Aucun commentaire:

Enregistrer un commentaire