Includes a library to program synesthesia into your app for memory recognition or for creating trippy effects. Convert soundfonts for Guitar, Bass, Drums, ect. into code that can be read by the browser.
Find a file
Michael Deal b9757cab9b grunt
2013-01-22 16:46:32 -08:00
build grunt 2013-01-22 16:46:32 -08:00
css update to latest libraries 2012-10-09 22:59:04 -07:00
images let there be midi 2012-02-15 20:46:03 -08:00
inc move Base64 to inc directory 2013-01-13 17:03:02 -08:00
js tweaks to tracking scheduling, and amplitude 2013-01-21 10:10:44 -08:00
soundfont use XHR or SCRIPT tag to loadPlugin, XHR has benefit of OnProgress event, whereas SCRIPT has benefit of loading from file:// 2013-01-18 23:18:41 -08:00
soundfont-generator separate ruby + shell build scripts into their own directories 2013-01-22 15:54:53 -08:00
demo-Basic.html tweak readme 2013-01-22 15:37:45 -08:00
demo-MIDIPlayer.html rename demo files 2013-01-19 16:56:52 -08:00
demo-WhitneyMusicBox.html rename demo files 2013-01-19 16:56:52 -08:00
grunt.js add grunt.js, update color libraries 2012-11-21 02:11:19 -08:00
LICENSE-MIT.txt update to latest libraries 2012-10-09 22:59:04 -07:00
package.json update to latest libraries 2012-10-09 22:59:04 -07:00
README.md grunt 2013-01-22 16:46:32 -08:00

CODE EXAMPLES (from the repo)

  • ./demo-Basic.html is the most basic implementation.
  • ./demo-MIDIPlayer.html shows how to parse MIDI files, and interact with the data stream.
  • ./demo-WhitneyMusicBox.html is a audio/visual experiment by Jim Bumgardner

DEMOS


// interface to download soundfont, then execute callback;
MIDI.loadPlugin(callback);
// simple example to get started;
MIDI.loadPlugin({
    instrument: "acoustic_grand_piano", // or 1 (default)
    instruments: [ "acoustic_grand_piano", "acoustic_guitar_nylon" ], // or multiple instruments
    callback: function() { }
});
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
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.
Callback whenever a note is played;
MIDI.Player.removeListener(); // removes current listener.
MIDI.Player.addListener(function(data) { // set it to your own function!
    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!
});
Smooth animation, interpolates between onMidiEvent calls;
MIDI.Player.clearAnimation(); // clears current animation.
MIDI.Player.setAnimation(function(data) {
    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!
});
  • Color.js: Color conversions, music isnt complete without!
Color.Space(0xff0000, "HEX>RGB>HSL");
DOMLoader.script.add(src, callback);
DOMLoader.sendRequest(src, callback);

Many thanks to the authors of these libraries;

* <audio>: HTML5 specs * WebAudioAPI: W3C proposal by Google * Java package: MIDIBridge by Daniel van der Meer. Supports MIDI keyboard, and 128 General MIDI instruments. * Flash package: SoundManager2 by Scott Schiller * jasmid: Reads MIDI file byte-code, and translats into a Javascript array. * base642binary.js: Cleans up XML base64-requests for Web Audio API.