updates for flash and safari, tweaks here and there
This commit is contained in:
parent
214d1917b0
commit
e31044b6b8
9 changed files with 35 additions and 27 deletions
|
@ -56,7 +56,7 @@ root.clearAnimation = function() {
|
|||
|
||||
root.setAnimation = function(config) {
|
||||
var callback = (typeof(config) === "function") ? config : config.callback;
|
||||
var delay = config.delay || 100;
|
||||
var delay = config.delay || 24;
|
||||
var currentTime = 0;
|
||||
var tOurTime = 0;
|
||||
var tTheirTime = 0;
|
||||
|
@ -96,7 +96,7 @@ root.setAnimation = function(config) {
|
|||
|
||||
// helpers
|
||||
|
||||
var loadMidiFile = function() { // reads midi into javascript array of events
|
||||
root.loadMidiFile = function() { // reads midi into javascript array of events
|
||||
root.replayer = new Replayer(MidiFile(root.currentData), root.timeWarp);
|
||||
root.data = root.replayer.getData();
|
||||
root.endTime = getLength();
|
||||
|
@ -107,7 +107,7 @@ root.loadFile = function (file, callback) {
|
|||
if (file.indexOf("base64,") !== -1) {
|
||||
var data = window.atob(file.split(",")[1]);
|
||||
root.currentData = data;
|
||||
loadMidiFile();
|
||||
root.loadMidiFile();
|
||||
if (callback) callback(data);
|
||||
return;
|
||||
}
|
||||
|
@ -125,7 +125,7 @@ root.loadFile = function (file, callback) {
|
|||
}
|
||||
var data = window.atob(ff.join(""));
|
||||
root.currentData = data;
|
||||
loadMidiFile();
|
||||
root.loadMidiFile();
|
||||
if (callback) callback(data);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -280,7 +280,7 @@ if (window.Audio) (function () {
|
|||
root.connect = function (callback) {
|
||||
soundManager.flashVersion = 9;
|
||||
soundManager.useHTML5Audio = true;
|
||||
soundManager.url = '../../swf/';
|
||||
soundManager.url = '../inc/SoundManager2/swf/';
|
||||
soundManager.useHighPerformance = true;
|
||||
soundManager.wmode = 'transparent';
|
||||
soundManager.flashPollingInterval = 1;
|
||||
|
@ -292,8 +292,8 @@ if (window.Audio) (function () {
|
|||
if (typeof (loader) === "undefined") return;
|
||||
loader.message("Processing: " + this.sID);
|
||||
};
|
||||
for (var i = 10; i < 65 + 10; i++) {
|
||||
var id = noteReverse[i + 26];
|
||||
for (var i = 0; i < 88; i++) {
|
||||
var id = noteReverse[i + 21];
|
||||
notes[id] = soundManager.createSound({
|
||||
id: id,
|
||||
url: './soundfont/mp3/' + id + '.mp3',
|
||||
|
@ -311,7 +311,7 @@ if (window.Audio) (function () {
|
|||
MIDI.chordOff = root.chordOff;
|
||||
//
|
||||
var interval = window.setInterval(function () {
|
||||
if (loaded.length !== 65) return;
|
||||
if (loaded.length !== 88) return;
|
||||
window.clearInterval(interval);
|
||||
if (callback) callback();
|
||||
}, 25);
|
||||
|
|
|
@ -15,7 +15,7 @@ if (typeof (MIDI.Soundfont) === "undefined") MIDI.Soundfont = {};
|
|||
var plugins = { "#webaudio": true, "#html5": true, "#java": true, "#flash": true };
|
||||
|
||||
MIDI.loadPlugin = function(callback, instrument) {
|
||||
var type, loader;
|
||||
var type = "";
|
||||
var instrument = instrument || "";
|
||||
MIDI.audioDetect(function(types) {
|
||||
// use the most appropriate plugin if not specified
|
||||
|
@ -27,15 +27,15 @@ MIDI.loadPlugin = function(callback, instrument) {
|
|||
}
|
||||
}
|
||||
if (type === "") {
|
||||
var isSafari = navigator.userAgent.toLowerCase().indexOf("safari") !== -1;
|
||||
if (window.webkitAudioContext) { // Chrome
|
||||
type = "#webaudio";
|
||||
} else if (window.Audio && isSafari === false) { // Firefox
|
||||
} else if (window.Audio) { // Firefox
|
||||
type = "#html5";
|
||||
} else { // Safari and Internet Explorer
|
||||
} else { // Internet Explorer
|
||||
type = "#flash";
|
||||
}
|
||||
}
|
||||
if (typeof(loader) === "undefined") var loader;
|
||||
// use audio/ogg when supported
|
||||
var filetype = types["audio/ogg"] ? "ogg" : "mp3";
|
||||
// load the specified plugin
|
||||
|
@ -59,7 +59,7 @@ MIDI.loadPlugin = function(callback, instrument) {
|
|||
case "#html5":
|
||||
// works well in Firefox
|
||||
DOMLoader.sendRequest({
|
||||
url: "./soundfont/soundfont-" + filetype + ".js",
|
||||
url: "./soundfont/soundfont-" + filetype + instrument + ".js",
|
||||
callback: function (response) {
|
||||
MIDI.Soundfont = JSON.parse(response.responseText);
|
||||
if (loader) loader.message("Downloading: 100%<br>Processing...");
|
||||
|
|
|
@ -7,7 +7,6 @@ var clone = function (o) {
|
|||
};
|
||||
|
||||
function Replayer(midiFile, timeWarp, eventProcessor) {
|
||||
//console.log(midiFile)
|
||||
var trackStates = [];
|
||||
var beatsPerMinute = 120;
|
||||
var ticksPerBeat = midiFile.header.ticksPerBeat;
|
||||
|
@ -64,7 +63,7 @@ function Replayer(midiFile, timeWarp, eventProcessor) {
|
|||
var beatsToGenerate = midiEvent.ticksToEvent / ticksPerBeat;
|
||||
var secondsToGenerate = beatsToGenerate / (beatsPerMinute / 60);
|
||||
}
|
||||
var time = secondsToGenerate * 1000 * timeWarp || 0;
|
||||
var time = (secondsToGenerate * 1000 * timeWarp) || 0;
|
||||
temporal.push([ midiEvent, time]);
|
||||
midiEvent = getNextEvent();
|
||||
};
|
||||
|
@ -76,7 +75,6 @@ function Replayer(midiFile, timeWarp, eventProcessor) {
|
|||
processEvents();
|
||||
return {
|
||||
"getData": function() {
|
||||
// console.log(temporal)
|
||||
return clone(temporal);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -7,7 +7,6 @@ var clone = function (o) {
|
|||
};
|
||||
|
||||
function Replayer(midiFile, timeWarp, eventProcessor) {
|
||||
//console.log(midiFile)
|
||||
var trackStates = [];
|
||||
var beatsPerMinute = 120;
|
||||
var ticksPerBeat = midiFile.header.ticksPerBeat;
|
||||
|
@ -64,7 +63,7 @@ function Replayer(midiFile, timeWarp, eventProcessor) {
|
|||
var beatsToGenerate = midiEvent.ticksToEvent / ticksPerBeat;
|
||||
var secondsToGenerate = beatsToGenerate / (beatsPerMinute / 60);
|
||||
}
|
||||
var time = secondsToGenerate * 1000 * timeWarp || 0;
|
||||
var time = (secondsToGenerate * 1000 * timeWarp) || 0;
|
||||
temporal.push([ midiEvent, time]);
|
||||
midiEvent = getNextEvent();
|
||||
};
|
||||
|
@ -76,7 +75,6 @@ function Replayer(midiFile, timeWarp, eventProcessor) {
|
|||
processEvents();
|
||||
return {
|
||||
"getData": function() {
|
||||
// console.log(temporal)
|
||||
return clone(temporal);
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue