work in progress on tempo blocks

This commit is contained in:
Eric Rosenbaum 2016-10-25 22:42:34 -04:00
parent e3276c80d5
commit 2ae2200e08

View file

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