Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Live input possible? #185

Open
hputzek opened this issue Sep 9, 2018 · 5 comments
Open

Live input possible? #185

hputzek opened this issue Sep 9, 2018 · 5 comments

Comments

@hputzek
Copy link

hputzek commented Sep 9, 2018

Hi Chris

Sorry to bother you

Thanks for offering a tool for beat detection!
I would love to use it for a project of mine, but I need it to work with live audio input.
I have never done audio stuff using the web audio api.

If you find time, could you maybe give me a direction on how to use web-audio-beat-detector together with https://developer.mozilla.org/en-US/docs/Web/API/AudioContext/createMediaStreamSource or if that is even possible?

Thanks a lot,

Hendrik

@chrisguttandin
Copy link
Owner

Hi Hendrik,

sorry for the late reply. I was busy doing other things over the weekend.

The short answer to your question is: It is sadly not possible to use live input right now because this module is designed to work with AudioBuffers which are typically obtained by calling decodeAudioData().

The longer but also more optimistic answer is: I do definitely think it's doable and I would love to add this feature. However I do currently need to prioritize paid client projects and my todo list for open source projects is already pretty long. It can take some time until I finally get the time to do it, or somebody else steps up to help.

If the project you mentioned is backed by a budget and there is some money left to implement this feature, that would be awesome and allow me to prioritize working on it.

@hputzek
Copy link
Author

hputzek commented Sep 12, 2018

Hi Chris

Thanks for your extensive answer!
This really helped me because now I know that it is not directly possible to use live input.

I think I'll go with https://github.com/cjcliffe/beatdetektor which can be fed with webkitAudioContext()
as seen in https://github.com/simianarmy/bpmcounter/blob/master/js/main.js

I'll be happy to try out your implementation in web-audio-beat-detector anyway, if you'll find time at some point :-)

Thanks for your work, greetings

Hendrik

@chrisguttandin
Copy link
Owner

Hi Hendrik,

I was of course curious and couldn't resist having a look at the links. I wonder if the beatdetektor by cjcliffe can be used as shown in the example you referenced. An AnalyserNode is known for its unreliability. It doesn't really guarantee to return predictable data at a given time. It just returns whatever it is currently processing, which could be the current or mabye the next render quantum. But it is very convenient here as it is the only AudioNode which returns frequency data.

Can you please let me know if that technique produces reliable results? Many thanks in advance.

@hputzek
Copy link
Author

hputzek commented Sep 15, 2018

Hey!
Yeah, you're probably right about the reliability.
The bpm detection seems to work quite good, but the beat counter itself is not in sync with the beat unfortunately.
I want to control lighting fixtures with the signal, so I need a proper sync to the Bassdrum ;-)

Maybe it's possible to optimize the parameters, but I think you're right about the AnalyserNode beeing the problem here :-(

I didn't imagine it's so hard to find a ready-to-use library for beatdetection.... I will implement beatdetektor for now but I'll swap it out for a better solution as soon as I find one.
Is there actually another api that can be used for live stream input beside of AudoAnalyzer node?

If you want to quickly see/try out, my findings, you can use this link (I just zipped what I tried out)
https://www.dropbox.com/s/0lmgj6xmjblx8i9/bpmcounter.zip?dl=0
It works directly after npm install and includes visualization of the beat counter.

@Dizotoff
Copy link

Dizotoff commented Jan 6, 2020

Any updates on this or ideas how to implement a live input?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants