Search code examples
javascriptapiaudioweb-audio-apisample-rate

web audio api changes sample rate when a working draft is released?


I trying to develop a simple guitar tuner based on harmonic detection using the web audio API and js. https://github.com/lontafara/El-audio-en-la-web

I have always worked with a sample rate of 48000 Hz. Allowing me some resolution in the frequency domain. But whenever a working draft of the Web Audio API is published, this value automatically changes to 44100 for a while.

I realized for the first time in the version of 13 December, and now on April 25.

The .samplerate attribute is a readonly constant and i cant change it.

my question is, Can I continue working with a sample rate of 48000, or i've got to change to 44100? Is this change temporary, because last week the default sampling rate was still 48000?

Thank you!!!


Solution

  • The Web Audio API runs at whatever the default output device's sampling rate is. That is frequently 44.1kHz, but it is system-dependent. You shouldn't hardcode a sampling rate into your code.