mirror of
https://github.com/scratchfoundation/scratch-audio.git
synced 2025-01-09 14:22:53 -05:00
send duration in sec to instrumentplayer
This commit is contained in:
parent
03d78a203b
commit
a1c31c3f4b
2 changed files with 4 additions and 3 deletions
|
@ -15,11 +15,11 @@ function InstrumentPlayer (outputNode) {
|
||||||
this.instruments = [];
|
this.instruments = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
InstrumentPlayer.prototype.playNoteForBeatsWithInstrument = function (note, beats, instrumentNum) {
|
InstrumentPlayer.prototype.playNoteForSecsWithInst = function (note, sec, instrumentNum) {
|
||||||
this.loadInstrument(instrumentNum)
|
this.loadInstrument(instrumentNum)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
this.instruments[instrumentNum].play(
|
this.instruments[instrumentNum].play(
|
||||||
note, Tone.context.currentTime, {duration : Number(beats)} // todo: need to use tempo here
|
note, Tone.context.currentTime, {duration : sec}
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
|
@ -114,7 +114,8 @@ AudioPlayer.prototype.playSound = function (index) {
|
||||||
};
|
};
|
||||||
|
|
||||||
AudioPlayer.prototype.playNoteForBeats = function (note, beats) {
|
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);
|
return this.waitForBeats(beats);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue