add drums/guitar demos

This commit is contained in:
Michael Deal 2012-11-21 01:29:05 -08:00
parent ccb647f2a1
commit a50ca64600
95 changed files with 231 additions and 40 deletions

View file

@ -15,17 +15,20 @@
<script type="text/javascript"> <script type="text/javascript">
window.onload = function () { window.onload = function () {
MIDI.loadPlugin(function() { MIDI.loadPlugin({
for (var n = 0; n < 100; n ++) { instruments: [ "acoustic_grand_piano", "acoustic_guitar_nylon" ], // or multiple instruments
var delay = n / 4; // play one note every quarter second callback: function() {
var note = MIDI.pianoKeyOffset + n; // the MIDI note for (var n = 0; n < 100; n ++) {
var velocity = 127; // how hard the note hits var delay = n / 4; // play one note every quarter second
// play the note var note = MIDI.pianoKeyOffset + n; // the MIDI note
MIDI.noteOn(0, note, velocity, delay); var velocity = 127; // how hard the note hits
// play the some note 3-steps up // play the note
MIDI.noteOn(0, note + 3, velocity, delay); MIDI.noteOn(0, note, velocity, delay);
// play the some note 3-steps up
MIDI.noteOn(0, note + 3, velocity, delay);
}
} }
}); });
}; };
</script> </script>

View file

@ -58,11 +58,14 @@
<li class="indent"> <li class="indent">
<pre> <pre>
// interface to download soundfont, then execute callback; // interface to download soundfont, then execute callback;
MIDI.loadPlugin(callback, soundfont); MIDI.loadPlugin(callback);
// simple example to get started; // simple example to get started;
MIDI.loadPlugin(function() { MIDI.loadPlugin({
MIDI.noteOn(0, 100, 127, 0); // plays note once loaded instrument: 1, // or "Acoustic Grand Piano"
}, "soundfont/soundfont-ogg-guitar.js"); callback: function() {
MIDI.noteOn(0, 100, 127, 0); // plays note once loaded
}
});
</pre> </pre>
</li> </li>
<li><a href="./soundfont/soundfont-ogg.js">MIDI.Soundfont.js</a>: &nbsp;Customizable base64 Soundfont.</li> <li><a href="./soundfont/soundfont-ogg.js">MIDI.Soundfont.js</a>: &nbsp;Customizable base64 Soundfont.</li>
@ -202,32 +205,35 @@ Event.add(window, "load", function(event) {
colors.appendChild(d); colors.appendChild(d);
} }
// //
MIDI.loadPlugin(function () { MIDI.loadPlugin({
// this is the language we are running in instrument: 1,
var title = document.getElementById("title"); callback: function () {
title.innerHTML = "Sound being generated with " + MIDI.lang + "."; // this is the language we are running in
// this sets up the MIDI.Player and gets things going... var title = document.getElementById("title");
player = MIDI.Player; title.innerHTML = "Sound being generated with " + MIDI.lang + ".";
player.timeWarp = 1; // speed the song is played back // this sets up the MIDI.Player and gets things going...
player.loadFile(song[songid++%3], player.start); player = MIDI.Player;
// control the piano keys colors player.timeWarp = 1; // speed the song is played back
var colorMap = MusicTheory.Synesthesia.map(); player.loadFile(song[songid++%3], player.start);
player.addListener(function(data) { // control the piano keys colors
var pianoKey = data.note - MIDI.pianoKeyOffset; var colorMap = MusicTheory.Synesthesia.map();
var d = colorElements[pianoKey]; player.addListener(function(data) {
if (data.message === 144) { var pianoKey = data.note - MIDI.pianoKeyOffset;
d.style.background = colorMap[data.note-27].hex; var d = colorElements[pianoKey];
d.style.color = "#fff"; if (data.message === 144) {
} else { d.style.background = colorMap[data.note-27].hex;
d.style.background = ""; d.style.color = "#fff";
d.style.color = ""; } else {
} d.style.background = "";
}); d.style.color = "";
// }
ColorSphereBackground(); });
MIDIPlayerPercentage(player); //
// ColorSphereBackground();
loader.stop(); MIDIPlayerPercentage(player);
//
loader.stop();
}
}); });
}); });

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long