mirror of
https://github.com/scratchfoundation/scratch-audio.git
synced 2024-12-22 14:02:29 -05:00
set volume and change volume
This commit is contained in:
parent
85c4c03076
commit
f8aaf553f8
1 changed files with 12 additions and 0 deletions
12
src/index.js
12
src/index.js
|
@ -207,6 +207,18 @@ AudioEngine.prototype.clearEffects = function () {
|
|||
this.reverb.wet.value = 0;
|
||||
};
|
||||
|
||||
AudioEngine.prototype.setVolume = function (value) {
|
||||
var vol = this._clamp(value, 0, 100);
|
||||
vol /= 100;
|
||||
this.effectsNode.gain.value = vol;
|
||||
};
|
||||
|
||||
AudioEngine.prototype.changeVolume = function (value) {
|
||||
value /= 100;
|
||||
var newVol = this.effectsNode.gain.value + value;
|
||||
this.effectsNode.gain.value = this._clamp(newVol, 0, 1);
|
||||
};
|
||||
|
||||
AudioEngine.prototype._clamp = function (input, min, max) {
|
||||
return Math.min(Math.max(input, min), max);
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue