update demos to for latest libraries

This commit is contained in:
Michael Deal 2012-11-21 01:29:46 -08:00
parent a50ca64600
commit 26f6e8a031
3 changed files with 52 additions and 46 deletions

View file

@ -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);
}
}
});

View file

@ -205,9 +205,7 @@ Event.add(window, "load", function(event) {
colors.appendChild(d);
}
//
MIDI.loadPlugin({
instrument: 1,
callback: function () {
MIDI.loadPlugin(function () {
// this is the language we are running in
var title = document.getElementById("title");
title.innerHTML = "Sound being generated with " + MIDI.lang + ".";
@ -233,7 +231,6 @@ Event.add(window, "load", function(event) {
MIDIPlayerPercentage(player);
//
loader.stop();
}
});
});

View file

@ -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,7 +85,9 @@ RefreshFrame = function () {
};
window.onload = function () {
MIDI.loadPlugin(function() {
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";
@ -100,6 +102,7 @@ window.onload = function () {
}
startTime = (new Date()).getTime();
setInterval(RefreshFrame, 1000 / 30);
}
});
};