aboutsummaryrefslogtreecommitdiffstats
path: root/OpenAL32
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2010-04-08 08:54:28 -0700
committerChris Robinson <[email protected]>2010-04-08 08:54:28 -0700
commitb273d616ad5a9979cbf0b69318aded6ec821450e (patch)
treefd19d6b0a40228669960f7cb30b1e46e04bb9f26 /OpenAL32
parentc16b895460a51d9f89a8f728155e36ab1009c8c5 (diff)
Implement a skeleton Ring Modulator effect
Diffstat (limited to 'OpenAL32')
-rw-r--r--OpenAL32/Include/alAuxEffectSlot.h1
-rw-r--r--OpenAL32/Include/alEffect.h7
-rw-r--r--OpenAL32/alAuxEffectSlot.c2
-rw-r--r--OpenAL32/alEffect.c148
-rw-r--r--OpenAL32/alExtension.c7
5 files changed, 164 insertions, 1 deletions
diff --git a/OpenAL32/Include/alAuxEffectSlot.h b/OpenAL32/Include/alAuxEffectSlot.h
index 7f217dd1..9a916dd8 100644
--- a/OpenAL32/Include/alAuxEffectSlot.h
+++ b/OpenAL32/Include/alAuxEffectSlot.h
@@ -45,6 +45,7 @@ ALeffectState *NoneCreate(void);
ALeffectState *EAXVerbCreate(void);
ALeffectState *VerbCreate(void);
ALeffectState *EchoCreate(void);
+ALeffectState *ModulatorCreate(void);
#define ALEffect_Destroy(a) ((a)->Destroy((a)))
#define ALEffect_DeviceUpdate(a,b) ((a)->DeviceUpdate((a),(b)))
diff --git a/OpenAL32/Include/alEffect.h b/OpenAL32/Include/alEffect.h
index fa49e5d1..6cbf0e5d 100644
--- a/OpenAL32/Include/alEffect.h
+++ b/OpenAL32/Include/alEffect.h
@@ -13,6 +13,7 @@ enum {
EAXREVERB = 0,
REVERB,
ECHO,
+ MODULATOR,
MAX_EFFECTS
};
@@ -62,6 +63,12 @@ typedef struct ALeffect
ALfloat Spread;
} Echo;
+ struct {
+ ALfloat Frequency;
+ ALfloat HighPassCutoff;
+ ALint Waveform;
+ } Modulator;
+
// Index to itself
ALuint effect;
diff --git a/OpenAL32/alAuxEffectSlot.c b/OpenAL32/alAuxEffectSlot.c
index 3f76da2f..90e28431 100644
--- a/OpenAL32/alAuxEffectSlot.c
+++ b/OpenAL32/alAuxEffectSlot.c
@@ -497,6 +497,8 @@ static ALvoid InitializeEffect(ALCcontext *Context, ALeffectslot *EffectSlot, AL
NewState = VerbCreate();
else if(effect->type == AL_EFFECT_ECHO)
NewState = EchoCreate();
+ else if(effect->type == AL_EFFECT_RING_MODULATOR)
+ NewState = ModulatorCreate();
/* No new state? An error occured.. */
if(NewState == NULL ||
ALEffect_DeviceUpdate(NewState, Context->Device) == AL_FALSE)
diff --git a/OpenAL32/alEffect.c b/OpenAL32/alEffect.c
index 07d2b6dc..3dbc8b3d 100644
--- a/OpenAL32/alEffect.c
+++ b/OpenAL32/alEffect.c
@@ -185,7 +185,8 @@ AL_API ALvoid AL_APIENTRY alEffecti(ALuint effect, ALenum param, ALint iValue)
ALboolean isOk = (iValue == AL_EFFECT_NULL ||
(iValue == AL_EFFECT_EAXREVERB && !DisabledEffects[EAXREVERB]) ||
(iValue == AL_EFFECT_REVERB && !DisabledEffects[REVERB]) ||
- (iValue == AL_EFFECT_ECHO && !DisabledEffects[ECHO]));
+ (iValue == AL_EFFECT_ECHO && !DisabledEffects[ECHO]) ||
+ (iValue == AL_EFFECT_RING_MODULATOR && !DisabledEffects[MODULATOR]));
if(isOk)
InitEffectParams(ALEffect, iValue);
@@ -235,6 +236,28 @@ AL_API ALvoid AL_APIENTRY alEffecti(ALuint effect, ALenum param, ALint iValue)
break;
}
}
+ else if(ALEffect->type == AL_EFFECT_RING_MODULATOR)
+ {
+ switch(param)
+ {
+ case AL_RING_MODULATOR_FREQUENCY:
+ case AL_RING_MODULATOR_HIGHPASS_CUTOFF:
+ alEffectf(effect, param, (ALfloat)iValue);
+ break;
+
+ case AL_RING_MODULATOR_WAVEFORM:
+ if(iValue >= AL_RING_MODULATOR_MIN_WAVEFORM &&
+ iValue <= AL_RING_MODULATOR_MAX_WAVEFORM)
+ ALEffect->Modulator.Waveform = iValue;
+ else
+ alSetError(Context, AL_INVALID_VALUE);
+ break;
+
+ default:
+ alSetError(Context, AL_INVALID_ENUM);
+ break;
+ }
+ }
else
alSetError(Context, AL_INVALID_ENUM);
}
@@ -295,6 +318,21 @@ AL_API ALvoid AL_APIENTRY alEffectiv(ALuint effect, ALenum param, ALint *piValue
break;
}
}
+ else if(ALEffect->type == AL_EFFECT_RING_MODULATOR)
+ {
+ switch(param)
+ {
+ case AL_RING_MODULATOR_FREQUENCY:
+ case AL_RING_MODULATOR_HIGHPASS_CUTOFF:
+ case AL_RING_MODULATOR_WAVEFORM:
+ alEffecti(effect, param, piValues[0]);
+ break;
+
+ default:
+ alSetError(Context, AL_INVALID_ENUM);
+ break;
+ }
+ }
else
alSetError(Context, AL_INVALID_ENUM);
}
@@ -633,6 +671,31 @@ AL_API ALvoid AL_APIENTRY alEffectf(ALuint effect, ALenum param, ALfloat flValue
break;
}
}
+ else if(ALEffect->type == AL_EFFECT_RING_MODULATOR)
+ {
+ switch(param)
+ {
+ case AL_RING_MODULATOR_FREQUENCY:
+ if(flValue >= AL_RING_MODULATOR_MIN_FREQUENCY &&
+ flValue <= AL_RING_MODULATOR_MAX_FREQUENCY)
+ ALEffect->Modulator.Frequency = flValue;
+ else
+ alSetError(Context, AL_INVALID_VALUE);
+ break;
+
+ case AL_RING_MODULATOR_HIGHPASS_CUTOFF:
+ if(flValue >= AL_RING_MODULATOR_MIN_HIGHPASS_CUTOFF &&
+ flValue <= AL_RING_MODULATOR_MAX_HIGHPASS_CUTOFF)
+ ALEffect->Modulator.HighPassCutoff = flValue;
+ else
+ alSetError(Context, AL_INVALID_VALUE);
+ break;
+
+ default:
+ alSetError(Context, AL_INVALID_ENUM);
+ break;
+ }
+ }
else
alSetError(Context, AL_INVALID_ENUM);
}
@@ -748,6 +811,20 @@ AL_API ALvoid AL_APIENTRY alEffectfv(ALuint effect, ALenum param, ALfloat *pflVa
break;
}
}
+ else if(ALEffect->type == AL_EFFECT_RING_MODULATOR)
+ {
+ switch(param)
+ {
+ case AL_RING_MODULATOR_FREQUENCY:
+ case AL_RING_MODULATOR_HIGHPASS_CUTOFF:
+ alEffectf(effect, param, pflValues[0]);
+ break;
+
+ default:
+ alSetError(Context, AL_INVALID_ENUM);
+ break;
+ }
+ }
else
alSetError(Context, AL_INVALID_ENUM);
}
@@ -808,6 +885,25 @@ AL_API ALvoid AL_APIENTRY alGetEffecti(ALuint effect, ALenum param, ALint *piVal
break;
}
}
+ else if(ALEffect->type == AL_EFFECT_RING_MODULATOR)
+ {
+ switch(param)
+ {
+ case AL_RING_MODULATOR_FREQUENCY:
+ *piValue = (ALint)ALEffect->Modulator.Frequency;
+ break;
+ case AL_RING_MODULATOR_HIGHPASS_CUTOFF:
+ *piValue = (ALint)ALEffect->Modulator.HighPassCutoff;
+ break;
+ case AL_RING_MODULATOR_WAVEFORM:
+ *piValue = ALEffect->Modulator.Waveform;
+ break;
+
+ default:
+ alSetError(Context, AL_INVALID_ENUM);
+ break;
+ }
+ }
else
alSetError(Context, AL_INVALID_ENUM);
}
@@ -868,6 +964,21 @@ AL_API ALvoid AL_APIENTRY alGetEffectiv(ALuint effect, ALenum param, ALint *piVa
break;
}
}
+ else if(ALEffect->type == AL_EFFECT_RING_MODULATOR)
+ {
+ switch(param)
+ {
+ case AL_RING_MODULATOR_FREQUENCY:
+ case AL_RING_MODULATOR_HIGHPASS_CUTOFF:
+ case AL_RING_MODULATOR_WAVEFORM:
+ alGetEffecti(effect, param, piValues);
+ break;
+
+ default:
+ alSetError(Context, AL_INVALID_ENUM);
+ break;
+ }
+ }
else
alSetError(Context, AL_INVALID_ENUM);
}
@@ -1064,6 +1175,22 @@ AL_API ALvoid AL_APIENTRY alGetEffectf(ALuint effect, ALenum param, ALfloat *pfl
break;
}
}
+ else if(ALEffect->type == AL_EFFECT_RING_MODULATOR)
+ {
+ switch(param)
+ {
+ case AL_RING_MODULATOR_FREQUENCY:
+ *pflValue = ALEffect->Modulator.Frequency;
+ break;
+ case AL_RING_MODULATOR_HIGHPASS_CUTOFF:
+ *pflValue = ALEffect->Modulator.HighPassCutoff;
+ break;
+
+ default:
+ alSetError(Context, AL_INVALID_ENUM);
+ break;
+ }
+ }
else
alSetError(Context, AL_INVALID_ENUM);
}
@@ -1169,6 +1296,20 @@ AL_API ALvoid AL_APIENTRY alGetEffectfv(ALuint effect, ALenum param, ALfloat *pf
break;
}
}
+ else if(ALEffect->type == AL_EFFECT_RING_MODULATOR)
+ {
+ switch(param)
+ {
+ case AL_RING_MODULATOR_FREQUENCY:
+ case AL_RING_MODULATOR_HIGHPASS_CUTOFF:
+ alGetEffectf(effect, param, pflValues);
+ break;
+
+ default:
+ alSetError(Context, AL_INVALID_ENUM);
+ break;
+ }
+ }
else
alSetError(Context, AL_INVALID_ENUM);
}
@@ -1241,5 +1382,10 @@ static void InitEffectParams(ALeffect *effect, ALenum type)
effect->Echo.Feedback = AL_ECHO_DEFAULT_FEEDBACK;
effect->Echo.Spread = AL_ECHO_DEFAULT_SPREAD;
break;
+ case AL_EFFECT_RING_MODULATOR:
+ effect->Modulator.Frequency = AL_RING_MODULATOR_DEFAULT_FREQUENCY;
+ effect->Modulator.HighPassCutoff = AL_RING_MODULATOR_DEFAULT_HIGHPASS_CUTOFF;
+ effect->Modulator.Waveform = AL_RING_MODULATOR_DEFAULT_WAVEFORM;
+ break;
}
}
diff --git a/OpenAL32/alExtension.c b/OpenAL32/alExtension.c
index e08c78a5..f779c6a7 100644
--- a/OpenAL32/alExtension.c
+++ b/OpenAL32/alExtension.c
@@ -340,7 +340,9 @@ static const ALenums enumeration[] = {
{ "AL_EFFECT_FREQUENCY_SHIFTER", AL_EFFECT_FREQUENCY_SHIFTER },
{ "AL_EFFECT_VOCAL_MORPHER", AL_EFFECT_VOCAL_MORPHER },
{ "AL_EFFECT_PITCH_SHIFTER", AL_EFFECT_PITCH_SHIFTER },
+#endif
{ "AL_EFFECT_RING_MODULATOR", AL_EFFECT_RING_MODULATOR },
+#if 0
{ "AL_EFFECT_AUTOWAH", AL_EFFECT_AUTOWAH },
{ "AL_EFFECT_COMPRESSOR", AL_EFFECT_COMPRESSOR },
{ "AL_EFFECT_EQUALIZER", AL_EFFECT_EQUALIZER },
@@ -393,6 +395,11 @@ static const ALenums enumeration[] = {
{ "AL_ECHO_FEEDBACK", AL_ECHO_FEEDBACK },
{ "AL_ECHO_SPREAD", AL_ECHO_SPREAD },
+ // Ring Modulator params
+ { "AL_RING_MODULATOR_FREQUENCY", AL_RING_MODULATOR_FREQUENCY },
+ { "AL_RING_MODULATOR_HIGHPASS_CUTOFF", AL_RING_MODULATOR_HIGHPASS_CUTOFF },
+ { "AL_RING_MODULATOR_WAVEFORM", AL_RING_MODULATOR_WAVEFORM },
+
// Default
{ NULL, (ALenum)0 }