aboutsummaryrefslogtreecommitdiffstats
path: root/OpenAL32
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2013-03-13 23:31:12 -0700
committerChris Robinson <[email protected]>2013-03-13 23:31:12 -0700
commit3fd0f23e48fc71718f438e035ffb09d4ba9a47a3 (patch)
treedc33a1a36aa51489f513cb68c1ed4c07b7334d47 /OpenAL32
parent991aba286f32e8760811bc061b15c5102c66b3e1 (diff)
Add Chorus and Flanger effects
Code provided by Mike Gorchak
Diffstat (limited to 'OpenAL32')
-rw-r--r--OpenAL32/Include/alAuxEffectSlot.h2
-rw-r--r--OpenAL32/Include/alEffect.h38
-rw-r--r--OpenAL32/alAuxEffectSlot.c10
-rw-r--r--OpenAL32/alEffect.c34
-rw-r--r--OpenAL32/alExtension.c2
5 files changed, 86 insertions, 0 deletions
diff --git a/OpenAL32/Include/alAuxEffectSlot.h b/OpenAL32/Include/alAuxEffectSlot.h
index 4c14b1f7..e39a3d91 100644
--- a/OpenAL32/Include/alAuxEffectSlot.h
+++ b/OpenAL32/Include/alAuxEffectSlot.h
@@ -46,6 +46,8 @@ ALeffectState *ReverbCreate(void);
ALeffectState *EchoCreate(void);
ALeffectState *ModulatorCreate(void);
ALeffectState *DedicatedCreate(void);
+ALeffectState *ChorusCreate(void);
+ALeffectState *FlangerCreate(void);
#define ALeffectState_Destroy(a) ((a)->Destroy((a)))
#define ALeffectState_DeviceUpdate(a,b) ((a)->DeviceUpdate((a),(b)))
diff --git a/OpenAL32/Include/alEffect.h b/OpenAL32/Include/alEffect.h
index 77ff97a8..87dc717d 100644
--- a/OpenAL32/Include/alEffect.h
+++ b/OpenAL32/Include/alEffect.h
@@ -13,6 +13,8 @@ enum {
ECHO,
MODULATOR,
DEDICATED,
+ CHORUS,
+ FLANGER,
MAX_EFFECTS
};
@@ -75,6 +77,24 @@ typedef struct ALeffect
ALfloat Gain;
} Dedicated;
+ struct {
+ ALint Waveform;
+ ALint Phase;
+ ALfloat Rate;
+ ALfloat Depth;
+ ALfloat Feedback;
+ ALfloat Delay;
+ } Chorus;
+
+ struct {
+ ALint Waveform;
+ ALint Phase;
+ ALfloat Rate;
+ ALfloat Depth;
+ ALfloat Feedback;
+ ALfloat Delay;
+ } Flanger;
+
void (*SetParami)(struct ALeffect *effect, ALCcontext *context, ALenum param, ALint val);
void (*SetParamiv)(struct ALeffect *effect, ALCcontext *context, ALenum param, const ALint *vals);
void (*SetParamf)(struct ALeffect *effect, ALCcontext *context, ALenum param, ALfloat val);
@@ -120,6 +140,15 @@ void reverb_GetParamiv(ALeffect *effect, ALCcontext *context, ALenum param, ALin
void reverb_GetParamf(ALeffect *effect, ALCcontext *context, ALenum param, ALfloat *val);
void reverb_GetParamfv(ALeffect *effect, ALCcontext *context, ALenum param, ALfloat *vals);
+void chorus_SetParami(ALeffect *effect, ALCcontext *context, ALenum param, ALint val);
+void chorus_SetParamiv(ALeffect *effect, ALCcontext *context, ALenum param, const ALint *vals);
+void chorus_SetParamf(ALeffect *effect, ALCcontext *context, ALenum param, ALfloat val);
+void chorus_SetParamfv(ALeffect *effect, ALCcontext *context, ALenum param, const ALfloat *vals);
+void chorus_GetParami(ALeffect *effect, ALCcontext *context, ALenum param, ALint *val);
+void chorus_GetParamiv(ALeffect *effect, ALCcontext *context, ALenum param, ALint *vals);
+void chorus_GetParamf(ALeffect *effect, ALCcontext *context, ALenum param, ALfloat *val);
+void chorus_GetParamfv(ALeffect *effect, ALCcontext *context, ALenum param, ALfloat *vals);
+
void echo_SetParami(ALeffect *effect, ALCcontext *context, ALenum param, ALint val);
void echo_SetParamiv(ALeffect *effect, ALCcontext *context, ALenum param, const ALint *vals);
void echo_SetParamf(ALeffect *effect, ALCcontext *context, ALenum param, ALfloat val);
@@ -129,6 +158,15 @@ void echo_GetParamiv(ALeffect *effect, ALCcontext *context, ALenum param, ALint
void echo_GetParamf(ALeffect *effect, ALCcontext *context, ALenum param, ALfloat *val);
void echo_GetParamfv(ALeffect *effect, ALCcontext *context, ALenum param, ALfloat *vals);
+void flanger_SetParami(ALeffect *effect, ALCcontext *context, ALenum param, ALint val);
+void flanger_SetParamiv(ALeffect *effect, ALCcontext *context, ALenum param, const ALint *vals);
+void flanger_SetParamf(ALeffect *effect, ALCcontext *context, ALenum param, ALfloat val);
+void flanger_SetParamfv(ALeffect *effect, ALCcontext *context, ALenum param, const ALfloat *vals);
+void flanger_GetParami(ALeffect *effect, ALCcontext *context, ALenum param, ALint *val);
+void flanger_GetParamiv(ALeffect *effect, ALCcontext *context, ALenum param, ALint *vals);
+void flanger_GetParamf(ALeffect *effect, ALCcontext *context, ALenum param, ALfloat *val);
+void flanger_GetParamfv(ALeffect *effect, ALCcontext *context, ALenum param, ALfloat *vals);
+
void mod_SetParamf(ALeffect *effect, ALCcontext *context, ALenum param, ALfloat val);
void mod_SetParamfv(ALeffect *effect, ALCcontext *context, ALenum param, const ALfloat *vals);
void mod_SetParami(ALeffect *effect, ALCcontext *context, ALenum param, ALint val);
diff --git a/OpenAL32/alAuxEffectSlot.c b/OpenAL32/alAuxEffectSlot.c
index 23cfa4ac..99e8daf1 100644
--- a/OpenAL32/alAuxEffectSlot.c
+++ b/OpenAL32/alAuxEffectSlot.c
@@ -537,6 +537,16 @@ ALenum InitializeEffect(ALCdevice *Device, ALeffectslot *EffectSlot, ALeffect *e
if(!State) err = AL_OUT_OF_MEMORY;
}
}
+ else if(newtype == AL_EFFECT_CHORUS && EffectSlot->effect.type != AL_EFFECT_CHORUS)
+ {
+ State = ChorusCreate();
+ if(!State) err = AL_OUT_OF_MEMORY;
+ }
+ else if(newtype == AL_EFFECT_FLANGER && EffectSlot->effect.type != AL_EFFECT_FLANGER)
+ {
+ State = FlangerCreate();
+ if(!State) err = AL_OUT_OF_MEMORY;
+ }
if(err != AL_NO_ERROR)
{
diff --git a/OpenAL32/alEffect.c b/OpenAL32/alEffect.c
index 2c684626..07bbaa8e 100644
--- a/OpenAL32/alEffect.c
+++ b/OpenAL32/alEffect.c
@@ -470,6 +470,40 @@ static void InitEffectParams(ALeffect *effect, ALenum type)
effect->GetParamf = ded_GetParamf;
effect->GetParamfv = ded_GetParamfv;
break;
+ case AL_EFFECT_CHORUS:
+ effect->Chorus.Waveform = AL_CHORUS_DEFAULT_WAVEFORM;
+ effect->Chorus.Phase = AL_CHORUS_DEFAULT_PHASE;
+ effect->Chorus.Rate = AL_CHORUS_MAX_RATE;
+ effect->Chorus.Depth = AL_CHORUS_DEFAULT_DEPTH;
+ effect->Chorus.Feedback = AL_CHORUS_DEFAULT_FEEDBACK;
+ effect->Chorus.Delay = AL_CHORUS_DEFAULT_DELAY;
+
+ effect->SetParami = chorus_SetParami;
+ effect->SetParamiv = chorus_SetParamiv;
+ effect->SetParamf = chorus_SetParamf;
+ effect->SetParamfv = chorus_SetParamfv;
+ effect->GetParami = chorus_GetParami;
+ effect->GetParamiv = chorus_GetParamiv;
+ effect->GetParamf = chorus_GetParamf;
+ effect->GetParamfv = chorus_GetParamfv;
+ break;
+ case AL_EFFECT_FLANGER:
+ effect->Flanger.Waveform = AL_FLANGER_DEFAULT_WAVEFORM;
+ effect->Flanger.Phase = AL_FLANGER_DEFAULT_PHASE;
+ effect->Flanger.Rate = AL_FLANGER_MAX_RATE;
+ effect->Flanger.Depth = AL_FLANGER_DEFAULT_DEPTH;
+ effect->Flanger.Feedback = AL_FLANGER_DEFAULT_FEEDBACK;
+ effect->Flanger.Delay = AL_FLANGER_DEFAULT_DELAY;
+
+ effect->SetParami = flanger_SetParami;
+ effect->SetParamiv = flanger_SetParamiv;
+ effect->SetParamf = flanger_SetParamf;
+ effect->SetParamfv = flanger_SetParamfv;
+ effect->GetParami = flanger_GetParami;
+ effect->GetParamiv = flanger_GetParamiv;
+ effect->GetParamf = flanger_GetParamf;
+ effect->GetParamfv = flanger_GetParamfv;
+ break;
default:
effect->SetParami = null_SetParami;
effect->SetParamiv = null_SetParamiv;
diff --git a/OpenAL32/alExtension.c b/OpenAL32/alExtension.c
index c73200d0..f22c89e5 100644
--- a/OpenAL32/alExtension.c
+++ b/OpenAL32/alExtension.c
@@ -42,6 +42,8 @@ const struct EffectList EffectList[] = {
{ "modulator", MODULATOR, "AL_EFFECT_RING_MODULATOR", AL_EFFECT_RING_MODULATOR },
{ "dedicated", DEDICATED, "AL_EFFECT_DEDICATED_LOW_FREQUENCY_EFFECT", AL_EFFECT_DEDICATED_LOW_FREQUENCY_EFFECT },
{ "dedicated", DEDICATED, "AL_EFFECT_DEDICATED_DIALOGUE", AL_EFFECT_DEDICATED_DIALOGUE },
+ { "chorus", CHORUS, "AL_EFFECT_CHORUS", AL_EFFECT_CHORUS },
+ { "flanger", FLANGER, "AL_EFFECT_FLANGER", AL_EFFECT_FLANGER },
{ NULL, 0, NULL, (ALenum)0 }
};