简体   繁体   English

如何生成和同步xml / json文件,该文件包含js中音频的每个节拍信息(bpm)

[英]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. 我需要为游戏等“吉他英雄”制作与音乐bpm同步的js事件

First Question : 第一个问题:

How to generate a track file from beat detection (each bpm stored like a music sheet)? 如何通过节拍检测生成跟踪文件(每个bpm像乐谱一样存储)? This file will be generated previously not necessary on the fly. 该文件以前不会即时生成。

Second Question : 第二个问题:

How to sync it with a js sound library ? 如何将其与js声音库同步?

Any idea ? 任何想法 ? Thanks in advance 提前致谢

The answer for 1 is here: 1的答案在这里:

https://github.com/miohtama/Krusovice/blob/master/src/tools/echonest.js#L107 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). 您可以使用Echo Nest API服务提取歌曲文件的所有功能,其中包括离线节拍检测(还可以检测小节等)。 The example is a Javascript example you can run in a (customized) Chrome: 该示例是一个Javascript示例,您可以在(自定义的)Chrome中运行:

https://github.com/miohtama/Krusovice/blob/master/demos/timing-tester.html 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. 2的答案是将游戏逻辑时钟与音频播放时钟联系在一起,而不是与Javascript系统时间联系在一起。 Like here: 像这儿:

https://github.com/miohtama/Krusovice/blob/master/src/show.js#L1072 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 免责声明:我是代码的作者

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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