monstercat / bpm.js

Pure js bpm detection on raw audio streams
53 stars 11 forks source link

web audio compatibility #1

Open tmaximini opened 9 years ago

tmaximini commented 9 years ago

Hi, I would be interested if this would work somehow with the web audio API? It would be nice to be able to detect bpm from a track playing in an html5 audio element in real time instead from an mp3 file. https://developer.mozilla.org/en-US/docs/Web/API/AudioContext.createMediaElementSource

jb55 commented 9 years ago

That would be really cool! All that would be needed is a library that creates a stream from the web audio API in the proper format. Then you could pipe it right into the stream interface of this library.

davidguttman commented 9 years ago

This looks to be close to the correct format: https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getFloatTimeDomainData . Would have to convert it to a buffer before piping it to bpm.js though (would be doing extra work though, bpm.js is converting back to float).

The only thing I'm not certain of is that the AnalyserNode wants an fftSize set, and I don't know what that should be / if there are timing / window issues with this approach.

josiahbryan commented 6 years ago

Did anyone get this to work from AudioContext.createMediaElementSource ...with bpm.js?

jb55 commented 6 years ago

Did anyone get this to work from AudioContext.createMediaElementSource ...with bpm.js?

I don't think anyone has done this yet...