From 326fc9952a31e068b85915932ba9144b8ee81994 Mon Sep 17 00:00:00 2001 From: Michael Deal Date: Thu, 24 Jan 2013 23:49:12 -0800 Subject: [PATCH] split multi-instrument and basic demos --- README.md | 9 ++++---- demo-Basic.html | 19 ++++++---------- demo-MultipleInstruments.html | 43 +++++++++++++++++++++++++++++++++++ 3 files changed, 55 insertions(+), 16 deletions(-) create mode 100644 demo-MultipleInstruments.html diff --git a/README.md b/README.md index b31633b..e457b73 100644 --- a/README.md +++ b/README.md @@ -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() { } }); diff --git a/demo-Basic.html b/demo-Basic.html index 60478a2..4a06593 100644 --- a/demo-Basic.html +++ b/demo-Basic.html @@ -9,6 +9,7 @@ + @@ -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 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); - } + 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); } }); }; diff --git a/demo-MultipleInstruments.html b/demo-MultipleInstruments.html new file mode 100644 index 0000000..3bfb3da --- /dev/null +++ b/demo-MultipleInstruments.html @@ -0,0 +1,43 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file