mirror of
https://github.com/scratchfoundation/scratch-audio.git
synced 2024-12-22 22:12:48 -05:00
work in progress on tempo blocks
This commit is contained in:
parent
e3276c80d5
commit
2ae2200e08
1 changed files with 15 additions and 0 deletions
15
src/index.js
15
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);
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue