update demos to for latest libraries
This commit is contained in:
parent
a50ca64600
commit
26f6e8a031
3 changed files with 52 additions and 46 deletions
|
@ -5,6 +5,7 @@
|
|||
<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/Widgets/Loader.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 -->
|
||||
|
@ -14,10 +15,15 @@
|
|||
<body>
|
||||
<script type="text/javascript">
|
||||
|
||||
var loader;
|
||||
window.onload = function () {
|
||||
loader = new widgets.Loader;
|
||||
MIDI.loadPlugin({
|
||||
instruments: [ "acoustic_grand_piano", "acoustic_guitar_nylon" ], // or multiple instruments
|
||||
callback: function() {
|
||||
loader.stop();
|
||||
MIDI.programChange(0, 0);
|
||||
MIDI.programChange(1, 24);
|
||||
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
|
||||
|
@ -25,7 +31,7 @@ window.onload = function () {
|
|||
// play the note
|
||||
MIDI.noteOn(0, note, velocity, delay);
|
||||
// play the some note 3-steps up
|
||||
MIDI.noteOn(0, note + 3, velocity, delay);
|
||||
MIDI.noteOn(1, note + 3, velocity, delay);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -205,35 +205,32 @@ Event.add(window, "load", function(event) {
|
|||
colors.appendChild(d);
|
||||
}
|
||||
//
|
||||
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();
|
||||
}
|
||||
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();
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -66,7 +66,7 @@ RefreshFrame = function () {
|
|||
var len = circleRadius * (1 + 1.0 / nbrPoints - r);
|
||||
if (Math.floor(a / PI2) !== Math.floor(tines[i] / PI2)) {
|
||||
MIDI.noteOn(0, i + 21, 100, 0);
|
||||
MIDI.noteOn(0, i + 21 + 36, 100, 0);
|
||||
MIDI.noteOn(24, i + 21 + 36, 100, 0);
|
||||
lastSound[i] = ms;
|
||||
}
|
||||
var x = (cx + Math.cos(a) * len);
|
||||
|
@ -85,21 +85,24 @@ RefreshFrame = function () {
|
|||
};
|
||||
|
||||
window.onload = function () {
|
||||
MIDI.loadPlugin(function() {
|
||||
loader.stop();
|
||||
var canvas = document.getElementById('mycanvas');
|
||||
canvas.style.width = gw + "px";
|
||||
canvas.style.width = gw + "px";
|
||||
canvas.width = gw;
|
||||
canvas.height = gh;
|
||||
dc = canvas.getContext('2d');
|
||||
for (var i = 0; i < nbrPoints; ++i) {
|
||||
if (i % 7 === 0) MIDI.noteOn(0, i + 21, 100, 0);
|
||||
lastSound[i] = 0;
|
||||
tines[i] = 0;
|
||||
MIDI.loadPlugin({
|
||||
instruments: [ "acoustic_grand_piano", "acoustic_guitar_nylon" ], // or multiple instruments
|
||||
callback: function() {
|
||||
loader.stop();
|
||||
var canvas = document.getElementById('mycanvas');
|
||||
canvas.style.width = gw + "px";
|
||||
canvas.style.width = gw + "px";
|
||||
canvas.width = gw;
|
||||
canvas.height = gh;
|
||||
dc = canvas.getContext('2d');
|
||||
for (var i = 0; i < nbrPoints; ++i) {
|
||||
if (i % 7 === 0) MIDI.noteOn(0, i + 21, 100, 0);
|
||||
lastSound[i] = 0;
|
||||
tines[i] = 0;
|
||||
}
|
||||
startTime = (new Date()).getTime();
|
||||
setInterval(RefreshFrame, 1000 / 30);
|
||||
}
|
||||
startTime = (new Date()).getTime();
|
||||
setInterval(RefreshFrame, 1000 / 30);
|
||||
});
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue