use an enum for audio effect names

This commit is contained in:
Eric Rosenbaum 2017-02-02 15:41:16 -05:00
parent de99228cd8
commit 7e671791b8

View file

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