aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2011-03-12 20:11:25 -0800
committerChris Robinson <[email protected]>2011-03-12 20:11:25 -0800
commit73123bc313fd0f700abc8569138081abca997b78 (patch)
treeb438e53a2ed62f8b6391793aaf36297da0ad8b27
parent947aa1342c82fe22b2030b04e43532af0a07d978 (diff)
Add support for ALC_EXT_DEDICATED
-rw-r--r--Alc/ALc.c4
-rw-r--r--Alc/alcDedicated.c131
-rw-r--r--CMakeLists.txt1
-rw-r--r--OpenAL32/Include/alAuxEffectSlot.h2
-rw-r--r--OpenAL32/Include/alEffect.h5
-rw-r--r--OpenAL32/alAuxEffectSlot.c4
-rw-r--r--OpenAL32/alEffect.c67
-rw-r--r--OpenAL32/alExtension.c5
8 files changed, 217 insertions, 2 deletions
diff --git a/Alc/ALc.c b/Alc/ALc.c
index c5b3f4e4..390856a7 100644
--- a/Alc/ALc.c
+++ b/Alc/ALc.c
@@ -331,7 +331,8 @@ static const ALCchar alcNoDeviceExtList[] =
"ALC_EXT_thread_local_context";
static const ALCchar alcExtensionList[] =
"ALC_ENUMERATE_ALL_EXT ALC_ENUMERATION_EXT ALC_EXT_CAPTURE "
- "ALC_EXT_disconnect ALC_EXT_EFX ALC_EXT_thread_local_context";
+ "ALC_EXT_DEDICATED ALC_EXT_disconnect ALC_EXT_EFX "
+ "ALC_EXT_thread_local_context";
static const ALCint alcMajorVersion = 1;
static const ALCint alcMinorVersion = 1;
@@ -514,6 +515,7 @@ static void alc_init(void)
{ "reverb", REVERB },
{ "echo", ECHO },
{ "modulator", MODULATOR },
+ { "dedicated", DEDICATED },
{ NULL, 0 }
};
int n;
diff --git a/Alc/alcDedicated.c b/Alc/alcDedicated.c
new file mode 100644
index 00000000..4ffc6534
--- /dev/null
+++ b/Alc/alcDedicated.c
@@ -0,0 +1,131 @@
+/**
+ * OpenAL cross platform audio library
+ * Copyright (C) 2011 by Chris Robinson.
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ * Or go to http://www.gnu.org/copyleft/lgpl.html
+ */
+
+#include "config.h"
+
+#include <stdlib.h>
+
+#include "alMain.h"
+#include "alFilter.h"
+#include "alAuxEffectSlot.h"
+#include "alError.h"
+#include "alu.h"
+
+
+typedef struct ALdedicatedState {
+ // Must be first in all effects!
+ ALeffectState state;
+
+ ALfloat gains[MAXCHANNELS];
+} ALdedicatedState;
+
+
+static ALvoid DedicatedDestroy(ALeffectState *effect)
+{
+ ALdedicatedState *state = (ALdedicatedState*)effect;
+ free(state);
+}
+
+static ALboolean DedicatedDeviceUpdate(ALeffectState *effect, ALCdevice *Device)
+{
+ (void)effect;
+ (void)Device;
+ return AL_TRUE;
+}
+
+static ALvoid DedicatedDLGUpdate(ALeffectState *effect, ALCcontext *Context, const ALeffect *Effect)
+{
+ ALdedicatedState *state = (ALdedicatedState*)effect;
+ ALCdevice *device = Context->Device;
+ const ALfloat *SpeakerGain;
+ ALint pos;
+ ALsizei s;
+
+ pos = aluCart2LUTpos(-1.0f, 0.0f);
+ SpeakerGain = &device->PanningLUT[MAXCHANNELS * pos];
+
+ for(s = 0;s < MAXCHANNELS;s++)
+ state->gains[s] = SpeakerGain[s] * Effect->Dedicated.Gain;
+}
+
+static ALvoid DedicatedLFEUpdate(ALeffectState *effect, ALCcontext *Context, const ALeffect *Effect)
+{
+ ALdedicatedState *state = (ALdedicatedState*)effect;
+ ALsizei s;
+ (void)Context;
+
+ for(s = 0;s < MAXCHANNELS;s++)
+ state->gains[s] = 0.0f;
+ state->gains[LFE] = Effect->Dedicated.Gain;
+}
+
+static ALvoid DedicatedProcess(ALeffectState *effect, const ALeffectslot *Slot, ALuint SamplesToDo, const ALfloat *SamplesIn, ALfloat (*SamplesOut)[MAXCHANNELS])
+{
+ ALdedicatedState *state = (ALdedicatedState*)effect;
+ const ALfloat *gains = state->gains;
+ ALuint i;
+
+ for(i = 0;i < SamplesToDo;i++)
+ {
+ ALsizei s;
+ for(s = 0;s < MAXCHANNELS;s++)
+ SamplesOut[i][s] = SamplesIn[i] * gains[s] * Slot->Gain;
+ }
+}
+
+ALeffectState *DedicatedDLGCreate(void)
+{
+ ALdedicatedState *state;
+ ALsizei s;
+
+ state = malloc(sizeof(*state));
+ if(!state)
+ return NULL;
+
+ state->state.Destroy = DedicatedDestroy;
+ state->state.DeviceUpdate = DedicatedDeviceUpdate;
+ state->state.Update = DedicatedDLGUpdate;
+ state->state.Process = DedicatedProcess;
+
+ for(s = 0;s < MAXCHANNELS;s++)
+ state->gains[s] = 0.0f;
+
+ return &state->state;
+}
+
+ALeffectState *DedicatedLFECreate(void)
+{
+ ALdedicatedState *state;
+ ALsizei s;
+
+ state = malloc(sizeof(*state));
+ if(!state)
+ return NULL;
+
+ state->state.Destroy = DedicatedDestroy;
+ state->state.DeviceUpdate = DedicatedDeviceUpdate;
+ state->state.Update = DedicatedLFEUpdate;
+ state->state.Process = DedicatedProcess;
+
+ for(s = 0;s < MAXCHANNELS;s++)
+ state->gains[s] = 0.0f;
+
+ return &state->state;
+}
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 2cd7aafa..9284a123 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -319,6 +319,7 @@ SET(OPENAL_OBJS OpenAL32/alAuxEffectSlot.c
SET(ALC_OBJS Alc/ALc.c
Alc/ALu.c
Alc/alcConfig.c
+ Alc/alcDedicated.c
Alc/alcEcho.c
Alc/alcModulator.c
Alc/alcReverb.c
diff --git a/OpenAL32/Include/alAuxEffectSlot.h b/OpenAL32/Include/alAuxEffectSlot.h
index 43d2f719..09bc363e 100644
--- a/OpenAL32/Include/alAuxEffectSlot.h
+++ b/OpenAL32/Include/alAuxEffectSlot.h
@@ -49,6 +49,8 @@ ALeffectState *EAXVerbCreate(void);
ALeffectState *VerbCreate(void);
ALeffectState *EchoCreate(void);
ALeffectState *ModulatorCreate(void);
+ALeffectState *DedicatedDLGCreate(void);
+ALeffectState *DedicatedLFECreate(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 500b60a1..aa8e1200 100644
--- a/OpenAL32/Include/alEffect.h
+++ b/OpenAL32/Include/alEffect.h
@@ -14,6 +14,7 @@ enum {
REVERB,
ECHO,
MODULATOR,
+ DEDICATED,
MAX_EFFECTS
};
@@ -69,6 +70,10 @@ typedef struct ALeffect
ALint Waveform;
} Modulator;
+ struct {
+ ALfloat Gain;
+ } Dedicated;
+
// Index to itself
ALuint effect;
} ALeffect;
diff --git a/OpenAL32/alAuxEffectSlot.c b/OpenAL32/alAuxEffectSlot.c
index aab4f96b..9d25ce23 100644
--- a/OpenAL32/alAuxEffectSlot.c
+++ b/OpenAL32/alAuxEffectSlot.c
@@ -488,6 +488,10 @@ static ALvoid InitializeEffect(ALCcontext *Context, ALeffectslot *EffectSlot, AL
NewState = EchoCreate();
else if(effect->type == AL_EFFECT_RING_MODULATOR)
NewState = ModulatorCreate();
+ else if(effect->type == AL_EFFECT_DEDICATED_LOW_FREQUENCY_EFFECT)
+ NewState = DedicatedLFECreate();
+ else if(effect->type == AL_EFFECT_DEDICATED_DIALOGUE)
+ NewState = DedicatedDLGCreate();
/* 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 0814cfe0..69a5b32d 100644
--- a/OpenAL32/alEffect.c
+++ b/OpenAL32/alEffect.c
@@ -171,7 +171,9 @@ AL_API ALvoid AL_APIENTRY alEffecti(ALuint effect, ALenum param, ALint iValue)
(iValue == AL_EFFECT_EAXREVERB && !DisabledEffects[EAXREVERB]) ||
(iValue == AL_EFFECT_REVERB && !DisabledEffects[REVERB]) ||
(iValue == AL_EFFECT_ECHO && !DisabledEffects[ECHO]) ||
- (iValue == AL_EFFECT_RING_MODULATOR && !DisabledEffects[MODULATOR]));
+ (iValue == AL_EFFECT_RING_MODULATOR && !DisabledEffects[MODULATOR]) ||
+ ((iValue == AL_EFFECT_DEDICATED_LOW_FREQUENCY_EFFECT ||
+ iValue == AL_EFFECT_DEDICATED_DIALOGUE) && !DisabledEffects[DEDICATED]));
if(isOk)
InitEffectParams(ALEffect, iValue);
@@ -681,6 +683,23 @@ AL_API ALvoid AL_APIENTRY alEffectf(ALuint effect, ALenum param, ALfloat flValue
break;
}
}
+ else if(ALEffect->type == AL_EFFECT_DEDICATED_LOW_FREQUENCY_EFFECT ||
+ ALEffect->type == AL_EFFECT_DEDICATED_DIALOGUE)
+ {
+ switch(param)
+ {
+ case AL_DEDICATED_GAIN:
+ if(flValue >= 0.0f)
+ ALEffect->Dedicated.Gain = flValue;
+ else
+ alSetError(Context, AL_INVALID_VALUE);
+ break;
+
+ default:
+ alSetError(Context, AL_INVALID_ENUM);
+ break;
+ }
+ }
else
alSetError(Context, AL_INVALID_ENUM);
}
@@ -810,6 +829,20 @@ AL_API ALvoid AL_APIENTRY alEffectfv(ALuint effect, ALenum param, ALfloat *pflVa
break;
}
}
+ else if(ALEffect->type == AL_EFFECT_DEDICATED_LOW_FREQUENCY_EFFECT ||
+ ALEffect->type == AL_EFFECT_DEDICATED_DIALOGUE)
+ {
+ switch(param)
+ {
+ case AL_DEDICATED_GAIN:
+ alEffectf(effect, param, pflValues[0]);
+ break;
+
+ default:
+ alSetError(Context, AL_INVALID_ENUM);
+ break;
+ }
+ }
else
alSetError(Context, AL_INVALID_ENUM);
}
@@ -1176,6 +1209,20 @@ AL_API ALvoid AL_APIENTRY alGetEffectf(ALuint effect, ALenum param, ALfloat *pfl
break;
}
}
+ else if(ALEffect->type == AL_EFFECT_DEDICATED_LOW_FREQUENCY_EFFECT ||
+ ALEffect->type == AL_EFFECT_DEDICATED_DIALOGUE)
+ {
+ switch(param)
+ {
+ case AL_DEDICATED_GAIN:
+ *pflValue = ALEffect->Dedicated.Gain;
+ break;
+
+ default:
+ alSetError(Context, AL_INVALID_ENUM);
+ break;
+ }
+ }
else
alSetError(Context, AL_INVALID_ENUM);
}
@@ -1295,6 +1342,20 @@ AL_API ALvoid AL_APIENTRY alGetEffectfv(ALuint effect, ALenum param, ALfloat *pf
break;
}
}
+ else if(ALEffect->type == AL_EFFECT_DEDICATED_LOW_FREQUENCY_EFFECT ||
+ ALEffect->type == AL_EFFECT_DEDICATED_DIALOGUE)
+ {
+ switch(param)
+ {
+ case AL_DEDICATED_GAIN:
+ alGetEffectf(effect, param, pflValues);
+ break;
+
+ default:
+ alSetError(Context, AL_INVALID_ENUM);
+ break;
+ }
+ }
else
alSetError(Context, AL_INVALID_ENUM);
}
@@ -1372,5 +1433,9 @@ static void InitEffectParams(ALeffect *effect, ALenum type)
effect->Modulator.HighPassCutoff = AL_RING_MODULATOR_DEFAULT_HIGHPASS_CUTOFF;
effect->Modulator.Waveform = AL_RING_MODULATOR_DEFAULT_WAVEFORM;
break;
+ case AL_EFFECT_DEDICATED_LOW_FREQUENCY_EFFECT:
+ case AL_EFFECT_DEDICATED_DIALOGUE:
+ effect->Dedicated.Gain = 1.0f;
+ break;
}
}
diff --git a/OpenAL32/alExtension.c b/OpenAL32/alExtension.c
index 0febf225..59ca48aa 100644
--- a/OpenAL32/alExtension.c
+++ b/OpenAL32/alExtension.c
@@ -211,6 +211,8 @@ static const ALenums enumeration[] = {
{ "AL_EFFECT_COMPRESSOR", AL_EFFECT_COMPRESSOR },
{ "AL_EFFECT_EQUALIZER", AL_EFFECT_EQUALIZER },
#endif
+ { "AL_EFFECT_DEDICATED_LOW_FREQUENCY_EFFECT",AL_EFFECT_DEDICATED_LOW_FREQUENCY_EFFECT},
+ { "AL_EFFECT_DEDICATED_DIALOGUE", AL_EFFECT_DEDICATED_DIALOGUE },
// Reverb params
{ "AL_REVERB_DENSITY", AL_REVERB_DENSITY },
@@ -264,6 +266,9 @@ static const ALenums enumeration[] = {
{ "AL_RING_MODULATOR_HIGHPASS_CUTOFF", AL_RING_MODULATOR_HIGHPASS_CUTOFF },
{ "AL_RING_MODULATOR_WAVEFORM", AL_RING_MODULATOR_WAVEFORM },
+ // Dedicated Dialogue/LFE params
+ { "AL_DEDICATED_GAIN", AL_DEDICATED_GAIN },
+
// Default
{ NULL, (ALenum)0 }