split multi-instrument and basic demos
This commit is contained in:
parent
671cb8b61a
commit
326fc9952a
|
@ -1,8 +1,9 @@
|
|||
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
|
||||
* ./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
|
||||
|
||||
-------------
|
||||
|
||||
|
@ -23,7 +24,7 @@ DEMOS
|
|||
MIDI.loadPlugin(callback);
|
||||
// simple example to get started;
|
||||
MIDI.loadPlugin({
|
||||
instrument: "acoustic_grand_piano", // or 1 (default)
|
||||
instrument: "acoustic_grand_piano", // or the instrument code 1 (aka the default)
|
||||
instruments: [ "acoustic_grand_piano", "acoustic_guitar_nylon" ], // or multiple instruments
|
||||
callback: function() { }
|
||||
});
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
<script src="./js/Window/DOMLoader.script.js" type="text/javascript"></script>
|
||||
<!-- base64 packages -->
|
||||
<script src="./inc/Polyfill/Base64.js" type="text/javascript"></script>
|
||||
<script src="./inc/WebMIDIAPI.js" type="text/javascript"></script>
|
||||
<script src="./inc/base64binary.js" type="text/javascript"></script>
|
||||
</head>
|
||||
<body>
|
||||
|
@ -17,19 +18,13 @@
|
|||
window.onload = function () {
|
||||
MIDI.loadPlugin({
|
||||
soundfontUrl: "./soundfont/",
|
||||
instruments: [ "acoustic_grand_piano", "synth_drum" ], // or multiple instruments
|
||||
instrument: "acoustic_grand_piano",
|
||||
callback: function() {
|
||||
MIDI.programChange(0, 0);
|
||||
MIDI.programChange(1, 118);
|
||||
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 delay = 0; // play one note every quarter second
|
||||
var note = 50; // 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);
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
|
43
demo-MultipleInstruments.html
Normal file
43
demo-MultipleInstruments.html
Normal file
|
@ -0,0 +1,43 @@
|
|||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns = "http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<script src="./js/MIDI/audioDetect.js" type="text/javascript"></script>
|
||||
<script src="./js/MIDI/loadPlugin.js" type="text/javascript"></script>
|
||||
<script src="./js/MIDI/Plugin.js" type="text/javascript"></script>
|
||||
<script src="./js/MIDI/Player.js" type="text/javascript"></script>
|
||||
<script src="./js/Window/DOMLoader.XMLHttp.js" type="text/javascript"></script>
|
||||
<script src="./js/Window/DOMLoader.script.js" type="text/javascript"></script>
|
||||
<!-- base64 packages -->
|
||||
<script src="./inc/Polyfill/Base64.js" type="text/javascript"></script>
|
||||
<script src="./inc/base64binary.js" type="text/javascript"></script>
|
||||
</head>
|
||||
<body>
|
||||
<script type="text/javascript">
|
||||
|
||||
// This iterates through all the notes in these two soundfonts.
|
||||
// The synth_drum does not have as high or low of range of notes,
|
||||
// so you wont hear it for a few seconds.
|
||||
|
||||
window.onload = function () {
|
||||
MIDI.loadPlugin({
|
||||
soundfontUrl: "./soundfont/",
|
||||
instruments: [ "acoustic_grand_piano", "synth_drum" ],
|
||||
callback: function() {
|
||||
MIDI.programChange(0, 0);
|
||||
MIDI.programChange(1, 118);
|
||||
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);
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in a new issue