how to generate and sync a xml/json file that contains each beat informations (bpm) for audio in js

1k views Asked by At

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

1

There are 1 answers

0
Mikko Ohtamaa On BEST ANSWER

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