mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2025-08-28 22:30:40 -04:00
target manages audio effect values
This commit is contained in:
parent
01e237a2d5
commit
4e4b0b86e1
2 changed files with 23 additions and 2 deletions
|
@ -97,13 +97,17 @@ Scratch3SoundBlocks.prototype.setInstrument = function (args, util) {
|
|||
};
|
||||
|
||||
Scratch3SoundBlocks.prototype.setEffect = function (args, util) {
|
||||
var effect = Cast.toString(args.EFFECT).toLowerCase();
|
||||
var value = Cast.toNumber(args.VALUE);
|
||||
util.target.audioPlayer.setEffect(args.EFFECT, value);
|
||||
util.target.setAudioEffect(effect, value);
|
||||
};
|
||||
|
||||
Scratch3SoundBlocks.prototype.changeEffect = function (args, util) {
|
||||
var effect = Cast.toString(args.EFFECT).toLowerCase();
|
||||
var value = Cast.toNumber(args.VALUE);
|
||||
util.target.audioPlayer.changeEffect(args.EFFECT, value);
|
||||
if (!util.target.audioEffects.hasOwnProperty(effect)) return;
|
||||
var newValue = value + util.target.audioEffects[effect];
|
||||
util.target.setAudioEffect(effect, newValue);
|
||||
};
|
||||
|
||||
Scratch3SoundBlocks.prototype.clearEffects = function (args, util) {
|
||||
|
|
|
@ -341,6 +341,23 @@ RenderedTarget.prototype.clearEffects = function () {
|
|||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Set a particular audio effect value.
|
||||
* @param {!string} effectName Name audio of effect (see `RenderedTarget.prototype.audioEffects`).
|
||||
* @param {!number} value Numerical magnitude of effect.
|
||||
*/
|
||||
RenderedTarget.prototype.setAudioEffect = function (effectName, value) {
|
||||
if (!this.audioEffects.hasOwnProperty(effectName)) return;
|
||||
this.audioEffects[effectName] = value;
|
||||
this.audioPlayer.setEffect(effectName, value);
|
||||
};
|
||||
|
||||
RenderedTarget.prototype.clearAudioEffects = function () {
|
||||
for (var effectName in this.audioEffects) {
|
||||
this.audioEffects[effectName] = 0;
|
||||
this.audioPlayer.setEffect(effectName, 0);
|
||||
}
|
||||
};
|
||||
/**
|
||||
* Set the current costume.
|
||||
* @param {number} index New index of costume.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue