Question

I need to produce js events synced with music bpm for a "guitar hero" like game.

First Question :

How to generate a track file from beat detection (each bpm stored like a music sheet)? This file will be generated previously not necessary on the fly.

Second Question :

How to sync it with a js sound library ?

Any idea ? Thanks in advance

Was it helpful?

Solution

The answer for 1 is here:

https://github.com/miohtama/Krusovice/blob/master/src/tools/echonest.js#L107

You can use Echo Nest API service to extract all kind of features of a song file, one including offline beat detection (also detects bars, and such). The example is a Javascript example you can run in a (customized) Chrome:

https://github.com/miohtama/Krusovice/blob/master/demos/timing-tester.html

The answer for 2 is that you tie your game logic clock to audio playback clock, not Javascript system time. Like here:

https://github.com/miohtama/Krusovice/blob/master/src/show.js#L1072

You listen for audio on time update events and then between the events interpolate the passed time using system clock.

Disclaimer: I am the author of the code

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top