midijs入门

时间:2014-02-03 04:53:50

标签: javascript midi

我开始使用midijs时遇到了麻烦。初始示例不输出任何声音。如何开始在浏览器中播放单个MIDI音符?

<html>
    <head>
      <script src="./js/MIDI/AudioDetect.js" type="text/javascript"></script>
      <script src="./js/MIDI/LoadPlugin.js" type="text/javascript"></script>
      <script src="./js/MIDI/Plugin.js" type="text/javascript"></script>
      <script src="./js/MIDI/Player.js" type="text/javascript"></script>
      <script src="./js/Window/DOMLoader.XMLHttp.js" type="text/javascript"></script>
      <!-- extras -->
      <script src="./inc/Base64.js" type="text/javascript"></script>
      <script src="./inc/base64binary.js" type="text/javascript"></script>
   </head>
<body>
<script>
window.onload = function () {
    MIDI.loadPlugin({
        soundfontUrl: "./soundfont/",
        instrument: "acoustic_grand_piano",
        callback: function() {
            var delay = 0; // play one note every quarter second
            var note = 50; // the MIDI note
            var velocity = 127; // how hard the note hits
            // play the note
            MIDI.programChange(0, 1); // Load "synth_drum" (118) into channel 0
            MIDI.setVolume(0, 127);
            MIDI.noteOn(0, note, velocity, delay);
            MIDI.noteOff(0, note, delay + 0.75);
        }
    });
};
</script>

我已经设置了MIDI部分,但我不知道如何从Chrome播放音乐。

0 个答案:

没有答案