[resolved] Implementing a beat detection algorithm
Posted: Sat Jun 08, 2013 11:38 am
Hey all,
I want to put beat detection into my game. It doesn't have to be super accurate, nothing fancy really, so I have settled for the simple sound energy algorithm, as outlined here.
That's all really cool, but to be honest I have no idea how to implement that in LÖVE. The maths behind it are doable for me, so I just need to know how to handle the sample history buffer, and the "do this every 1024 samples" thing. I know I can pass my audio file into love.sound.newSoundData, but I don't know how to proceed from there. Should I just store all samples beforehand? In my love.update, how would I know what sample position to use for the algorithm? How would I handle a looping background song?
As the end result, I want to be able to make the background of a screen flash whenever it detects a beat in the music that's playing.
If I could get code examples that'd be great, but I can make do with some pointers on how to do this as well. Thanks!
~ Fang
I want to put beat detection into my game. It doesn't have to be super accurate, nothing fancy really, so I have settled for the simple sound energy algorithm, as outlined here.
That's all really cool, but to be honest I have no idea how to implement that in LÖVE. The maths behind it are doable for me, so I just need to know how to handle the sample history buffer, and the "do this every 1024 samples" thing. I know I can pass my audio file into love.sound.newSoundData, but I don't know how to proceed from there. Should I just store all samples beforehand? In my love.update, how would I know what sample position to use for the algorithm? How would I handle a looping background song?
As the end result, I want to be able to make the background of a screen flash whenever it detects a beat in the music that's playing.
If I could get code examples that'd be great, but I can make do with some pointers on how to do this as well. Thanks!
~ Fang