From fbaad0fe06c7a4f8e5467263bad8fe779a315f26 Mon Sep 17 00:00:00 2001 From: Eric Rosenbaum Date: Wed, 28 Sep 2016 13:20:51 -0400 Subject: [PATCH] experimenting with a soundfont --- playground/AudioEngine.js | 11 +++++++++-- playground/index.html | 1 + playground/soundfont-player.min.js | 1 + 3 files changed, 11 insertions(+), 2 deletions(-) create mode 100644 playground/soundfont-player.min.js diff --git a/playground/AudioEngine.js b/playground/AudioEngine.js index 8b5aa0360..94eed307c 100644 --- a/playground/AudioEngine.js +++ b/playground/AudioEngine.js @@ -1,5 +1,13 @@ function AudioEngine () { + // soundfont setup + + Soundfont.instrument(Tone.context, 'acoustic_grand_piano').then(function (piano) { + this.instrument = piano; + }.bind(this)); + + // tone setup + this.tone = new Tone(); // effects setup @@ -40,8 +48,7 @@ AudioEngine.prototype.getSoundDuration = function (soundNum) { }; AudioEngine.prototype.playNoteForBeats = function(note, beats) { - var freq = this._midiToFreq(note); - this.synth.triggerAttackRelease(freq, beats); + this.instrument.play(note, this.tone.now(), beats); }; AudioEngine.prototype.playDrumForBeats = function(drumNum, beats) { diff --git a/playground/index.html b/playground/index.html index 6287cfa8c..fcf355e6d 100644 --- a/playground/index.html +++ b/playground/index.html @@ -805,6 +805,7 @@ +