aboutsummaryrefslogtreecommitdiffstats
path: root/Alc/effects/chorus.c
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2014-05-14 23:51:24 -0700
committerChris Robinson <[email protected]>2014-05-14 23:51:24 -0700
commit16d3316f70419bf3589117169d2a789d5ad68160 (patch)
tree79ab8459f03b23ceaf14a9eea83b03b7099ef7e1 /Alc/effects/chorus.c
parenta6974a6c83dcb08735c1c88eb9c0050c084bb1e2 (diff)
Use an enum for the chorus and flanger waveforms
Diffstat (limited to 'Alc/effects/chorus.c')
-rw-r--r--Alc/effects/chorus.c35
1 files changed, 27 insertions, 8 deletions
diff --git a/Alc/effects/chorus.c b/Alc/effects/chorus.c
index f2e43eb6..a6bb199e 100644
--- a/Alc/effects/chorus.c
+++ b/Alc/effects/chorus.c
@@ -30,6 +30,11 @@
#include "alu.h"
+enum ChorusWaveForm {
+ CWF_Triangle = AL_CHORUS_WAVEFORM_TRIANGLE,
+ CWF_Sinusoid = AL_CHORUS_WAVEFORM_SINUSOID
+};
+
typedef struct ALchorusState {
DERIVE_FROM_TYPE(ALeffectState);
@@ -44,7 +49,7 @@ typedef struct ALchorusState {
ALfloat Gain[2][MaxChannels];
/* effect parameters */
- ALint waveform;
+ enum ChorusWaveForm waveform;
ALint delay;
ALfloat depth;
ALfloat feedback;
@@ -92,7 +97,15 @@ static ALvoid ALchorusState_update(ALchorusState *state, ALCdevice *Device, cons
ALfloat rate;
ALint phase;
- state->waveform = Slot->EffectProps.Chorus.Waveform;
+ switch(Slot->EffectProps.Chorus.Waveform)
+ {
+ case AL_CHORUS_WAVEFORM_TRIANGLE:
+ state->waveform = CWF_Triangle;
+ break;
+ case AL_CHORUS_WAVEFORM_SINUSOID:
+ state->waveform = CWF_Sinusoid;
+ break;
+ }
state->depth = Slot->EffectProps.Chorus.Depth;
state->feedback = Slot->EffectProps.Chorus.Feedback;
state->delay = fastf2i(Slot->EffectProps.Chorus.Delay * frequency);
@@ -115,10 +128,10 @@ static ALvoid ALchorusState_update(ALchorusState *state, ALCdevice *Device, cons
state->lfo_range = fastf2u(frequency/rate + 0.5f);
switch(state->waveform)
{
- case AL_CHORUS_WAVEFORM_TRIANGLE:
+ case CWF_Triangle:
state->lfo_scale = 4.0f / state->lfo_range;
break;
- case AL_CHORUS_WAVEFORM_SINUSOID:
+ case CWF_Sinusoid:
state->lfo_scale = F_2PI / state->lfo_range;
break;
}
@@ -198,10 +211,15 @@ static ALvoid ALchorusState_process(ALchorusState *state, ALuint SamplesToDo, co
ALfloat temps[64][2];
ALuint td = minu(SamplesToDo-base, 64);
- if(state->waveform == AL_CHORUS_WAVEFORM_TRIANGLE)
- ProcessTriangle(state, td, SamplesIn+base, temps);
- else if(state->waveform == AL_CHORUS_WAVEFORM_SINUSOID)
- ProcessSinusoid(state, td, SamplesIn+base, temps);
+ switch(state->waveform)
+ {
+ case CWF_Triangle:
+ ProcessTriangle(state, td, SamplesIn+base, temps);
+ break;
+ case CWF_Sinusoid:
+ ProcessSinusoid(state, td, SamplesIn+base, temps);
+ break;
+ }
for(kt = 0;kt < MaxChannels;kt++)
{
@@ -246,6 +264,7 @@ static ALeffectState *ALchorusStateFactory_create(ALchorusStateFactory *UNUSED(f
state->SampleBuffer[1] = NULL;
state->offset = 0;
state->lfo_range = 1;
+ state->waveform = CWF_Triangle;
return STATIC_CAST(ALeffectState, state);
}