Merge pull request #21 from bsstoner/flash

flash api isn't loading any of the mp3 samples
This commit is contained in:
Michael Deal 2013-03-20 16:47:54 -07:00
commit e9c2766858
2 changed files with 11 additions and 7 deletions

View file

@ -75,7 +75,7 @@ connect.flash = function(filetype, instruments, conf) {
src: conf.soundManagerUrl || "./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 = conf.soundManagerSwfUrl || '../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);