Search code examples
javascriptweb-audio-api

Web Audio API: FFT data in firefox differ from those in chrome, when using media stream?


I am trying to do the frequency analysis on data that I get from my microphone with web audio API. I need realtime data (as much as you can get realtime with a window size of 1024 samples).

I am using createMediaStreamSource for the source node. I've used the FFT data from the Analyzer node using getByteFrequencyData method (sample size = 1024).

The data from the FFT array are completely different in chrome and firefox (In firefox the frequency spectrum is always smaller in size (smaller vector dimension) and smaller in value (lower values) as opposed to Chrome where it seems Ok compared to other FFT algorythms in Audacity for example). Even when I used Audio recorder from https://webaudiodemos.appspot.com/AudioRecorder/index.html and put the recordings in one of the audio analyzer applications (audacity on windows) I get this (image).

I would like to know why frequency spectrum in Firefox differs from frequency spectrum in chrome.

Thanks for any help.


Solution

  • This is because we (Firefox) automatically apply processing (echo cancelation, noise suppression) on the input AND use 16kHz sample rate on the input audio stream.

    This is going to change, but it's how it is right now, sorry about that.

    It will be possible to request the input sample rate and deactivate any processing in the future.