From a1c31c3f4bd7db7c584466a6e5cbace8c1a3f4fa Mon Sep 17 00:00:00 2001 From: Eric Rosenbaum Date: Tue, 10 Jan 2017 11:00:22 -0500 Subject: [PATCH] send duration in sec to instrumentplayer --- src/InstrumentPlayer.js | 4 ++-- src/index.js | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/InstrumentPlayer.js b/src/InstrumentPlayer.js index cee8cb3..ec0896c 100644 --- a/src/InstrumentPlayer.js +++ b/src/InstrumentPlayer.js @@ -15,11 +15,11 @@ function InstrumentPlayer (outputNode) { this.instruments = []; } -InstrumentPlayer.prototype.playNoteForBeatsWithInstrument = function (note, beats, instrumentNum) { +InstrumentPlayer.prototype.playNoteForSecsWithInst = function (note, sec, instrumentNum) { this.loadInstrument(instrumentNum) .then(() => { this.instruments[instrumentNum].play( - note, Tone.context.currentTime, {duration : Number(beats)} // todo: need to use tempo here + note, Tone.context.currentTime, {duration : sec} ); }); }; diff --git a/src/index.js b/src/index.js index d56b831..6e43cd8 100644 --- a/src/index.js +++ b/src/index.js @@ -114,7 +114,8 @@ AudioPlayer.prototype.playSound = function (index) { }; AudioPlayer.prototype.playNoteForBeats = function (note, beats) { - this.audioEngine.instrumentPlayer.playNoteForBeatsWithInstrument(note, beats, this.currentInstrument); + var sec = this.beatsToSec(beats); + this.audioEngine.instrumentPlayer.playNoteForSecsWithInst(note, sec, this.currentInstrument); return this.waitForBeats(beats); };