aboutsummaryrefslogtreecommitdiffstats
path: root/OpenAL32
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2013-05-18 01:33:01 -0700
committerChris Robinson <[email protected]>2013-05-18 01:33:01 -0700
commit78e7c1c27bb0dcc05fc961e53060be17e3df3e02 (patch)
treed4a1368d6a4039bf11b1a5ae9995089ee705cc71 /OpenAL32
parenta7ad6080f0d3fc783fd5e1811b961ab9efe79cde (diff)
Implement distortion and equalizer effects
Code provided by Mike Gorchak
Diffstat (limited to 'OpenAL32')
-rw-r--r--OpenAL32/Include/alAuxEffectSlot.h2
-rw-r--r--OpenAL32/Include/alEffect.h42
-rw-r--r--OpenAL32/alAuxEffectSlot.c4
-rw-r--r--OpenAL32/alEffect.c39
-rw-r--r--OpenAL32/alExtension.c18
5 files changed, 95 insertions, 10 deletions
diff --git a/OpenAL32/Include/alAuxEffectSlot.h b/OpenAL32/Include/alAuxEffectSlot.h
index e39a3d91..c19eb7b3 100644
--- a/OpenAL32/Include/alAuxEffectSlot.h
+++ b/OpenAL32/Include/alAuxEffectSlot.h
@@ -48,6 +48,8 @@ ALeffectState *ModulatorCreate(void);
ALeffectState *DedicatedCreate(void);
ALeffectState *ChorusCreate(void);
ALeffectState *FlangerCreate(void);
+ALeffectState *EqualizerCreate(void);
+ALeffectState *DistortionCreate(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 87dc717d..a3d40b82 100644
--- a/OpenAL32/Include/alEffect.h
+++ b/OpenAL32/Include/alEffect.h
@@ -15,6 +15,8 @@ enum {
DEDICATED,
CHORUS,
FLANGER,
+ EQUALIZER,
+ DISTORTION,
MAX_EFFECTS
};
@@ -95,6 +97,28 @@ typedef struct ALeffect
ALfloat Delay;
} Flanger;
+ struct {
+ ALfloat Delay;
+ ALfloat LowCutoff;
+ ALfloat LowGain;
+ ALfloat Mid1Center;
+ ALfloat Mid1Gain;
+ ALfloat Mid1Width;
+ ALfloat Mid2Center;
+ ALfloat Mid2Gain;
+ ALfloat Mid2Width;
+ ALfloat HighCutoff;
+ ALfloat HighGain;
+ } Equalizer;
+
+ struct {
+ ALfloat Edge;
+ ALfloat Gain;
+ ALfloat LowpassCutoff;
+ ALfloat EQCenter;
+ ALfloat EQBandwidth;
+ } Distortion;
+
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);
@@ -149,6 +173,15 @@ void chorus_GetParamiv(ALeffect *effect, ALCcontext *context, ALenum param, ALin
void chorus_GetParamf(ALeffect *effect, ALCcontext *context, ALenum param, ALfloat *val);
void chorus_GetParamfv(ALeffect *effect, ALCcontext *context, ALenum param, ALfloat *vals);
+void distortion_SetParami(ALeffect *effect, ALCcontext *context, ALenum param, ALint val);
+void distortion_SetParamiv(ALeffect *effect, ALCcontext *context, ALenum param, const ALint *vals);
+void distortion_SetParamf(ALeffect *effect, ALCcontext *context, ALenum param, ALfloat val);
+void distortion_SetParamfv(ALeffect *effect, ALCcontext *context, ALenum param, const ALfloat *vals);
+void distortion_GetParami(ALeffect *effect, ALCcontext *context, ALenum param, ALint *val);
+void distortion_GetParamiv(ALeffect *effect, ALCcontext *context, ALenum param, ALint *vals);
+void distortion_GetParamf(ALeffect *effect, ALCcontext *context, ALenum param, ALfloat *val);
+void distortion_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);
@@ -158,6 +191,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 equalizer_SetParami(ALeffect *effect, ALCcontext *context, ALenum param, ALint val);
+void equalizer_SetParamiv(ALeffect *effect, ALCcontext *context, ALenum param, const ALint *vals);
+void equalizer_SetParamf(ALeffect *effect, ALCcontext *context, ALenum param, ALfloat val);
+void equalizer_SetParamfv(ALeffect *effect, ALCcontext *context, ALenum param, const ALfloat *vals);
+void equalizer_GetParami(ALeffect *effect, ALCcontext *context, ALenum param, ALint *val);
+void equalizer_GetParamiv(ALeffect *effect, ALCcontext *context, ALenum param, ALint *vals);
+void equalizer_GetParamf(ALeffect *effect, ALCcontext *context, ALenum param, ALfloat *val);
+void equalizer_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);
diff --git a/OpenAL32/alAuxEffectSlot.c b/OpenAL32/alAuxEffectSlot.c
index dbaccaa2..7df6bca4 100644
--- a/OpenAL32/alAuxEffectSlot.c
+++ b/OpenAL32/alAuxEffectSlot.c
@@ -513,8 +513,12 @@ static ALeffectState *CreateStateByType(ALenum type)
return ReverbCreate();
case AL_EFFECT_CHORUS:
return ChorusCreate();
+ case AL_EFFECT_DISTORTION:
+ return DistortionCreate();
case AL_EFFECT_ECHO:
return EchoCreate();
+ case AL_EFFECT_EQUALIZER:
+ return EqualizerCreate();
case AL_EFFECT_FLANGER:
return FlangerCreate();
case AL_EFFECT_RING_MODULATOR:
diff --git a/OpenAL32/alEffect.c b/OpenAL32/alEffect.c
index 26d5398d..23176beb 100644
--- a/OpenAL32/alEffect.c
+++ b/OpenAL32/alEffect.c
@@ -430,7 +430,7 @@ static void InitEffectParams(ALeffect *effect, ALenum type)
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.Rate = AL_CHORUS_DEFAULT_RATE;
effect->Chorus.Depth = AL_CHORUS_DEFAULT_DEPTH;
effect->Chorus.Feedback = AL_CHORUS_DEFAULT_FEEDBACK;
effect->Chorus.Delay = AL_CHORUS_DEFAULT_DELAY;
@@ -443,6 +443,21 @@ static void InitEffectParams(ALeffect *effect, ALenum type)
effect->GetParamf = chorus_GetParamf;
effect->GetParamfv = chorus_GetParamfv;
break;
+ case AL_EFFECT_DISTORTION:
+ effect->Distortion.Edge = AL_DISTORTION_DEFAULT_EDGE;
+ effect->Distortion.Gain = AL_DISTORTION_DEFAULT_GAIN;
+ effect->Distortion.LowpassCutoff = AL_DISTORTION_DEFAULT_LOWPASS_CUTOFF;
+ effect->Distortion.EQCenter = AL_DISTORTION_DEFAULT_EQCENTER;
+ effect->Distortion.EQBandwidth = AL_DISTORTION_DEFAULT_EQBANDWIDTH;
+ effect->SetParami = distortion_SetParami;
+ effect->SetParamiv = distortion_SetParamiv;
+ effect->SetParamf = distortion_SetParamf;
+ effect->SetParamfv = distortion_SetParamfv;
+ effect->GetParami = distortion_GetParami;
+ effect->GetParamiv = distortion_GetParamiv;
+ effect->GetParamf = distortion_GetParamf;
+ effect->GetParamfv = distortion_GetParamfv;
+ break;
case AL_EFFECT_ECHO:
effect->Echo.Delay = AL_ECHO_DEFAULT_DELAY;
effect->Echo.LRDelay = AL_ECHO_DEFAULT_LRDELAY;
@@ -458,10 +473,30 @@ static void InitEffectParams(ALeffect *effect, ALenum type)
effect->GetParamf = echo_GetParamf;
effect->GetParamfv = echo_GetParamfv;
break;
+ case AL_EFFECT_EQUALIZER:
+ effect->Equalizer.LowCutoff = AL_EQUALIZER_DEFAULT_LOW_CUTOFF;
+ effect->Equalizer.LowGain = AL_EQUALIZER_DEFAULT_LOW_GAIN;
+ effect->Equalizer.Mid1Center = AL_EQUALIZER_DEFAULT_MID1_CENTER;
+ effect->Equalizer.Mid1Gain = AL_EQUALIZER_DEFAULT_MID1_GAIN;
+ effect->Equalizer.Mid1Width = AL_EQUALIZER_DEFAULT_MID1_WIDTH;
+ effect->Equalizer.Mid2Center = AL_EQUALIZER_DEFAULT_MID2_CENTER;
+ effect->Equalizer.Mid2Gain = AL_EQUALIZER_DEFAULT_MID2_GAIN;
+ effect->Equalizer.Mid2Width = AL_EQUALIZER_DEFAULT_MID2_WIDTH;
+ effect->Equalizer.HighCutoff = AL_EQUALIZER_DEFAULT_HIGH_CUTOFF;
+ effect->Equalizer.HighGain = AL_EQUALIZER_DEFAULT_HIGH_GAIN;
+ effect->SetParami = equalizer_SetParami;
+ effect->SetParamiv = equalizer_SetParamiv;
+ effect->SetParamf = equalizer_SetParamf;
+ effect->SetParamfv = equalizer_SetParamfv;
+ effect->GetParami = equalizer_GetParami;
+ effect->GetParamiv = equalizer_GetParamiv;
+ effect->GetParamf = equalizer_GetParamf;
+ effect->GetParamfv = equalizer_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.Rate = AL_FLANGER_DEFAULT_RATE;
effect->Flanger.Depth = AL_FLANGER_DEFAULT_DEPTH;
effect->Flanger.Feedback = AL_FLANGER_DEFAULT_FEEDBACK;
effect->Flanger.Delay = AL_FLANGER_DEFAULT_DELAY;
diff --git a/OpenAL32/alExtension.c b/OpenAL32/alExtension.c
index f22c89e5..0261ba7a 100644
--- a/OpenAL32/alExtension.c
+++ b/OpenAL32/alExtension.c
@@ -36,14 +36,16 @@
const struct EffectList EffectList[] = {
- { "eaxreverb", EAXREVERB, "AL_EFFECT_EAXREVERB", AL_EFFECT_EAXREVERB },
- { "reverb", REVERB, "AL_EFFECT_REVERB", AL_EFFECT_REVERB },
- { "echo", ECHO, "AL_EFFECT_ECHO", AL_EFFECT_ECHO },
- { "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 },
+ { "eaxreverb", EAXREVERB, "AL_EFFECT_EAXREVERB", AL_EFFECT_EAXREVERB },
+ { "reverb", REVERB, "AL_EFFECT_REVERB", AL_EFFECT_REVERB },
+ { "echo", ECHO, "AL_EFFECT_ECHO", AL_EFFECT_ECHO },
+ { "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 },
+ { "equalizer", EQUALIZER, "AL_EFFECT_EQUALIZER", AL_EFFECT_EQUALIZER },
+ { "distortion", DISTORTION, "AL_EFFECT_DISTORTION", AL_EFFECT_DISTORTION },
{ NULL, 0, NULL, (ALenum)0 }
};