3
我使用這個MIDI.js庫:https://github.com/mudcube/MIDI.js如何轉置MIDI文件?
要加載的插件和播放MIDI文件,我這樣做:
window.onload = function() {
MIDI.loadPlugin({
soundfontUrl: "./soundfont/",
instruments: [ "acoustic_grand_piano" ],
callback: function() {
MIDI.programChange(0, 0);
_player = MIDI.Player;
}
});
};
function playSong(){
_player.timeWarp = 1; // speed the song is played back
_player.loadFile(song[songid], _player.start);
_player.addListener(function(data) {
var now = data.now; // where we are now
var end = data.end; // time when song ends
var channel = data.channel; // channel note is playing on
var message = data.message; // 128 is noteOff, 144 is noteOn
var note = data.note; // the note
var velocity = data.velocity; // the velocity of the note
});
}
var songid = 0;
var song = ['data:audio/mid;base64,TVRoZAAAAA...
我的問題是,無論如何轉置這個midi文件之前玩嗎?基本上我想解析一個MIDI文件(無論是.mid文件還是base64格式),將所有音符改爲+1,然後發送給播放器。任何方式在JavaScript中做到這一點?