mirror of
https://github.com/scratchfoundation/scratch-audio.git
synced 2025-01-03 11:35:49 -05:00
use an enum for audio effect names
This commit is contained in:
parent
de99228cd8
commit
7e671791b8
1 changed files with 20 additions and 6 deletions
26
src/index.js
26
src/index.js
|
@ -142,6 +142,20 @@ AudioEngine.prototype.changeTempo = function (value) {
|
|||
this.setTempo(this.currentTempo + value);
|
||||
};
|
||||
|
||||
/**
|
||||
* Names of the audio effects.
|
||||
* @readonly
|
||||
* @enum {string}
|
||||
*/
|
||||
AudioEngine.prototype.EFFECT_NAMES = {
|
||||
pitch: 'pitch',
|
||||
pan: 'pan',
|
||||
echo: 'echo',
|
||||
reverb: 'reverb',
|
||||
fuzz: 'fuzz',
|
||||
robot: 'robot'
|
||||
};
|
||||
|
||||
/**
|
||||
* Create an AudioPlayer. Each sprite or clone has an AudioPlayer.
|
||||
* It includes a reference to the AudioEngine so it can use global
|
||||
|
@ -254,22 +268,22 @@ AudioPlayer.prototype.stopAllSounds = function () {
|
|||
*/
|
||||
AudioPlayer.prototype.setEffect = function (effect, value) {
|
||||
switch (effect) {
|
||||
case 'pitch':
|
||||
case this.audioEngine.EFFECT_NAMES.pitch:
|
||||
this.pitchEffect.set(value, this.activeSoundPlayers);
|
||||
break;
|
||||
case 'pan':
|
||||
case this.audioEngine.EFFECT_NAMES.pan:
|
||||
this.panEffect.set(value);
|
||||
break;
|
||||
case 'echo':
|
||||
case this.audioEngine.EFFECT_NAMES.echo:
|
||||
this.audioEngine.echoEffect.set(value);
|
||||
break;
|
||||
case 'reverb':
|
||||
case this.audioEngine.EFFECT_NAMES.reverb:
|
||||
this.audioEngine.reverbEffect.set(value);
|
||||
break;
|
||||
case 'fuzz' :
|
||||
case this.audioEngine.EFFECT_NAMES.fuzz:
|
||||
this.audioEngine.fuzzEffect.set(value);
|
||||
break;
|
||||
case 'robot' :
|
||||
case this.audioEngine.EFFECT_NAMES.robot:
|
||||
this.audioEngine.roboticEffect.set(value);
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue