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