send duration in sec to instrumentplayer

This commit is contained in:
Eric Rosenbaum 2017-01-10 11:00:22 -05:00
parent 03d78a203b
commit a1c31c3f4b
2 changed files with 4 additions and 3 deletions

View file

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

View file

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