From 7e671791b8561fe3d149b201659d54a3651bc885 Mon Sep 17 00:00:00 2001 From: Eric Rosenbaum Date: Thu, 2 Feb 2017 15:41:16 -0500 Subject: [PATCH] use an enum for audio effect names --- src/index.js | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/src/index.js b/src/index.js index 4eddc04..eaeb1ca 100644 --- a/src/index.js +++ b/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; }