2013-01-23 01:23:40 +01:00
CODE EXAMPLES (from the repo)
2013-01-25 08:49:12 +01:00
* ./demo-Basic.html - the most basic implementation.
* ./demo-MIDIPlayer.html - how to parse MIDI files, and interact with the data stream.
* ./demo-MultipleInstruments.html - synth drum and piano playing together
* ./demo-WhitneyMusicBox.html - a audio/visual experiment by Jim Bumgardner
2013-01-23 01:23:40 +01:00
-------------
DEMOS
2013-01-23 03:44:58 +01:00
* < a href = "http://my.vexflow.com/articles/53" > VexFlow</ a >
2013-01-23 01:23:40 +01:00
* < a href = "http://qiao.github.com/euphony/" > Euphony 3D Piano</ a >
* < a href = "http://labs.uxmonk.com/simon-says/" > Simon Says</ a >
* < a href = "http://labs.uxmonk.com/brite-lite/" > Brite Lite</ a >
* < a href = "http://mudcu.be/piano/" > Color Piano</ a >
-------------
2013-01-23 01:09:06 +01:00
* < a href = "./js/MIDI.loadPlugin.js" > MIDI.loadPlugin.js</ a > : Decides which framework is best to use, and sends request.
2013-01-23 01:46:32 +01:00
2012-02-16 05:46:03 +01:00
< pre >
// interface to download soundfont, then execute callback;
2012-11-21 11:29:57 +01:00
MIDI.loadPlugin(callback);
2012-02-16 05:46:03 +01:00
// simple example to get started;
2012-11-21 11:29:57 +01:00
MIDI.loadPlugin({
2013-01-25 08:49:12 +01:00
instrument: "acoustic_grand_piano", // or the instrument code 1 (aka the default)
2013-01-23 01:23:40 +01:00
instruments: [ "acoustic_grand_piano", "acoustic_guitar_nylon" ], // or multiple instruments
callback: function() { }
2012-11-21 11:29:57 +01:00
});
2012-02-16 05:46:03 +01:00
< / pre >
2013-01-23 01:09:06 +01:00
* < a href = "./soundfont/soundfont-ogg.js" > MIDI.Soundfont.js</ a > : Customizable base64 Soundfont.
* < a href = "./js/MIDI.Plugin.js" > MIDI.Plugin.js</ a > : Ties together the following frameworks;
2013-01-23 01:25:07 +01:00
2013-01-23 01:09:06 +01:00
< pre >
2012-02-16 05:46:03 +01:00
MIDI.noteOn(channel, note, velocity, delay);
MIDI.noteOff(channel, note, delay);
MIDI.chordOn(channel, chord, velocity, delay);
MIDI.chordOff(channel, chord, delay);
MIDI.keyToNote = object; // A0 => 21
MIDI.noteToKey = object; // 21 => A0
2013-01-23 01:09:06 +01:00
< / pre >
2013-01-23 01:25:07 +01:00
2013-01-23 01:09:06 +01:00
* < a href = "./js/MIDI.Player.js" > MIDI.Player.js</ a > : Streams the MIDI to the browser.
2013-01-23 01:25:07 +01:00
2013-01-23 01:23:40 +01:00
< pre >
2012-02-16 05:46:03 +01:00
MIDI.Player.currentTime = integer; // time we are at now within the song.
MIDI.Player.endTime = integer; // time when song ends.
MIDI.Player.playing = boolean; // are we playing? yes or no.
MIDI.Player.loadFile(file, callback); // load .MIDI from base64 or binary XML request.
MIDI.Player.start(); // start the MIDI track (you can put this in the loadFile callback)
MIDI.Player.resume(); // resume the MIDI track from pause.
MIDI.Player.pause(); // pause the MIDI track.
MIDI.Player.stop(); // stops all audio being played, and resets currentTime to 0.
2013-01-23 05:24:43 +01:00
// < b > Callback whenever a note is played;< / b >
2012-02-16 05:46:03 +01:00
MIDI.Player.removeListener(); // removes current listener.
MIDI.Player.addListener(function(data) { // set it to your own function!
2013-01-23 01:23:40 +01:00
var now = data.now; // where we are now
var end = data.end; // time when song ends
var channel = data.channel; // channel note is playing on
var message = data.message; // 128 is noteOff, 144 is noteOn
var note = data.note; // the note
var velocity = data.velocity; // the velocity of the note
// then do whatever you want with the information!
2012-02-16 05:46:03 +01:00
});
2013-01-23 05:24:43 +01:00
// < b > Smooth animation, interpolates between onMidiEvent calls;< / b >
2012-02-16 05:46:03 +01:00
MIDI.Player.clearAnimation(); // clears current animation.
MIDI.Player.setAnimation(function(data) {
2013-01-23 01:23:40 +01:00
var now = data.now; // where we are now
var end = data.end; // time when song ends
var events = data.events; // all the notes currently being processed
// then do what you want with the information!
2013-01-23 01:09:06 +01:00
});< / pre >
* < a href = "./js/Color.js" > Color.js</ a > : Color conversions, music isn’ t complete without!
< pre > Color.Space(0xff0000, "HEX>RGB>HSL");< / pre >
* < a href = "./js/DOMLoader.script.js" > DOMLoader.script.js</ a > : Loads scripts in synchronously, or asynchronously.
< pre > DOMLoader.script.add(src, callback);< / pre >
* < a href = "./js/DOMLoader.XMLHttp.js" > DOMLoader.XMLHttp.js</ a > : Cross-browser XMLHttpd request.
< pre > DOMLoader.sendRequest(src, callback);< / pre >
* < a href = "./js/MusicTheory.Synesthesia.js" > MusicTheory.Synesthesia.js</ a > : Note-to-color mappings (from Isaac Newton onwards).
2012-02-16 05:46:03 +01:00
< h3 > Many thanks to the authors of these libraries;< / h3 >
2013-01-25 08:57:13 +01:00
* < a href = "https://dvcs.w3.org/hg/audio/raw-file/tip/midi/specification.html" > Web MIDI API</ a > : W3C proposal by Jussi Kalliokoski & Chris Wilson
2013-01-25 09:11:41 +01:00
* < a href = "https://dvcs.w3.org/hg/audio/raw-file/tip/webaudio/specification.html" > Web Audio API</ a > : W3C proposal by Chris Rogers
2013-01-23 01:09:06 +01:00
* < a href = "http://dev.w3.org/html5/spec/Overview.html" > < audio> </ a > : HTML5 specs
* Flash package: < a href = "http://www.schillmania.com/projects/soundmanager2/" > SoundManager2</ a > by < a href = "http://schillmania.com" > Scott Schiller</ a >
* < a href = "https://github.com/gasman/jasmid" > jasmid</ a > : Reads MIDI file byte-code, and translats into a Javascript array.
* < a href = "http://blog.danguer.com/2011/10/24/base64-binary-decoding-in-javascript/" > base642binary.js</ a > : Cleans up XML base64-requests for Web Audio API.