简体   繁体   中英

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

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM