add demos and more code examples to README
This commit is contained in:
parent
edbb8113b8
commit
53c40f3cf3
73
README.md
73
README.md
|
@ -1,12 +1,55 @@
|
||||||
|
CODE EXAMPLES (from the repo)
|
||||||
|
|
||||||
|
* ./demo-Basic.html is the most basic implementation as seen here:
|
||||||
|
<pre>
|
||||||
|
MIDI.loadPlugin({
|
||||||
|
soundfontUrl: "./soundfont/", // path to soundfont directory
|
||||||
|
instruments: [ "acoustic_grand_piano", "synth_drum" ], // multiple instruments
|
||||||
|
callback: function() {
|
||||||
|
MIDI.programChange(0, 0); // change channel 0 to instrument 0 (acoustic_grand_piano)
|
||||||
|
MIDI.programChange(1, 118); // change channel 1 to instrument 118 (synth_drum)
|
||||||
|
for (var n = 0; n < 100; n ++) {
|
||||||
|
var delay = n / 4; // play one note every quarter second
|
||||||
|
var note = MIDI.pianoKeyOffset + n; // the MIDI note
|
||||||
|
var velocity = 127; // how hard the note hits
|
||||||
|
// play the note
|
||||||
|
MIDI.noteOn(0, note, velocity, delay);
|
||||||
|
// play the some note 3-steps up
|
||||||
|
MIDI.noteOn(1, note + 3, velocity, delay);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
</pre>
|
||||||
|
* ./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
|
||||||
|
|
||||||
|
* <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>
|
||||||
|
|
||||||
|
-------------
|
||||||
|
|
||||||
|
SOUNDFONT GENERATORS (*not* required to get started!)
|
||||||
|
|
||||||
|
* Ruby
|
||||||
|
* Shell
|
||||||
|
|
||||||
|
-------------
|
||||||
|
|
||||||
* <a href="./js/MIDI.loadPlugin.js">MIDI.loadPlugin.js</a>: Decides which framework is best to use, and sends request.
|
* <a href="./js/MIDI.loadPlugin.js">MIDI.loadPlugin.js</a>: Decides which framework is best to use, and sends request.
|
||||||
<pre>
|
<pre>
|
||||||
// interface to download soundfont, then execute callback;
|
// interface to download soundfont, then execute callback;
|
||||||
MIDI.loadPlugin(callback);
|
MIDI.loadPlugin(callback);
|
||||||
// simple example to get started;
|
// simple example to get started;
|
||||||
MIDI.loadPlugin({
|
MIDI.loadPlugin({
|
||||||
instrument: "acoustic_grand_piano", // or 1 (default)
|
instrument: "acoustic_grand_piano", // or 1 (default)
|
||||||
instruments: [ "acoustic_grand_piano", "acoustic_guitar_nylon" ], // or multiple instruments
|
instruments: [ "acoustic_grand_piano", "acoustic_guitar_nylon" ], // or multiple instruments
|
||||||
callback: function() { }
|
callback: function() { }
|
||||||
});
|
});
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
|
@ -21,7 +64,7 @@ MIDI.keyToNote = object; // A0 => 21
|
||||||
MIDI.noteToKey = object; // 21 => A0
|
MIDI.noteToKey = object; // 21 => A0
|
||||||
</pre>
|
</pre>
|
||||||
* <a href="./js/MIDI.Player.js">MIDI.Player.js</a>: Streams the MIDI to the browser.
|
* <a href="./js/MIDI.Player.js">MIDI.Player.js</a>: Streams the MIDI to the browser.
|
||||||
<pre>
|
<pre>
|
||||||
MIDI.Player.currentTime = integer; // time we are at now within the song.
|
MIDI.Player.currentTime = integer; // time we are at now within the song.
|
||||||
MIDI.Player.endTime = integer; // time when song ends.
|
MIDI.Player.endTime = integer; // time when song ends.
|
||||||
MIDI.Player.playing = boolean; // are we playing? yes or no.
|
MIDI.Player.playing = boolean; // are we playing? yes or no.
|
||||||
|
@ -33,21 +76,21 @@ MIDI.Player.stop(); // stops all audio being played, and resets currentTime to 0
|
||||||
<b>Callback whenever a note is played;</b>
|
<b>Callback whenever a note is played;</b>
|
||||||
MIDI.Player.removeListener(); // removes current listener.
|
MIDI.Player.removeListener(); // removes current listener.
|
||||||
MIDI.Player.addListener(function(data) { // set it to your own function!
|
MIDI.Player.addListener(function(data) { // set it to your own function!
|
||||||
var now = data.now; // where we are now
|
var now = data.now; // where we are now
|
||||||
var end = data.end; // time when song ends
|
var end = data.end; // time when song ends
|
||||||
var channel = data.channel; // channel note is playing on
|
var channel = data.channel; // channel note is playing on
|
||||||
var message = data.message; // 128 is noteOff, 144 is noteOn
|
var message = data.message; // 128 is noteOff, 144 is noteOn
|
||||||
var note = data.note; // the note
|
var note = data.note; // the note
|
||||||
var velocity = data.velocity; // the velocity of the note
|
var velocity = data.velocity; // the velocity of the note
|
||||||
// then do whatever you want with the information!
|
// then do whatever you want with the information!
|
||||||
});
|
});
|
||||||
<b>Smooth animation, interpolates between onMidiEvent calls;</b>
|
<b>Smooth animation, interpolates between onMidiEvent calls;</b>
|
||||||
MIDI.Player.clearAnimation(); // clears current animation.
|
MIDI.Player.clearAnimation(); // clears current animation.
|
||||||
MIDI.Player.setAnimation(function(data) {
|
MIDI.Player.setAnimation(function(data) {
|
||||||
var now = data.now; // where we are now
|
var now = data.now; // where we are now
|
||||||
var end = data.end; // time when song ends
|
var end = data.end; // time when song ends
|
||||||
var events = data.events; // all the notes currently being processed
|
var events = data.events; // all the notes currently being processed
|
||||||
// then do what you want with the information!
|
// then do what you want with the information!
|
||||||
});</pre>
|
});</pre>
|
||||||
|
|
||||||
* <a href="./js/Color.js">Color.js</a>: Color conversions, music isn’t complete without!
|
* <a href="./js/Color.js">Color.js</a>: Color conversions, music isn’t complete without!
|
||||||
|
|
Loading…
Reference in a new issue