【发布时间】:2015-08-10 19:33:44
【问题描述】:
我熟悉 C++ 和 MIDI 协议,但我是 javascript 的初学者。 我已经从下面的 git hub 成功运行了示例 Basic.html https://github.com/mudcube/MIDI.js/blob/master/examples/Basic.html:
<body>
<script type="text/javascript">
window.onload = function () {
MIDI.loadPlugin({
soundfontUrl: "./soundfont/",
instrument: "acoustic_grand_piano",
onprogress: function(state, progress) {
console.log(state, progress);
},
onsuccess: 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.setVolume(0, 127);
MIDI.noteOn(0, note, velocity, delay);
MIDI.noteOff(0, note, delay + 0.75);
}
});
};
</script>
</body>
我想在窗口加载时加载插件。然后我想 让我自己的 javascript 函数将指定的音符值发送到 MIDI.noteOn() 和 MIDI.noteOff()。我不好意思问这么简单的问题,但我的尝试无济于事。感谢您的任何建议。
【问题讨论】:
标签: javascript midi midi.js