aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2008-02-06 22:18:50 -0800
committerChris Robinson <[email protected]>2008-02-06 22:18:50 -0800
commitb4ffdfab81827626a3da2882218d401fd83cf375 (patch)
treeae5a0cc574ca67c5b0a6f77c7f4ea7ee32ece8de
parent1ea4aac799b1751dc0616259ed9c167152da72c7 (diff)
Add an option for duplicating stereo sources on the back speakers
-rw-r--r--Alc/ALc.c8
-rw-r--r--Alc/ALu.c23
-rw-r--r--OpenAL32/Include/alu.h2
-rw-r--r--alsoftrc.sample8
4 files changed, 34 insertions, 7 deletions
diff --git a/Alc/ALc.c b/Alc/ALc.c
index b485ec2e..a21b90db 100644
--- a/Alc/ALc.c
+++ b/Alc/ALc.c
@@ -201,7 +201,7 @@ static void InitAL(void)
if(!done)
{
int i;
- const char *devs;
+ const char *devs, *str;
InitializeCriticalSection(&_alMutex);
ALTHUNK_INIT();
@@ -250,6 +250,12 @@ static void InitAL(void)
for(i = 0;BackendList[i].Init;i++)
BackendList[i].Init(&BackendList[i].Funcs);
done = 1;
+
+ str = GetConfigValue(NULL, "stereodup", "false");
+ DuplicateStereo = (strcasecmp(str, "true") == 0 ||
+ strcasecmp(str, "yes") == 0 ||
+ strcasecmp(str, "on") == 0 ||
+ atoi(str) != 0);
}
}
diff --git a/Alc/ALu.c b/Alc/ALu.c
index 79603425..756dce20 100644
--- a/Alc/ALu.c
+++ b/Alc/ALu.c
@@ -82,6 +82,8 @@ enum {
OUTPUTCHANNELS
};
+ALboolean DuplicateStereo = AL_FALSE;
+
/* NOTE: The AL_FORMAT_REAR* enums aren't handled here be cause they're
* converted to AL_FORMAT_QUAD* when loaded */
__inline ALuint aluBytesFromFormat(ALenum format)
@@ -752,14 +754,15 @@ ALvoid aluMixData(ALCcontext *ALContext,ALvoid *buffer,ALsizei size,ALenum forma
}
else
{
+ ALfloat samp1, samp2;
//First order interpolator (front left)
- value = (ALfloat)((ALshort)(((Data[k*Channels ]*((1L<<FRACTIONBITS)-fraction))+(Data[(k+1)*Channels ]*(fraction)))>>FRACTIONBITS));
- DryBuffer[j][FRONT_LEFT] += value*DrySend[FRONT_LEFT];
- WetBuffer[j][FRONT_LEFT] += value*WetSend[FRONT_LEFT];
+ samp1 = (ALfloat)((ALshort)(((Data[k*Channels ]*((1L<<FRACTIONBITS)-fraction))+(Data[(k+1)*Channels ]*(fraction)))>>FRACTIONBITS));
+ DryBuffer[j][FRONT_LEFT] += samp1*DrySend[FRONT_LEFT];
+ WetBuffer[j][FRONT_LEFT] += samp1*WetSend[FRONT_LEFT];
//First order interpolator (front right)
- value = (ALfloat)((ALshort)(((Data[k*Channels+1]*((1L<<FRACTIONBITS)-fraction))+(Data[(k+1)*Channels+1]*(fraction)))>>FRACTIONBITS));
- DryBuffer[j][FRONT_RIGHT] += value*DrySend[FRONT_RIGHT];
- WetBuffer[j][FRONT_RIGHT] += value*WetSend[FRONT_RIGHT];
+ samp2 = (ALfloat)((ALshort)(((Data[k*Channels+1]*((1L<<FRACTIONBITS)-fraction))+(Data[(k+1)*Channels+1]*(fraction)))>>FRACTIONBITS));
+ DryBuffer[j][FRONT_RIGHT] += samp2*DrySend[FRONT_RIGHT];
+ WetBuffer[j][FRONT_RIGHT] += samp2*WetSend[FRONT_RIGHT];
if(Channels >= 4)
{
int i = 2;
@@ -803,6 +806,14 @@ ALvoid aluMixData(ALCcontext *ALContext,ALvoid *buffer,ALsizei size,ALenum forma
i++;
}
}
+ else if(DuplicateStereo)
+ {
+ //Duplicate stereo channels on the back speakers
+ DryBuffer[j][BACK_LEFT] += samp1*DrySend[BACK_LEFT];
+ WetBuffer[j][BACK_LEFT] += samp1*WetSend[BACK_LEFT];
+ DryBuffer[j][BACK_RIGHT] += samp2*DrySend[BACK_RIGHT];
+ WetBuffer[j][BACK_RIGHT] += samp2*WetSend[BACK_RIGHT];
+ }
}
DataPosFrac += increment;
j++;
diff --git a/OpenAL32/Include/alu.h b/OpenAL32/Include/alu.h
index d43e0127..6fab1fae 100644
--- a/OpenAL32/Include/alu.h
+++ b/OpenAL32/Include/alu.h
@@ -8,6 +8,8 @@
extern "C" {
#endif
+extern ALboolean DuplicateStereo;
+
__inline ALuint aluBytesFromFormat(ALenum format);
__inline ALuint aluChannelsFromFormat(ALenum format);
ALvoid aluMixData(ALCcontext *context,ALvoid *buffer,ALsizei size,ALenum format);
diff --git a/alsoftrc.sample b/alsoftrc.sample
index c3bb9e83..8eaa0f4f 100644
--- a/alsoftrc.sample
+++ b/alsoftrc.sample
@@ -44,6 +44,14 @@ sources = 256 # Sets the maximum number of allocatable sources. Lower values
# may help for systems with apps that try to play more sounds
# than the CPU can handle. Default is 256
+stereodup = # Sets whether to duplicate stereo sounds on the rear speakers for
+ # 4+ channel output. This can make stereo sources substantially
+ # louder than mono or even 4+ channel sources, but provides a
+ # "fuller" playback quality. True, yes, on, and non-0 values will
+ # duplicate stereo sources. 0 and anything else will cause stereo
+ # sounds to only play out the front speakers.
+ # Default is false
+
drivers = # Sets the backend driver list order, comma-seperated. Unknown
# backends and duplicated names are ignored, and unlisted backends
# won't be considered for use. An empty list means the default.