Control the music

Hi community, its me again)

I have a question about what kind of things i can do in Corona,
Is there a way to mathematically break down a audio track in terms of BPM with script in order to time the pressing of buttons on a beat (with of course a few nanoseconds added on to each end). So if we were to break down a drum track to 16 beats per bar, would there be a way to program it so that the button press would come up on beats 1, 3, 5, and 9 (example)?
Any help is appreciated) [import]uid: 16142 topic_id: 20443 reply_id: 320443[/import]

This is what I would do if you want to create a beat tapping game. Let’s say you want to play a beat on 1,3,5,9. Assume each beat is 100ms apart.

[lua]local startTime
local beats = {}
local index = 1

local function buttonHandler(event)
local phase = event.phase
local timeofTouch = event.time
local verifyTime
local offset

if phase == “began” then
verifyTime = startTime + 100 * beats[index]
index = index + 1

– This is how much time the touch is off from the beat
offset = timeofTouch - verifyTime
end
end

startTime = event.time – or system.getTimer()

timer.performWithDelay(100,playBeat)
timer.performWithDelay(300,playBeat)
timer.performWithDelay(500,playBeat)
timer.performWithDelay(900,playBeat)

beats[1] = 1
beats[2] = 3
beats[3] = 5
beats[4] = 9

buton:addEventListener(“touch”, buttonHandler)[/lua]

But if you’re asking about directly processing the audio streams, I’m not too sure how to do that. This might be related somehow: http://blog.anscamobile.com/2011/07/the-secretundocumented-audio-apis-in-corona-sdk/ [import]uid: 108204 topic_id: 20443 reply_id: 80151[/import]

thanks for answer

Anyone have any idea if there’s a way to port this tut to Corona?
http://illogictree.com/blog/2010/05/how-to-code-a-rhythm-game/ [import]uid: 16142 topic_id: 20443 reply_id: 80232[/import]