From 072eadb4afb096e46ecf3a6d83fc721b92dd7413 Mon Sep 17 00:00:00 2001 From: Michael Deal Date: Mon, 28 Jan 2013 12:27:53 -0800 Subject: [PATCH] add USE_JAZZMIDI variable to enable experimental Web MIDI API, add utf8 meta tags to demos --- css/MIDIPlayer.css | 1 + demo-Basic.html | 1 + demo-MIDIPlayer.html | 2 +- demo-MultipleInstruments.html | 1 + demo-WhitneyMusicBox.html | 1 + js/MIDI/LoadPlugin.js | 3 ++- js/MIDI/Plugin.js | 4 ++-- 7 files changed, 9 insertions(+), 4 deletions(-) diff --git a/css/MIDIPlayer.css b/css/MIDIPlayer.css index 4c4912e..81fd77d 100644 --- a/css/MIDIPlayer.css +++ b/css/MIDIPlayer.css @@ -159,6 +159,7 @@ h1 { -webkit-transition-property: background, color; -webkit-transition-duration: .25s; padding: 1px 0 1px 5px; font-family: arial; font-size: 9px; line-height: 9px; color: #aaa; width: 30px; height: 9px; + background: #000; background-image: -webkit-gradient(linear,left top,left bottom,from(rgba(66,66,66,0.75)),to(rgba(0,0,0,1))); border-bottom: 1px solid rgba(5,5,5,0.7); } \ No newline at end of file diff --git a/demo-Basic.html b/demo-Basic.html index 9a36a79..fb21ba3 100644 --- a/demo-Basic.html +++ b/demo-Basic.html @@ -1,6 +1,7 @@ + diff --git a/demo-MIDIPlayer.html b/demo-MIDIPlayer.html index ce3e76d..a733dda 100644 --- a/demo-MIDIPlayer.html +++ b/demo-MIDIPlayer.html @@ -1,7 +1,7 @@ - + MIDI.js - Sequencing in Javascript. diff --git a/demo-MultipleInstruments.html b/demo-MultipleInstruments.html index 2d25885..87746e3 100644 --- a/demo-MultipleInstruments.html +++ b/demo-MultipleInstruments.html @@ -1,6 +1,7 @@ + diff --git a/demo-WhitneyMusicBox.html b/demo-WhitneyMusicBox.html index 134bed1..2765cd0 100644 --- a/demo-WhitneyMusicBox.html +++ b/demo-WhitneyMusicBox.html @@ -2,6 +2,7 @@ Whitney Music Box in HTML5 + diff --git a/js/MIDI/LoadPlugin.js b/js/MIDI/LoadPlugin.js index 6a928c5..3e1bff2 100644 --- a/js/MIDI/LoadPlugin.js +++ b/js/MIDI/LoadPlugin.js @@ -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"; diff --git a/js/MIDI/Plugin.js b/js/MIDI/Plugin.js index 2440ff9..6bf625e 100644 --- a/js/MIDI/Plugin.js +++ b/js/MIDI/Plugin.js @@ -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; };