mirror of
https://github.com/scratchfoundation/scratch-audio.git
synced 2025-01-05 04:11:55 -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);
|
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.
|
* Create an AudioPlayer. Each sprite or clone has an AudioPlayer.
|
||||||
* It includes a reference to the AudioEngine so it can use global
|
* 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) {
|
AudioPlayer.prototype.setEffect = function (effect, value) {
|
||||||
switch (effect) {
|
switch (effect) {
|
||||||
case 'pitch':
|
case this.audioEngine.EFFECT_NAMES.pitch:
|
||||||
this.pitchEffect.set(value, this.activeSoundPlayers);
|
this.pitchEffect.set(value, this.activeSoundPlayers);
|
||||||
break;
|
break;
|
||||||
case 'pan':
|
case this.audioEngine.EFFECT_NAMES.pan:
|
||||||
this.panEffect.set(value);
|
this.panEffect.set(value);
|
||||||
break;
|
break;
|
||||||
case 'echo':
|
case this.audioEngine.EFFECT_NAMES.echo:
|
||||||
this.audioEngine.echoEffect.set(value);
|
this.audioEngine.echoEffect.set(value);
|
||||||
break;
|
break;
|
||||||
case 'reverb':
|
case this.audioEngine.EFFECT_NAMES.reverb:
|
||||||
this.audioEngine.reverbEffect.set(value);
|
this.audioEngine.reverbEffect.set(value);
|
||||||
break;
|
break;
|
||||||
case 'fuzz' :
|
case this.audioEngine.EFFECT_NAMES.fuzz:
|
||||||
this.audioEngine.fuzzEffect.set(value);
|
this.audioEngine.fuzzEffect.set(value);
|
||||||
break;
|
break;
|
||||||
case 'robot' :
|
case this.audioEngine.EFFECT_NAMES.robot:
|
||||||
this.audioEngine.roboticEffect.set(value);
|
this.audioEngine.roboticEffect.set(value);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue