From fae1dea4abc1e38e861fcdd690c1e10706d4e31a Mon Sep 17 00:00:00 2001 From: Stephanie Chung Date: Wed, 7 May 2014 07:37:48 -0700 Subject: [PATCH] - hooking up piano sounds --- index.html | 113 ++++++++++++++++++++++++++++------------------------- js/main.js | 44 ++++++++++++--------- 2 files changed, 86 insertions(+), 71 deletions(-) diff --git a/index.html b/index.html index 3d880c9..f089467 100644 --- a/index.html +++ b/index.html @@ -6,61 +6,68 @@
- + + + + + + + + \ No newline at end of file diff --git a/js/main.js b/js/main.js index 7281bf0..f49f353 100644 --- a/js/main.js +++ b/js/main.js @@ -1,22 +1,30 @@ -requirejs.config({ - baseUrl: 'js/', +window.onload = function () { + MIDI.loadPlugin({ + soundfontUrl: "./soundfont/", + instrument: "acoustic_grand_piano", + callback: function() { + $('#piano').click(function(event) { + var note = $(event.target).data('note'); - paths: { - jquery: 'libs/jquery-1.11.1.min', - 'jquery.cookie': 'lib/jquery.cookie-1.4.0', - underscore: 'lib/underscore-1.6.0', - fiber: 'libs/fiber.min' - }, - - shim: { - 'jquery.cookie': { - deps: ['jquery'] + playNote(note) + }); } - } -}); + }); + +}; + +function pianoReady() { + +} + +function playNote(note) { + var delay = 0; // play one note every quarter second + var velocity = 127; // how hard the note hits + MIDI.setVolume(0, 127); + MIDI.noteOn(0, note, velocity, delay); + MIDI.noteOff(0, note, delay + 0.75); +} +function getAsyncMusicData() { -require(['controllers/keysController'], - function (KeysController) { - var controller = new KeysController(); - }); \ No newline at end of file +} \ No newline at end of file