4 ms·
It's just a random sound sample I found on freesound. The demo works on Firefox 78, Ubuntu. However you'd have to set correct sample rate with ?sr=44.1 to matc
by gbh444g 6y ago
It's just a random sound sample I found on freesound.
The demo works on Firefox 78, Ubuntu. However you'd have to set correct sample rate with ?sr=44.1 to match the mp3's sample rate: Firefox won't do resampling.
- TheRealPomax 6y agoFun fact, I ran into the esampling problem myself back in April when I posted https://github.com/WebAudio/web-audio-api/issues/30 https://github.com/WebAudio/web-audio-api/issues/30, V2 of the spec will allow this natively, but it also not seemingly making any headway towards initial release so who knows when it'll land... What you can do though is look at the first few bytes of an .mp3 file (since it's a file drop/file load) to just directly read the sample rate from the MP3 block header[1], where you directly check the value encoded by [data[19], data[20]]: if it's [0,0] that means it's 44100, [0,1] means it's 48000, [1,0] means it's 32000 and that's it. There are no other sample rates allowed for MP3. [1] http://mpgedit.org/mpgedit/mpeg_format/MP3Format.html http://mpgedit.org/mpgedit/mpeg_format/MP3Format.html for the full block format)
- gbh444g 6y agoThanks for the note! I've been wanting to auto-detect the sample rate.