Skip to content Skip to sidebar Skip to footer

Extracting The Song Frequency Of An Mp3 File Using Html5 Web Audio Api

I am using the HTML5 web audio API to analyse a song and create markers when the average sound frequency drops below a certain value. Using the existing AudioNode infrastructure, I

Solution 1:

I have been able to find a slide in a presentation which describes exactly this: here

Normal use of the API is to process audio in real-time. Instead, we can pre-process the audio through the entire system and get result:

The only problem is that my understanding of the audio API is too simplistic to see what the 'trick' is from the code sample:

var sampleRate = 44100.0;
var length = 20; // secondsvar ctx = newwebkitAudioContext(2, sampleRate * length, sampleRate);
ctx.oncomplete = function(e) {
  var resultAudioBuffer = e.renderedBuffer;
  ...
};

functionconvolveAudio(audioBuffer, audioBuffer2) {
  var source = ctx.createBufferSource();
  var convolver = ctx.createConvolver();
  source.buffer = audioBuffer;
  convolver.buffer = audioBuffer2;

  // source -> convolver -> destination.
  source.connect(convolver);
  convolver.connect(ctx.destination);

  source.noteOn(0);
  ctx.startRendering();
}

But I thought it would be better to at least share this than to leave it be entirely, even if this isn't exactly the answer I was hoping to give.

Solution 2:

The convolution above is describing a fourier transform, which moves your audio from an intensity over time to an intensity over frequency. I suggest googling javascript fourier transform. Depending on what you're looking for, I saw several useful links on the subject.

Post a Comment for "Extracting The Song Frequency Of An Mp3 File Using Html5 Web Audio Api"