Closed mfbx9da4 closed 7 years ago
Hi @mfbx9da4, thanks for reporting that issue. I just had a quick look at the source code and it might be possible that the algorithm can't detect any beats at all. That special case seems to be unhandled so far.
Are you able to upload the file you are using?
Yes sure, here are three examples with no peaks
Why would that be it can't detect any beats?
Also could you make the source file non-minified so I can see how it works better?
Many thanks for the example files. I updated the code to throw a meaningful error. The Tombo_piano.mp3 does indeed not contain any detectable beats. At least when using the algorithm used in this package, which is a relatively trivial one. You can find a link to an article describing the algorithm in the README.
This package is just a convenient version of the web-audio-beat-detector-broker and web-audio-beat-detector-worker. It can be used without thinking about WebWorkers.
Tombo_piano.mp3 is understandable but it's disappointing that no peaks could be found for Chambinho_do_Acordeon_e_Dominguinhos-h_z1x273cN8.mp3
I'm sorry to hear that it doesn't work for you. The algorithm works best for electronic/hip-hop/pop music which contains a prominent and steady timed baseline. Maybe you get better results if you apply some preprocessing before using this package. I'm thinking of some dynamic processing which emphasizes the onsets. But I haven't tested that.
Please feel free to tweak the algorithm for analyze() or guess(). They could surely be better.
The built-in preprocessing happens here: https://github.com/chrisguttandin/web-audio-beat-detector-broker/blob/master/src/helpers/render.ts
Ok thanks for your help, I'll look into it if I get a chance and maybe try and port some stuff from aubio
Ok, I'm closing the issue because it was originally about the error message which is much more descriptive now.
audio/Tombo piano.mp3
(but tried with multiple),responseType = "arraybuffer"
request.onload
=>context.decodeAudioData
=>buffer
source.buffer = buffer; source.start()
await guess(buffer)
produces