我正在尝试在http://mudcu.be/piano/上创建彩色钢琴网站的变体,并且真的很难找到一个很好的工作示例来说明如何解析 MIDI 文件、绘制图形元素和播放 MIDI 音符。
有谁知道彩色钢琴网站是如何创建的?
我首先只是想播放一个特定的 MIDI 文件——没有运气。
下面的代码没有做任何事情,也没有显示错误。
<!DOCTYPE html>
<html xmlns = "http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<!-- polyfill -->
<script src="static/Base64.js" type="text/javascript"></script>
<script src="static/Base64binary.js" type="text/javascript"></script>
<script src="static/WebAudioAPI.js" type="text/javascript"></script>
<!-- midi.js package -->
<script src="static/audioDetect.js" type="text/javascript"></script>
<script src="static/gm.js" type="text/javascript"></script>
<script src="static/loader.js" type="text/javascript"></script>
<script src="static/player.js" type="text/javascript"></script>
<script src="static/event.js" type="text/javascript"></script>
<script src="static/plugin.audiotag.js" type="text/javascript"></script>
<script src="static/plugin.webaudio.js" type="text/javascript"></script>
<script src="static/plugin.webmidi.js" type="text/javascript"></script>
<!-- jasmid just in case-->
<script src="static/stream.js"></script>
<script src="static/midifile.js"></script>
<script src="static/replayer.js"></script>
<!-- utils -->
<script src="static/dom_request_xhr.js" type="text/javascript"></script>
<script src="static/dom_request_script.js" type="text/javascript"></script>
</head>
<body>
<script type="text/javascript">
window.onload = function () {
MIDI.loadPlugin({
soundfontUrl: "static/",
instrument: "acoustic_grand_piano",
callback: function() {
MIDI.Player.loadFile("static/mario.mid", MIDI.Player.start);
}
});
}
</script>
</body>
</html>