Pass instruments into flash.connect(), so that it can load all the sample .mp3 files

master
Brian Stoner 2013-03-12 15:54:04 -04:00
parent a5edc8ae9a
commit 277a7e04aa
2 changed files with 11 additions and 7 deletions

View File

@ -75,7 +75,7 @@ connect.flash = function(filetype, instruments, conf) {
src: "./inc/SoundManager2/script/soundmanager2.js",
verify: "SoundManager",
callback: function () {
MIDI.Flash.connect(conf);
MIDI.Flash.connect(instruments, conf);
}
});
};

View File

@ -424,7 +424,7 @@ if (window.Audio) (function () {
};
root.connect = function (conf) {
root.connect = function (instruments, conf) {
soundManager.flashVersion = 9;
soundManager.useHTML5Audio = true;
soundManager.url = '../inc/SoundManager2/swf/';
@ -444,15 +444,19 @@ if (window.Audio) (function () {
onload: onload
});
};
for (var instrument in MIDI.Soundfont) {
var loaded = [];
var loaded = [];
var samplesPerInstrument = 88;
var samplesToLoad = instruments.length * samplesPerInstrument;
for (var i = 0; i < instruments.length; i++) {
var instrument = instruments[i];
var onload = function () {
loaded.push(this.sID);
if (typeof (MIDI.loader) === "undefined") return;
MIDI.loader.update(null, "Processing: " + this.sID);
};
for (var i = 0; i < 88; i++) {
var id = noteReverse[i + 21];
for (var j = 0; j < samplesPerInstrument; j++) {
var id = noteReverse[j + 21];
createBuffer(instrument, id, onload);
}
}
@ -460,7 +464,7 @@ if (window.Audio) (function () {
setPlugin(root);
//
var interval = window.setInterval(function () {
if (loaded.length !== 88) return;
if (loaded.length < samplesToLoad) return;
window.clearInterval(interval);
if (conf.callback) conf.callback();
}, 25);