diff --git a/src/index.js b/src/index.js index 7ee7ce7..52b88ce 100644 --- a/src/index.js +++ b/src/index.js @@ -42,6 +42,11 @@ function AudioEngine (sounds) { this.setInstrument(0); + // tempo in bpm (beats per minute) + // default is 60bpm + + this.currentTempo = 60; + // theremin setup this.theremin = new Tone.Synth(); @@ -224,6 +229,16 @@ AudioEngine.prototype.changeVolume = function (value) { this.effectsNode.gain.value = this._clamp(newVol, 0, 1); }; +AudioEngine.prototype.setTempo = function (value) { + var newTempo = this._clamp(value, 10, 1000); + this.currentTempo = newTempo; +}; + +AudioEngine.prototype.changeTempo = function (value) { + var newTempo = this._clamp(this.currentTempo + value, 10, 1000); + this.currentTempo = newTempo; +}; + AudioEngine.prototype._clamp = function (input, min, max) { return Math.min(Math.max(input, min), max); };