single tempo owned by audioengine

This commit is contained in:
Eric Rosenbaum 2017-01-09 15:56:59 -05:00
parent 9b3119c96e
commit 2058b2dd19

View file

@ -32,6 +32,8 @@ function AudioEngine () {
// this.input = new Tone.Gain();
// this.input.connect(Tone.Master);
// global tempo in bpm (beats per minute)
this.currentTempo = 60;
}
AudioEngine.prototype.createPlayer = function () {
@ -70,11 +72,6 @@ function AudioPlayer (audioEngine) {
this.instrumentNum;
this.setInstrument(1);
// tempo in bpm (beats per minute)
// default is 60bpm
this.currentTempo = 60;
this.currentVolume = 100;
}
@ -142,7 +139,7 @@ AudioPlayer.prototype.waitForBeats = function (beats) {
return new Promise(function (resolve) {
setTimeout(function () {
resolve();
}, ((60 / storedContext.currentTempo) * 1000 * beats));
}, ((60 / storedContext.audioEngine.currentTempo) * 1000 * beats));
});
};
@ -243,12 +240,12 @@ AudioPlayer.prototype.changeVolume = function (value) {
AudioPlayer.prototype.setTempo = function (value) {
var newTempo = this._clamp(value, 10, 1000);
this.currentTempo = newTempo;
this.audioEngine.currentTempo = newTempo;
};
AudioPlayer.prototype.changeTempo = function (value) {
var newTempo = this._clamp(this.currentTempo + value, 10, 1000);
this.currentTempo = newTempo;
this.audioEngine.currentTempo = newTempo;
};
AudioPlayer.prototype._clamp = function (input, min, max) {