add USE_JAZZMIDI variable to enable experimental Web MIDI API, add utf8 meta tags to demos
This commit is contained in:
parent
a7d5b8a06e
commit
072eadb4af
7 changed files with 9 additions and 4 deletions
|
@ -18,6 +18,7 @@ if (typeof (MIDI.Soundfont) === "undefined") MIDI.Soundfont = {};
|
|||
|
||||
// Turn on to get "onprogress" event. XHR will not work from file://
|
||||
var USE_XHR = false;
|
||||
var USE_JAZZMIDI = false;
|
||||
|
||||
MIDI.loadPlugin = function(conf) {
|
||||
if (typeof(conf) === "function") conf = {
|
||||
|
@ -40,7 +41,7 @@ MIDI.loadPlugin = function(conf) {
|
|||
api = conf.api;
|
||||
} else if (apis[window.location.hash.substr(1)]) {
|
||||
api = window.location.hash.substr(1);
|
||||
} else if (navigator.requestMIDIAccess) {
|
||||
} else if (USE_JAZZMIDI && navigator.requestMIDIAccess) {
|
||||
api = "webmidi";
|
||||
} else if (window.webkitAudioContext) { // Chrome
|
||||
api = "webaudio";
|
||||
|
|
|
@ -258,7 +258,7 @@ if (window.Audio) (function () {
|
|||
api: "audiotag"
|
||||
};
|
||||
var note2id = {};
|
||||
var volume = 1; // floating point
|
||||
var volume = 127; // floating point
|
||||
var channel_nid = -1; // current channel
|
||||
var channels = []; // the audio channels
|
||||
var notes = {}; // the piano keys
|
||||
|
@ -276,7 +276,7 @@ if (window.Audio) (function () {
|
|||
var time = (new Date()).getTime();
|
||||
var audio = channels[nid];
|
||||
audio.src = MIDI.Soundfont[id][note.id];
|
||||
audio.volume = volume;
|
||||
audio.volume = volume / 127;
|
||||
audio.play();
|
||||
channel_nid = nid;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue