From 2ae2200e08734a2d535592b5dbe79cba4c77ff8a Mon Sep 17 00:00:00 2001 From: Eric Rosenbaum Date: Tue, 25 Oct 2016 22:42:34 -0400 Subject: [PATCH] work in progress on tempo blocks --- src/index.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) 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); };