From dcac0de44ce1856fea0ff2d8d71feb2346aa911c Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Wed, 26 Dec 2007 17:38:42 -0800 Subject: Allow empty device specifiers when opening; treat them like NULL --- Alc/ALc.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'Alc') diff --git a/Alc/ALc.c b/Alc/ALc.c index b4ec8e9f..fa591174 100644 --- a/Alc/ALc.c +++ b/Alc/ALc.c @@ -409,6 +409,9 @@ ALCAPI ALCdevice* ALCAPIENTRY alcCaptureOpenDevice(const ALCchar *deviceName, AL InitAL(); + if(deviceName && !deviceName[0]) + deviceName = NULL; + pDevice = malloc(sizeof(ALCdevice)); if (pDevice) { @@ -1034,6 +1037,9 @@ ALCAPI ALCdevice* ALCAPIENTRY alcOpenDevice(const ALCchar *deviceName) InitAL(); + if(deviceName && !deviceName[0]) + deviceName = NULL; + device = malloc(sizeof(ALCdevice)); if (device) { -- cgit v1.2.3 From ab8d342df06fdfcc1b630e318e121bcfb6a1cdfa Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Wed, 26 Dec 2007 23:01:22 -0800 Subject: Allow 5.1 channel output This doesn't use the center or LFE channel in spatial calculations, however --- Alc/ALu.c | 31 +++++++++++++++++++++++++++++-- OpenAL32/Include/alMain.h | 4 +++- OpenAL32/Include/alu.h | 2 +- OpenAL32/alExtension.c | 2 ++ 4 files changed, 35 insertions(+), 4 deletions(-) (limited to 'Alc') diff --git a/Alc/ALu.c b/Alc/ALu.c index 87764592..3e8ddd89 100644 --- a/Alc/ALu.c +++ b/Alc/ALu.c @@ -59,11 +59,13 @@ __inline ALuint aluBytesFromFormat(ALenum format) case AL_FORMAT_MONO8: case AL_FORMAT_STEREO8: case AL_FORMAT_QUAD8: + case AL_FORMAT_51CHN8: return 1; case AL_FORMAT_MONO16: case AL_FORMAT_STEREO16: case AL_FORMAT_QUAD16: + case AL_FORMAT_51CHN16: return 2; default: @@ -87,6 +89,10 @@ __inline ALuint aluChannelsFromFormat(ALenum format) case AL_FORMAT_QUAD16: return 4; + case AL_FORMAT_51CHN8: + case AL_FORMAT_51CHN16: + return 6; + default: return 0; } @@ -340,6 +346,9 @@ static ALvoid CalcSourceParams(ALCcontext *ALContext, ALsource *ALSource, break; case AL_FORMAT_QUAD8: case AL_FORMAT_QUAD16: + /* TODO: Add center/lfe channel in spatial calculations? */ + case AL_FORMAT_51CHN8: + case AL_FORMAT_51CHN16: // Apply a scalar so each individual speaker has more weight PanningLR = 0.5f + (0.5f*Position[0]*1.41421356f); PanningLR = __min(1.0f, PanningLR); @@ -367,10 +376,14 @@ static ALvoid CalcSourceParams(ALCcontext *ALContext, ALsource *ALSource, drysend[1] = SourceVolume * 1.0f * ListenerGain; drysend[2] = SourceVolume * 1.0f * ListenerGain; drysend[3] = SourceVolume * 1.0f * ListenerGain; + drysend[4] = SourceVolume * 1.0f * ListenerGain; + drysend[5] = SourceVolume * 1.0f * ListenerGain; wetsend[0] = SourceVolume * 0.0f * ListenerGain; wetsend[1] = SourceVolume * 0.0f * ListenerGain; wetsend[2] = SourceVolume * 0.0f * ListenerGain; wetsend[3] = SourceVolume * 0.0f * ListenerGain; + wetsend[4] = SourceVolume * 0.0f * ListenerGain; + wetsend[5] = SourceVolume * 0.0f * ListenerGain; pitch[0] = Pitch; } @@ -380,8 +393,8 @@ ALvoid aluMixData(ALCcontext *ALContext,ALvoid *buffer,ALsizei size,ALenum forma { static float DryBuffer[BUFFERSIZE][OUTPUTCHANNELS]; static float WetBuffer[BUFFERSIZE][OUTPUTCHANNELS]; - ALfloat DrySend[OUTPUTCHANNELS] = { 0.0f, 0.0f, 0.0f, 0.0f }; - ALfloat WetSend[OUTPUTCHANNELS] = { 0.0f, 0.0f, 0.0f, 0.0f }; + ALfloat DrySend[OUTPUTCHANNELS] = { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f }; + ALfloat WetSend[OUTPUTCHANNELS] = { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f }; ALuint BlockAlign,BufferSize; ALuint DataSize=0,DataPosInt=0,DataPosFrac=0; ALuint Channels,Bits,Frequency,ulExtraSamples; @@ -641,6 +654,13 @@ ALvoid aluMixData(ALCcontext *ALContext,ALvoid *buffer,ALsizei size,ALenum forma buffer = ((ALubyte*)buffer) + 1; } break; + case AL_FORMAT_51CHN8: + for(i = 0;i < SamplesToDo*6;i++) + { + *((ALubyte*)buffer) = (ALubyte)((aluF2S(DryBuffer[i/6][i%6]+WetBuffer[i/6][i%6])>>8)+128); + buffer = ((ALubyte*)buffer) + 1; + } + break; case AL_FORMAT_MONO16: for(i = 0;i < SamplesToDo;i++) { @@ -663,6 +683,13 @@ ALvoid aluMixData(ALCcontext *ALContext,ALvoid *buffer,ALsizei size,ALenum forma buffer = ((ALshort*)buffer) + 1; } break; + case AL_FORMAT_51CHN16: + for(i = 0;i < SamplesToDo*6;i++) + { + *((ALshort*)buffer) = aluF2S(DryBuffer[i/6][i%6]+WetBuffer[i/6][i%6]); + buffer = ((ALshort*)buffer) + 1; + } + break; } size -= SamplesToDo; diff --git a/OpenAL32/Include/alMain.h b/OpenAL32/Include/alMain.h index 1f62b535..30dd068f 100644 --- a/OpenAL32/Include/alMain.h +++ b/OpenAL32/Include/alMain.h @@ -92,9 +92,11 @@ extern char _alDebug[256]; #define AL_FORMAT_MONO_IMA4 0x1300 #define AL_FORMAT_STEREO_IMA4 0x1301 // These are from AL_EXT_MCFORMATS, which we don't support yet but the mixer -// can use 4-channel formats +// can use the extra formats #define AL_FORMAT_QUAD8 0x1204 #define AL_FORMAT_QUAD16 0x1205 +#define AL_FORMAT_51CHN8 0x120A +#define AL_FORMAT_51CHN16 0x120B #define SWMIXER_OUTPUT_RATE 44100 //#define OUTPUT_BUFFER_SIZE (32768*SWMIXER_OUTPUT_RATE/22050) diff --git a/OpenAL32/Include/alu.h b/OpenAL32/Include/alu.h index e4fe0dc3..ecf32e5c 100644 --- a/OpenAL32/Include/alu.h +++ b/OpenAL32/Include/alu.h @@ -5,7 +5,7 @@ #define FRACTIONBITS 14 #define FRACTIONMASK ((1L< Date: Wed, 26 Dec 2007 23:29:32 -0800 Subject: Don't check explicitly against formats, but rather their byte/channel count --- Alc/ALu.c | 14 +++++--------- Alc/alsa.c | 10 +++------- Alc/dsound.c | 2 +- Alc/oss.c | 20 ++++++-------------- 4 files changed, 15 insertions(+), 31 deletions(-) (limited to 'Alc') diff --git a/Alc/ALu.c b/Alc/ALu.c index 3e8ddd89..b5af500b 100644 --- a/Alc/ALu.c +++ b/Alc/ALu.c @@ -327,28 +327,24 @@ static ALvoid CalcSourceParams(ALCcontext *ALContext, ALsource *ALSource, //6. Convert normalized position into pannings, then into channel volumes aluNormalize(Position); - switch(OutputFormat) + switch(aluChannelsFromFormat(OutputFormat)) { - case AL_FORMAT_MONO8: - case AL_FORMAT_MONO16: + case 1: drysend[0] = ConeVolume * ListenerGain * DryMix * aluSqrt(1.0f); //Direct drysend[1] = ConeVolume * ListenerGain * DryMix * aluSqrt(1.0f); //Direct wetsend[0] = ListenerGain * WetMix * aluSqrt(1.0f); //Room wetsend[1] = ListenerGain * WetMix * aluSqrt(1.0f); //Room break; - case AL_FORMAT_STEREO8: - case AL_FORMAT_STEREO16: + case 2: PanningLR = 0.5f + 0.5f*Position[0]; drysend[0] = ConeVolume * ListenerGain * DryMix * aluSqrt(1.0f-PanningLR); //L Direct drysend[1] = ConeVolume * ListenerGain * DryMix * aluSqrt( PanningLR); //R Direct wetsend[0] = ListenerGain * WetMix * aluSqrt(1.0f-PanningLR); //L Room wetsend[1] = ListenerGain * WetMix * aluSqrt( PanningLR); //R Room break; - case AL_FORMAT_QUAD8: - case AL_FORMAT_QUAD16: + case 4: /* TODO: Add center/lfe channel in spatial calculations? */ - case AL_FORMAT_51CHN8: - case AL_FORMAT_51CHN16: + case 6: // Apply a scalar so each individual speaker has more weight PanningLR = 0.5f + (0.5f*Position[0]*1.41421356f); PanningLR = __min(1.0f, PanningLR); diff --git a/Alc/alsa.c b/Alc/alsa.c index 2a46eff0..a6035d46 100644 --- a/Alc/alsa.c +++ b/Alc/alsa.c @@ -324,16 +324,12 @@ open_alsa: return ALC_FALSE; } - switch(device->Format) + switch(aluBytesFromFormat(device->Format)) { - case AL_FORMAT_MONO8: - case AL_FORMAT_STEREO8: - case AL_FORMAT_QUAD8: + case 1: data->format = SND_PCM_FORMAT_U8; break; - case AL_FORMAT_MONO16: - case AL_FORMAT_STEREO16: - case AL_FORMAT_QUAD16: + case 2: data->format = SND_PCM_FORMAT_S16; break; default: diff --git a/Alc/dsound.c b/Alc/dsound.c index a2b036a1..90a422a2 100644 --- a/Alc/dsound.c +++ b/Alc/dsound.c @@ -129,7 +129,7 @@ static ALCboolean DSoundOpenPlayback(ALCdevice *device, const ALCchar *deviceNam memset(&OutputType, 0, sizeof(WAVEFORMATEX)); OutputType.wFormatTag = WAVE_FORMAT_PCM; OutputType.nChannels = device->Channels; - OutputType.wBitsPerSample = (((device->Format==AL_FORMAT_MONO16)||(device->Format==AL_FORMAT_STEREO16)||(device->Format==AL_FORMAT_QUAD16))?16:8); + OutputType.wBitsPerSample = aluBytesFromFormat(device->Format) * 8; OutputType.nBlockAlign = OutputType.nChannels*OutputType.wBitsPerSample/8; OutputType.nSamplesPerSec = device->Frequency; OutputType.nAvgBytesPerSec = OutputType.nSamplesPerSec*OutputType.nBlockAlign; diff --git a/Alc/oss.c b/Alc/oss.c index de8f6e43..a63acb9b 100644 --- a/Alc/oss.c +++ b/Alc/oss.c @@ -174,17 +174,13 @@ static ALCboolean oss_open_playback(ALCdevice *device, const ALCchar *deviceName return ALC_FALSE; } - switch(device->Format) + switch(aluBytesFromFormat(device->Format)) { - case AL_FORMAT_MONO8: - case AL_FORMAT_STEREO8: - case AL_FORMAT_QUAD8: + case 1: data->silence = 0x80; ossFormat = AFMT_U8; break; - case AL_FORMAT_MONO16: - case AL_FORMAT_STEREO16: - case AL_FORMAT_QUAD16: + case 2: data->silence = 0; ossFormat = AFMT_S16_NE; break; @@ -337,17 +333,13 @@ static ALCboolean oss_open_capture(ALCdevice *device, const ALCchar *deviceName, return ALC_FALSE; } - switch(format) + switch(aluBytesFromFormat(format)) { - case AL_FORMAT_MONO8: - case AL_FORMAT_STEREO8: - case AL_FORMAT_QUAD8: + case 1: data->silence = 0x80; ossFormat = AFMT_U8; break; - case AL_FORMAT_MONO16: - case AL_FORMAT_STEREO16: - case AL_FORMAT_QUAD16: + case 2: data->silence = 0; ossFormat = AFMT_S16_NE; break; -- cgit v1.2.3 From d90b36cf1147b0b14068db55a7510ffb0d2d2641 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Fri, 28 Dec 2007 22:14:36 -0800 Subject: Advertise AL_EXT_IMA4, since it's been supported all this time --- Alc/ALc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Alc') diff --git a/Alc/ALc.c b/Alc/ALc.c index fa591174..8c75b32c 100644 --- a/Alc/ALc.c +++ b/Alc/ALc.c @@ -357,7 +357,7 @@ static ALvoid InitContext(ALCcontext *pContext) pContext->lNumStereoSources = 1; pContext->lNumMonoSources = pContext->Device->MaxNoOfSources - pContext->lNumStereoSources; - strcpy(pContext->ExtensionList, "AL_EXT_EXPONENT_DISTANCE AL_EXT_LINEAR_DISTANCE AL_EXT_OFFSET"); + strcpy(pContext->ExtensionList, "AL_EXT_EXPONENT_DISTANCE AL_EXT_IMA4 AL_EXT_LINEAR_DISTANCE AL_EXT_OFFSET"); } -- cgit v1.2.3 From 5f8e65e09941c9c5d48e2277a8b1be1e35f04a9a Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Fri, 28 Dec 2007 22:41:14 -0800 Subject: Implement AL_EXT_FLOAT32 --- Alc/ALc.c | 2 +- Alc/ALu.c | 6 ++++++ OpenAL32/Include/alMain.h | 3 +++ OpenAL32/alBuffer.c | 28 ++++++++++++++++++++++++++++ OpenAL32/alSource.c | 9 +++++++++ 5 files changed, 47 insertions(+), 1 deletion(-) (limited to 'Alc') diff --git a/Alc/ALc.c b/Alc/ALc.c index 8c75b32c..0db68efe 100644 --- a/Alc/ALc.c +++ b/Alc/ALc.c @@ -357,7 +357,7 @@ static ALvoid InitContext(ALCcontext *pContext) pContext->lNumStereoSources = 1; pContext->lNumMonoSources = pContext->Device->MaxNoOfSources - pContext->lNumStereoSources; - strcpy(pContext->ExtensionList, "AL_EXT_EXPONENT_DISTANCE AL_EXT_IMA4 AL_EXT_LINEAR_DISTANCE AL_EXT_OFFSET"); + strcpy(pContext->ExtensionList, "AL_EXT_EXPONENT_DISTANCE AL_EXT_FLOAT32 AL_EXT_IMA4 AL_EXT_LINEAR_DISTANCE AL_EXT_OFFSET"); } diff --git a/Alc/ALu.c b/Alc/ALu.c index b5af500b..f77990a7 100644 --- a/Alc/ALu.c +++ b/Alc/ALu.c @@ -68,6 +68,10 @@ __inline ALuint aluBytesFromFormat(ALenum format) case AL_FORMAT_51CHN16: return 2; + case AL_FORMAT_MONO_FLOAT32: + case AL_FORMAT_STEREO_FLOAT32: + return 4; + default: return 0; } @@ -79,10 +83,12 @@ __inline ALuint aluChannelsFromFormat(ALenum format) { case AL_FORMAT_MONO8: case AL_FORMAT_MONO16: + case AL_FORMAT_MONO_FLOAT32: return 1; case AL_FORMAT_STEREO8: case AL_FORMAT_STEREO16: + case AL_FORMAT_STEREO_FLOAT32: return 2; case AL_FORMAT_QUAD8: diff --git a/OpenAL32/Include/alMain.h b/OpenAL32/Include/alMain.h index 30dd068f..f11f8fd9 100644 --- a/OpenAL32/Include/alMain.h +++ b/OpenAL32/Include/alMain.h @@ -89,6 +89,9 @@ extern char _alDebug[256]; } while(0) +#define AL_FORMAT_MONO_FLOAT32 0x10010 +#define AL_FORMAT_STEREO_FLOAT32 0x10011 + #define AL_FORMAT_MONO_IMA4 0x1300 #define AL_FORMAT_STEREO_IMA4 0x1301 // These are from AL_EXT_MCFORMATS, which we don't support yet but the mixer diff --git a/OpenAL32/alBuffer.c b/OpenAL32/alBuffer.c index ab5b60d8..d1a8c359 100644 --- a/OpenAL32/alBuffer.c +++ b/OpenAL32/alBuffer.c @@ -282,6 +282,10 @@ ALAPI ALvoid ALAPIENTRY alBufferData(ALuint buffer,ALenum format,const ALvoid *d LoadData(ALBuf, data, size, freq, format, AL_FORMAT_MONO16); break; + case AL_FORMAT_MONO_FLOAT32: + LoadData(ALBuf, data, size, freq, format, AL_FORMAT_MONO16); + break; + case AL_FORMAT_STEREO8: LoadData(ALBuf, data, size, freq, format, AL_FORMAT_STEREO16); break; @@ -290,6 +294,10 @@ ALAPI ALvoid ALAPIENTRY alBufferData(ALuint buffer,ALenum format,const ALvoid *d LoadData(ALBuf, data, size, freq, format, AL_FORMAT_STEREO16); break; + case AL_FORMAT_STEREO_FLOAT32: + LoadData(ALBuf, data, size, freq, format, AL_FORMAT_STEREO16); + break; + case AL_FORMAT_MONO_IMA4: // Here is where things vary: // nVidia and Apple use 64+1 samples per block => block_size=36 bytes @@ -913,6 +921,26 @@ static void LoadData(ALbuffer *ALBuf, const ALubyte *data, ALsizei size, ALuint alSetError(AL_OUT_OF_MEMORY); break; + case 4: + size /= sizeof(ALfloat); + + // Allocate 8 extra samples + ALBuf->data = realloc(ALBuf->data, (8*NewChannels + size) * (1*sizeof(ALshort))); + if (ALBuf->data) + { + for (i = 0;i < size;i++) + ALBuf->data[i] = (ALshort)(((ALfloat*)data)[i] * 32767.5f - 0.5); + memset(&(ALBuf->data[size]), 0, 16*NewChannels); + + ALBuf->format = NewFormat; + ALBuf->eOriginalFormat = OrigFormat; + ALBuf->size = size*1*sizeof(ALshort); + ALBuf->frequency = freq; + } + else + alSetError(AL_OUT_OF_MEMORY); + break; + default: assert(0); } diff --git a/OpenAL32/alSource.c b/OpenAL32/alSource.c index a06c6060..7c022e6c 100644 --- a/OpenAL32/alSource.c +++ b/OpenAL32/alSource.c @@ -1910,6 +1910,10 @@ static ALboolean GetSourceOffset(ALsource *pSource, ALenum eName, ALfloat *pflOf { *pflOffset = (ALfloat)(lBytesPlayed >> 1); } + else if (aluBytesFromFormat(eOriginalFormat) == 4) + { + *pflOffset = (ALfloat)(lBytesPlayed << 1); + } else if ((eOriginalFormat == AL_FORMAT_MONO_IMA4) || (eOriginalFormat == AL_FORMAT_STEREO_IMA4)) { @@ -2061,6 +2065,11 @@ static ALint GetByteOffset(ALsource *pSource) lByteOffset = pSource->lOffset * 2; lByteOffset -= (lByteOffset % (lChannels * 2)); } + else if (aluBytesFromFormat(pBuffer->eOriginalFormat) == 4) + { + lByteOffset = pSource->lOffset / 2; + lByteOffset -= (lByteOffset % (lChannels * 2)); + } else if ((pBuffer->eOriginalFormat == AL_FORMAT_MONO_IMA4) || (pBuffer->eOriginalFormat == AL_FORMAT_STEREO_IMA4)) { -- cgit v1.2.3 From 2e88a3d03bce05010b2f14d4615271e3462834f9 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Sun, 30 Dec 2007 01:28:25 -0800 Subject: Check for the correct ALSA driver option name --- Alc/alsa.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Alc') diff --git a/Alc/alsa.c b/Alc/alsa.c index a6035d46..a181eebd 100644 --- a/Alc/alsa.c +++ b/Alc/alsa.c @@ -269,7 +269,7 @@ static ALCboolean alsa_open_playback(ALCdevice *device, const ALCchar *deviceNam char *err; int i; - strncpy(driver, GetConfigValue("alsa", "default", "default"), sizeof(driver)-1); + strncpy(driver, GetConfigValue("alsa", "device", "default"), sizeof(driver)-1); driver[sizeof(driver)-1] = 0; if(deviceName) { -- cgit v1.2.3 From fcff17c567a0143787bd82ab4fe7ae1d69aee323 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Sun, 30 Dec 2007 02:09:39 -0800 Subject: Fallback to non-mmap access for ALSA if mmap isn't available --- Alc/alsa.c | 117 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 114 insertions(+), 3 deletions(-) (limited to 'Alc') diff --git a/Alc/alsa.c b/Alc/alsa.c index a181eebd..bef6ac99 100644 --- a/Alc/alsa.c +++ b/Alc/alsa.c @@ -36,6 +36,10 @@ typedef struct { snd_pcm_t *pcmHandle; snd_pcm_format_t format; + + ALvoid *buffer; + ALsizei size; + int killNow; ALvoid *thread; } alsa_data; @@ -63,6 +67,7 @@ MAKE_FUNC(snd_pcm_hw_params_set_rate_near); MAKE_FUNC(snd_pcm_hw_params_set_rate); MAKE_FUNC(snd_pcm_hw_params_set_buffer_size_near); MAKE_FUNC(snd_pcm_hw_params_set_buffer_size_min); +MAKE_FUNC(snd_pcm_hw_params_get_access); MAKE_FUNC(snd_pcm_hw_params); MAKE_FUNC(snd_pcm_prepare); MAKE_FUNC(snd_pcm_start); @@ -72,6 +77,7 @@ MAKE_FUNC(snd_pcm_avail_update); MAKE_FUNC(snd_pcm_areas_silence); MAKE_FUNC(snd_pcm_mmap_begin); MAKE_FUNC(snd_pcm_mmap_commit); +MAKE_FUNC(snd_pcm_writei); MAKE_FUNC(snd_pcm_drain); MAKE_FUNC(snd_pcm_info_malloc); MAKE_FUNC(snd_pcm_info_free); @@ -210,6 +216,76 @@ static ALuint ALSAProc(ALvoid *ptr) return 0; } +static ALuint ALSANoMMapProc(ALvoid *ptr) +{ + ALCdevice *pDevice = (ALCdevice*)ptr; + alsa_data *data = (alsa_data*)pDevice->ExtraData; + snd_pcm_sframes_t avail; + char *WritePtr; + int err; + + while(!data->killNow) + { + snd_pcm_state_t state = psnd_pcm_state(data->pcmHandle); + if(state == SND_PCM_STATE_XRUN) + { + err = xrun_recovery(data->pcmHandle, -EPIPE); + if (err < 0) + { + AL_PRINT("XRUN recovery failed: %s\n", psnd_strerror(err)); + break; + } + } + else if (state == SND_PCM_STATE_SUSPENDED) + { + err = xrun_recovery(data->pcmHandle, -ESTRPIPE); + if (err < 0) + { + AL_PRINT("SUSPEND recovery failed: %s\n", psnd_strerror(err)); + break; + } + } + + SuspendContext(NULL); + aluMixData(pDevice->Context, data->buffer, data->size, pDevice->Format); + ProcessContext(NULL); + + WritePtr = data->buffer; + avail = (snd_pcm_uframes_t)data->size / psnd_pcm_frames_to_bytes(data->pcmHandle, 1); + while(avail > 0) + { + int ret = psnd_pcm_writei(data->pcmHandle, WritePtr, avail); + switch (ret) + { + case -EAGAIN: + continue; + case -ESTRPIPE: + do { + ret = psnd_pcm_resume(data->pcmHandle); + } while(ret == -EAGAIN); + break; + case -EPIPE: + break; + default: + if (ret >= 0) + { + WritePtr += psnd_pcm_frames_to_bytes(data->pcmHandle, ret); + avail -= ret; + } + break; + } + if (ret < 0) + { + ret = psnd_pcm_prepare(data->pcmHandle); + if(ret < 0) + break; + } + } + } + + return 0; +} + static void fill_silence(snd_pcm_t *pcmHandle, snd_pcm_format_t alsaFormat, int channels) { const snd_pcm_channel_area_t *areas = NULL; @@ -263,6 +339,7 @@ static ALCboolean alsa_open_playback(ALCdevice *device, const ALCchar *deviceNam { snd_pcm_uframes_t bufferSizeInFrames; snd_pcm_hw_params_t *p = NULL; + snd_pcm_access_t access; unsigned int periods; alsa_data *data; char driver[64]; @@ -347,7 +424,8 @@ open_alsa: /* start with the largest configuration space possible */ if(!(ok(psnd_pcm_hw_params_any(data->pcmHandle, p), "any") && /* set interleaved access */ - ok(psnd_pcm_hw_params_set_access(data->pcmHandle, p, SND_PCM_ACCESS_MMAP_INTERLEAVED), "set access") && + (ok(psnd_pcm_hw_params_set_access(data->pcmHandle, p, SND_PCM_ACCESS_MMAP_INTERLEAVED), "set access") || + ok(psnd_pcm_hw_params_set_access(data->pcmHandle, p, SND_PCM_ACCESS_RW_INTERLEAVED), "set access"))&& /* set format (implicitly sets sample bits) */ ok(psnd_pcm_hw_params_set_format(data->pcmHandle, p, data->format), "set format") && /* set channels (implicitly sets frame bits) */ @@ -368,6 +446,16 @@ open_alsa: return ALC_FALSE; } #undef ok + + if((i=psnd_pcm_hw_params_get_access(p, &access)) < 0) + { + AL_PRINT("get_access failed: %s\n", psnd_strerror(i)); + psnd_pcm_hw_params_free(p); + psnd_pcm_close(data->pcmHandle); + free(data); + return ALC_FALSE; + } + psnd_pcm_hw_params_free(p); device->MaxNoOfSources = 256; @@ -378,26 +466,46 @@ open_alsa: { AL_PRINT("prepare error: %s\n", psnd_strerror(i)); psnd_pcm_close(data->pcmHandle); + free(data->buffer); free(data); return ALC_FALSE; } - fill_silence(data->pcmHandle, data->format, device->Channels); + data->size = psnd_pcm_frames_to_bytes(data->pcmHandle, bufferSizeInFrames); + if(access == SND_PCM_ACCESS_RW_INTERLEAVED) + { + data->buffer = malloc(data->size); + if(!data->buffer) + { + AL_PRINT("buffer malloc failed\n"); + psnd_pcm_close(data->pcmHandle); + free(data); + return ALC_FALSE; + } + } + else + fill_silence(data->pcmHandle, data->format, device->Channels); + i = psnd_pcm_start(data->pcmHandle); if(i < 0) { AL_PRINT("start error: %s\n", psnd_strerror(i)); psnd_pcm_close(data->pcmHandle); + free(data->buffer); free(data); return ALC_FALSE; } device->ExtraData = data; - data->thread = StartThread(ALSAProc, device); + if(access == SND_PCM_ACCESS_RW_INTERLEAVED) + data->thread = StartThread(ALSANoMMapProc, device); + else + data->thread = StartThread(ALSAProc, device); if(data->thread == NULL) { psnd_pcm_close(data->pcmHandle); device->ExtraData = NULL; + free(data->buffer); free(data); return ALC_FALSE; } @@ -412,6 +520,7 @@ static void alsa_close_playback(ALCdevice *device) StopThread(data->thread); psnd_pcm_close(data->pcmHandle); + free(data->buffer); free(data); device->ExtraData = NULL; } @@ -686,6 +795,7 @@ LOAD_FUNC(snd_pcm_hw_params_set_rate_near); LOAD_FUNC(snd_pcm_hw_params_set_rate); LOAD_FUNC(snd_pcm_hw_params_set_buffer_size_near); LOAD_FUNC(snd_pcm_hw_params_set_buffer_size_min); +LOAD_FUNC(snd_pcm_hw_params_get_access); LOAD_FUNC(snd_pcm_hw_params); LOAD_FUNC(snd_pcm_prepare); LOAD_FUNC(snd_pcm_start); @@ -695,6 +805,7 @@ LOAD_FUNC(snd_pcm_avail_update); LOAD_FUNC(snd_pcm_areas_silence); LOAD_FUNC(snd_pcm_mmap_begin); LOAD_FUNC(snd_pcm_mmap_commit); +LOAD_FUNC(snd_pcm_writei); LOAD_FUNC(snd_pcm_drain); LOAD_FUNC(snd_pcm_info_malloc); -- cgit v1.2.3 From 927763902f13e9f28f0093df3579946183fef83e Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Mon, 31 Dec 2007 00:05:29 -0800 Subject: Loop per frame, not per sample, when writing the output buffer --- Alc/ALu.c | 58 ++++++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 38 insertions(+), 20 deletions(-) (limited to 'Alc') diff --git a/Alc/ALu.c b/Alc/ALu.c index f77990a7..038bf5d3 100644 --- a/Alc/ALu.c +++ b/Alc/ALu.c @@ -638,58 +638,76 @@ ALvoid aluMixData(ALCcontext *ALContext,ALvoid *buffer,ALsizei size,ALenum forma case AL_FORMAT_MONO8: for(i = 0;i < SamplesToDo;i++) { - *((ALubyte*)buffer) = (ALubyte)((aluF2S(DryBuffer[i][0]+DryBuffer[i][1]+WetBuffer[i][0]+WetBuffer[i][1])>>8)+128); + ((ALubyte*)buffer)[0] = (ALubyte)((aluF2S(DryBuffer[i][0]+DryBuffer[i][1]+WetBuffer[i][0]+WetBuffer[i][1])>>8)+128); buffer = ((ALubyte*)buffer) + 1; } break; case AL_FORMAT_STEREO8: - for(i = 0;i < SamplesToDo*2;i++) + for(i = 0;i < SamplesToDo;i++) { - *((ALubyte*)buffer) = (ALubyte)((aluF2S(DryBuffer[i>>1][i&1]+WetBuffer[i>>1][i&1])>>8)+128); - buffer = ((ALubyte*)buffer) + 1; + ((ALubyte*)buffer)[0] = (ALubyte)((aluF2S(DryBuffer[i][0]+WetBuffer[i][0])>>8)+128); + ((ALubyte*)buffer)[1] = (ALubyte)((aluF2S(DryBuffer[i][1]+WetBuffer[i][1])>>8)+128); + buffer = ((ALubyte*)buffer) + 2; } break; case AL_FORMAT_QUAD8: - for(i = 0;i < SamplesToDo*4;i++) + for(i = 0;i < SamplesToDo;i++) { - *((ALubyte*)buffer) = (ALubyte)((aluF2S(DryBuffer[i>>2][i&3]+WetBuffer[i>>2][i&3])>>8)+128); - buffer = ((ALubyte*)buffer) + 1; + ((ALubyte*)buffer)[0] = (ALubyte)((aluF2S(DryBuffer[i][0]+WetBuffer[i][0])>>8)+128); + ((ALubyte*)buffer)[1] = (ALubyte)((aluF2S(DryBuffer[i][1]+WetBuffer[i][1])>>8)+128); + ((ALubyte*)buffer)[2] = (ALubyte)((aluF2S(DryBuffer[i][2]+WetBuffer[i][2])>>8)+128); + ((ALubyte*)buffer)[3] = (ALubyte)((aluF2S(DryBuffer[i][3]+WetBuffer[i][3])>>8)+128); + buffer = ((ALubyte*)buffer) + 4; } break; case AL_FORMAT_51CHN8: - for(i = 0;i < SamplesToDo*6;i++) + for(i = 0;i < SamplesToDo;i++) { - *((ALubyte*)buffer) = (ALubyte)((aluF2S(DryBuffer[i/6][i%6]+WetBuffer[i/6][i%6])>>8)+128); - buffer = ((ALubyte*)buffer) + 1; + ((ALubyte*)buffer)[0] = (ALubyte)((aluF2S(DryBuffer[i][0]+WetBuffer[i][0])>>8)+128); + ((ALubyte*)buffer)[1] = (ALubyte)((aluF2S(DryBuffer[i][1]+WetBuffer[i][1])>>8)+128); + ((ALubyte*)buffer)[2] = (ALubyte)((aluF2S(DryBuffer[i][2]+WetBuffer[i][2])>>8)+128); + ((ALubyte*)buffer)[3] = (ALubyte)((aluF2S(DryBuffer[i][3]+WetBuffer[i][3])>>8)+128); + ((ALubyte*)buffer)[4] = (ALubyte)((aluF2S(DryBuffer[i][4]+WetBuffer[i][4])>>8)+128); + ((ALubyte*)buffer)[5] = (ALubyte)((aluF2S(DryBuffer[i][5]+WetBuffer[i][5])>>8)+128); + buffer = ((ALubyte*)buffer) + 6; } break; case AL_FORMAT_MONO16: for(i = 0;i < SamplesToDo;i++) { - *((ALshort*)buffer) = aluF2S(DryBuffer[i][0]+DryBuffer[i][1]+WetBuffer[i][0]+WetBuffer[i][1]); + ((ALshort*)buffer)[0] = aluF2S(DryBuffer[i][0]+DryBuffer[i][1]+WetBuffer[i][0]+WetBuffer[i][1]); buffer = ((ALshort*)buffer) + 1; } break; case AL_FORMAT_STEREO16: default: - for(i = 0;i < SamplesToDo*2;i++) + for(i = 0;i < SamplesToDo;i++) { - *((ALshort*)buffer) = aluF2S(DryBuffer[i>>1][i&1]+WetBuffer[i>>1][i&1]); - buffer = ((ALshort*)buffer) + 1; + ((ALshort*)buffer)[0] = aluF2S(DryBuffer[i][0]+WetBuffer[i][0]); + ((ALshort*)buffer)[1] = aluF2S(DryBuffer[i][1]+WetBuffer[i][1]); + buffer = ((ALshort*)buffer) + 2; } break; case AL_FORMAT_QUAD16: - for(i = 0;i < SamplesToDo*4;i++) + for(i = 0;i < SamplesToDo;i++) { - *((ALshort*)buffer) = aluF2S(DryBuffer[i>>2][i&3]+WetBuffer[i>>2][i&3]); - buffer = ((ALshort*)buffer) + 1; + ((ALshort*)buffer)[0] = aluF2S(DryBuffer[i][0]+WetBuffer[i][0]); + ((ALshort*)buffer)[1] = aluF2S(DryBuffer[i][1]+WetBuffer[i][1]); + ((ALshort*)buffer)[2] = aluF2S(DryBuffer[i][2]+WetBuffer[i][2]); + ((ALshort*)buffer)[3] = aluF2S(DryBuffer[i][3]+WetBuffer[i][3]); + buffer = ((ALshort*)buffer) + 4; } break; case AL_FORMAT_51CHN16: - for(i = 0;i < SamplesToDo*6;i++) + for(i = 0;i < SamplesToDo;i++) { - *((ALshort*)buffer) = aluF2S(DryBuffer[i/6][i%6]+WetBuffer[i/6][i%6]); - buffer = ((ALshort*)buffer) + 1; + ((ALshort*)buffer)[0] = aluF2S(DryBuffer[i][0]+WetBuffer[i][0]); + ((ALshort*)buffer)[1] = aluF2S(DryBuffer[i][1]+WetBuffer[i][1]); + ((ALshort*)buffer)[2] = aluF2S(DryBuffer[i][2]+WetBuffer[i][2]); + ((ALshort*)buffer)[3] = aluF2S(DryBuffer[i][3]+WetBuffer[i][3]); + ((ALshort*)buffer)[4] = aluF2S(DryBuffer[i][4]+WetBuffer[i][4]); + ((ALshort*)buffer)[5] = aluF2S(DryBuffer[i][5]+WetBuffer[i][5]); + buffer = ((ALshort*)buffer) + 6; } break; } -- cgit v1.2.3 From f7ef5c169bff8366bb5ea4b245111ace5669109e Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Mon, 31 Dec 2007 00:08:07 -0800 Subject: Don't default to AL_FORMAT_STEREO16 when writing to the output buffer --- Alc/ALu.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'Alc') diff --git a/Alc/ALu.c b/Alc/ALu.c index 038bf5d3..f3cd24f5 100644 --- a/Alc/ALu.c +++ b/Alc/ALu.c @@ -680,7 +680,6 @@ ALvoid aluMixData(ALCcontext *ALContext,ALvoid *buffer,ALsizei size,ALenum forma } break; case AL_FORMAT_STEREO16: - default: for(i = 0;i < SamplesToDo;i++) { ((ALshort*)buffer)[0] = aluF2S(DryBuffer[i][0]+WetBuffer[i][0]); @@ -710,6 +709,9 @@ ALvoid aluMixData(ALCcontext *ALContext,ALvoid *buffer,ALsizei size,ALenum forma buffer = ((ALshort*)buffer) + 6; } break; + + default: + break; } size -= SamplesToDo; -- cgit v1.2.3 From e82c27ab0402fae11811a34b5b44ba4462f35f4e Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Mon, 31 Dec 2007 01:09:57 -0800 Subject: Fix includes so alMain.h doesn't include so much by itself --- Alc/ALc.c | 3 +++ Alc/ALu.c | 4 ++++ OpenAL32/Include/alMain.h | 10 ++-------- OpenAL32/alBuffer.c | 1 + OpenAL32/alSource.c | 2 ++ 5 files changed, 12 insertions(+), 8 deletions(-) (limited to 'Alc') diff --git a/Alc/ALc.c b/Alc/ALc.c index 0db68efe..376a3ce8 100644 --- a/Alc/ALc.c +++ b/Alc/ALc.c @@ -29,6 +29,9 @@ #include "alMain.h" #include "AL/al.h" #include "AL/alc.h" +#include "alThunk.h" +#include "alSource.h" +#include "alExtension.h" /////////////////////////////////////////////////////// // DEBUG INFORMATION diff --git a/Alc/ALu.c b/Alc/ALu.c index f3cd24f5..b19bd518 100644 --- a/Alc/ALu.c +++ b/Alc/ALu.c @@ -26,6 +26,10 @@ #include "alMain.h" #include "AL/al.h" #include "AL/alc.h" +#include "alSource.h" +#include "alBuffer.h" +#include "alThunk.h" +#include "alListener.h" #if defined(HAVE_STDINT_H) #include diff --git a/OpenAL32/Include/alMain.h b/OpenAL32/Include/alMain.h index c6738868..f2beb30f 100644 --- a/OpenAL32/Include/alMain.h +++ b/OpenAL32/Include/alMain.h @@ -56,13 +56,7 @@ static inline void DeleteCriticalSection(CRITICAL_SECTION *cs) #define max(x,y) (((x)>(y))?(x):(y)) #endif -#include "alBuffer.h" -#include "alError.h" -#include "alExtension.h" #include "alListener.h" -#include "alSource.h" -#include "alState.h" -#include "alThunk.h" #ifdef __cplusplus extern "C" @@ -156,8 +150,8 @@ struct ALCcontext_struct { ALlistener Listener; - ALsource *Source; - ALuint SourceCount; + struct ALsource *Source; + ALuint SourceCount; ALenum LastError; ALboolean InUse; diff --git a/OpenAL32/alBuffer.c b/OpenAL32/alBuffer.c index 33db7cfb..13b98b21 100644 --- a/OpenAL32/alBuffer.c +++ b/OpenAL32/alBuffer.c @@ -27,6 +27,7 @@ #include "AL/alc.h" #include "alError.h" #include "alBuffer.h" +#include "alThunk.h" static void LoadData(ALbuffer *ALBuf, const ALubyte *data, ALsizei size, ALuint freq, ALenum OrigFormat, ALenum NewFormat); diff --git a/OpenAL32/alSource.c b/OpenAL32/alSource.c index 7c022e6c..44cd8b41 100644 --- a/OpenAL32/alSource.c +++ b/OpenAL32/alSource.c @@ -26,6 +26,8 @@ #include "AL/alc.h" #include "alError.h" #include "alSource.h" +#include "alBuffer.h" +#include "alThunk.h" static ALvoid InitSourceParams(ALsource *pSource); static ALboolean GetSourceOffset(ALsource *pSource, ALenum eName, ALfloat *pflOffset); -- cgit v1.2.3 From 7a99b1fa32341460eb3144e860e6bd23467ae919 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Mon, 31 Dec 2007 01:16:13 -0800 Subject: Make some defines local to ALu.c --- Alc/ALu.c | 6 ++++++ OpenAL32/Include/alu.h | 6 ------ 2 files changed, 6 insertions(+), 6 deletions(-) (limited to 'Alc') diff --git a/Alc/ALu.c b/Alc/ALu.c index b19bd518..bb2bbd0a 100644 --- a/Alc/ALu.c +++ b/Alc/ALu.c @@ -56,6 +56,12 @@ typedef long long ALint64; #define __min min #endif +#define BUFFERSIZE 48000 +#define FRACTIONBITS 14 +#define FRACTIONMASK ((1L< Date: Mon, 31 Dec 2007 01:47:10 -0800 Subject: Use an enum list for dealing with channels This will make it easier to remap channels, especially the center and lfe channels --- Alc/ALu.c | 146 ++++++++++++++++++++++++++++++++++---------------------------- 1 file changed, 79 insertions(+), 67 deletions(-) (limited to 'Alc') diff --git a/Alc/ALu.c b/Alc/ALu.c index bb2bbd0a..682132e1 100644 --- a/Alc/ALu.c +++ b/Alc/ALu.c @@ -60,7 +60,17 @@ typedef long long ALint64; #define FRACTIONBITS 14 #define FRACTIONMASK ((1L<>FRACTIONBITS)); //Direct path final mix buffer and panning - DryBuffer[j][0] += value*DrySend[0]; - DryBuffer[j][1] += value*DrySend[1]; - DryBuffer[j][2] += value*DrySend[2]; - DryBuffer[j][3] += value*DrySend[3]; + DryBuffer[j][FRONT_LEFT] += value*DrySend[FRONT_LEFT]; + DryBuffer[j][FRONT_RIGHT] += value*DrySend[FRONT_RIGHT]; + DryBuffer[j][BACK_LEFT] += value*DrySend[BACK_LEFT]; + DryBuffer[j][BACK_RIGHT] += value*DrySend[BACK_RIGHT]; //Room path final mix buffer and panning - WetBuffer[j][0] += value*WetSend[0]; - WetBuffer[j][1] += value*WetSend[1]; - WetBuffer[j][2] += value*WetSend[2]; - WetBuffer[j][3] += value*WetSend[3]; + WetBuffer[j][FRONT_LEFT] += value*WetSend[FRONT_LEFT]; + WetBuffer[j][FRONT_RIGHT] += value*WetSend[FRONT_RIGHT]; + WetBuffer[j][BACK_LEFT] += value*WetSend[BACK_LEFT]; + WetBuffer[j][BACK_RIGHT] += value*WetSend[BACK_RIGHT]; } else { //First order interpolator (left) value = (ALfloat)((ALshort)(((Data[k*2 ]*((1L<>FRACTIONBITS)); //Direct path final mix buffer and panning (left) - DryBuffer[j][0] += value*DrySend[0]; + DryBuffer[j][FRONT_LEFT] += value*DrySend[FRONT_LEFT]; //Room path final mix buffer and panning (left) - WetBuffer[j][0] += value*WetSend[0]; + WetBuffer[j][FRONT_LEFT] += value*WetSend[FRONT_LEFT]; //First order interpolator (right) value = (ALfloat)((ALshort)(((Data[k*2+1]*((1L<>FRACTIONBITS)); //Direct path final mix buffer and panning (right) - DryBuffer[j][1] += value*DrySend[1]; + DryBuffer[j][FRONT_RIGHT] += value*DrySend[FRONT_RIGHT]; //Room path final mix buffer and panning (right) - WetBuffer[j][1] += value*WetSend[1]; + WetBuffer[j][FRONT_RIGHT] += value*WetSend[FRONT_RIGHT]; } DataPosFrac += increment; j++; @@ -648,74 +658,76 @@ ALvoid aluMixData(ALCcontext *ALContext,ALvoid *buffer,ALsizei size,ALenum forma case AL_FORMAT_MONO8: for(i = 0;i < SamplesToDo;i++) { - ((ALubyte*)buffer)[0] = (ALubyte)((aluF2S(DryBuffer[i][0]+DryBuffer[i][1]+WetBuffer[i][0]+WetBuffer[i][1])>>8)+128); + ((ALubyte*)buffer)[0] = (ALubyte)((aluF2S(DryBuffer[i][FRONT_LEFT]+DryBuffer[i][FRONT_RIGHT]+ + WetBuffer[i][FRONT_LEFT]+WetBuffer[i][FRONT_RIGHT])>>8)+128); buffer = ((ALubyte*)buffer) + 1; } break; case AL_FORMAT_STEREO8: for(i = 0;i < SamplesToDo;i++) { - ((ALubyte*)buffer)[0] = (ALubyte)((aluF2S(DryBuffer[i][0]+WetBuffer[i][0])>>8)+128); - ((ALubyte*)buffer)[1] = (ALubyte)((aluF2S(DryBuffer[i][1]+WetBuffer[i][1])>>8)+128); + ((ALubyte*)buffer)[0] = (ALubyte)((aluF2S(DryBuffer[i][FRONT_LEFT] +WetBuffer[i][FRONT_LEFT])>>8)+128); + ((ALubyte*)buffer)[1] = (ALubyte)((aluF2S(DryBuffer[i][FRONT_RIGHT]+WetBuffer[i][FRONT_RIGHT])>>8)+128); buffer = ((ALubyte*)buffer) + 2; } break; case AL_FORMAT_QUAD8: for(i = 0;i < SamplesToDo;i++) { - ((ALubyte*)buffer)[0] = (ALubyte)((aluF2S(DryBuffer[i][0]+WetBuffer[i][0])>>8)+128); - ((ALubyte*)buffer)[1] = (ALubyte)((aluF2S(DryBuffer[i][1]+WetBuffer[i][1])>>8)+128); - ((ALubyte*)buffer)[2] = (ALubyte)((aluF2S(DryBuffer[i][2]+WetBuffer[i][2])>>8)+128); - ((ALubyte*)buffer)[3] = (ALubyte)((aluF2S(DryBuffer[i][3]+WetBuffer[i][3])>>8)+128); + ((ALubyte*)buffer)[0] = (ALubyte)((aluF2S(DryBuffer[i][FRONT_LEFT] +WetBuffer[i][FRONT_LEFT])>>8)+128); + ((ALubyte*)buffer)[1] = (ALubyte)((aluF2S(DryBuffer[i][FRONT_RIGHT]+WetBuffer[i][FRONT_RIGHT])>>8)+128); + ((ALubyte*)buffer)[2] = (ALubyte)((aluF2S(DryBuffer[i][BACK_LEFT] +WetBuffer[i][BACK_LEFT])>>8)+128); + ((ALubyte*)buffer)[3] = (ALubyte)((aluF2S(DryBuffer[i][BACK_RIGHT] +WetBuffer[i][BACK_RIGHT])>>8)+128); buffer = ((ALubyte*)buffer) + 4; } break; case AL_FORMAT_51CHN8: for(i = 0;i < SamplesToDo;i++) { - ((ALubyte*)buffer)[0] = (ALubyte)((aluF2S(DryBuffer[i][0]+WetBuffer[i][0])>>8)+128); - ((ALubyte*)buffer)[1] = (ALubyte)((aluF2S(DryBuffer[i][1]+WetBuffer[i][1])>>8)+128); - ((ALubyte*)buffer)[2] = (ALubyte)((aluF2S(DryBuffer[i][2]+WetBuffer[i][2])>>8)+128); - ((ALubyte*)buffer)[3] = (ALubyte)((aluF2S(DryBuffer[i][3]+WetBuffer[i][3])>>8)+128); - ((ALubyte*)buffer)[4] = (ALubyte)((aluF2S(DryBuffer[i][4]+WetBuffer[i][4])>>8)+128); - ((ALubyte*)buffer)[5] = (ALubyte)((aluF2S(DryBuffer[i][5]+WetBuffer[i][5])>>8)+128); + ((ALubyte*)buffer)[0] = (ALubyte)((aluF2S(DryBuffer[i][FRONT_LEFT] +WetBuffer[i][FRONT_LEFT])>>8)+128); + ((ALubyte*)buffer)[1] = (ALubyte)((aluF2S(DryBuffer[i][FRONT_RIGHT]+WetBuffer[i][FRONT_RIGHT])>>8)+128); + ((ALubyte*)buffer)[2] = (ALubyte)((aluF2S(DryBuffer[i][BACK_LEFT] +WetBuffer[i][BACK_LEFT])>>8)+128); + ((ALubyte*)buffer)[3] = (ALubyte)((aluF2S(DryBuffer[i][BACK_RIGHT] +WetBuffer[i][BACK_RIGHT])>>8)+128); + ((ALubyte*)buffer)[4] = (ALubyte)((aluF2S(DryBuffer[i][CENTER] +WetBuffer[i][CENTER])>>8)+128); + ((ALubyte*)buffer)[5] = (ALubyte)((aluF2S(DryBuffer[i][LFE] +WetBuffer[i][LFE])>>8)+128); buffer = ((ALubyte*)buffer) + 6; } break; case AL_FORMAT_MONO16: for(i = 0;i < SamplesToDo;i++) { - ((ALshort*)buffer)[0] = aluF2S(DryBuffer[i][0]+DryBuffer[i][1]+WetBuffer[i][0]+WetBuffer[i][1]); + ((ALshort*)buffer)[0] = aluF2S(DryBuffer[i][FRONT_LEFT]+DryBuffer[i][FRONT_RIGHT]+ + WetBuffer[i][FRONT_LEFT]+WetBuffer[i][FRONT_RIGHT]); buffer = ((ALshort*)buffer) + 1; } break; case AL_FORMAT_STEREO16: for(i = 0;i < SamplesToDo;i++) { - ((ALshort*)buffer)[0] = aluF2S(DryBuffer[i][0]+WetBuffer[i][0]); - ((ALshort*)buffer)[1] = aluF2S(DryBuffer[i][1]+WetBuffer[i][1]); + ((ALshort*)buffer)[0] = aluF2S(DryBuffer[i][FRONT_LEFT] +WetBuffer[i][FRONT_LEFT]); + ((ALshort*)buffer)[1] = aluF2S(DryBuffer[i][FRONT_RIGHT]+WetBuffer[i][FRONT_RIGHT]); buffer = ((ALshort*)buffer) + 2; } break; case AL_FORMAT_QUAD16: for(i = 0;i < SamplesToDo;i++) { - ((ALshort*)buffer)[0] = aluF2S(DryBuffer[i][0]+WetBuffer[i][0]); - ((ALshort*)buffer)[1] = aluF2S(DryBuffer[i][1]+WetBuffer[i][1]); - ((ALshort*)buffer)[2] = aluF2S(DryBuffer[i][2]+WetBuffer[i][2]); - ((ALshort*)buffer)[3] = aluF2S(DryBuffer[i][3]+WetBuffer[i][3]); + ((ALshort*)buffer)[0] = aluF2S(DryBuffer[i][FRONT_LEFT] +WetBuffer[i][FRONT_LEFT]); + ((ALshort*)buffer)[1] = aluF2S(DryBuffer[i][FRONT_RIGHT]+WetBuffer[i][FRONT_RIGHT]); + ((ALshort*)buffer)[2] = aluF2S(DryBuffer[i][BACK_LEFT] +WetBuffer[i][BACK_LEFT]); + ((ALshort*)buffer)[3] = aluF2S(DryBuffer[i][BACK_RIGHT] +WetBuffer[i][BACK_RIGHT]); buffer = ((ALshort*)buffer) + 4; } break; case AL_FORMAT_51CHN16: for(i = 0;i < SamplesToDo;i++) { - ((ALshort*)buffer)[0] = aluF2S(DryBuffer[i][0]+WetBuffer[i][0]); - ((ALshort*)buffer)[1] = aluF2S(DryBuffer[i][1]+WetBuffer[i][1]); - ((ALshort*)buffer)[2] = aluF2S(DryBuffer[i][2]+WetBuffer[i][2]); - ((ALshort*)buffer)[3] = aluF2S(DryBuffer[i][3]+WetBuffer[i][3]); - ((ALshort*)buffer)[4] = aluF2S(DryBuffer[i][4]+WetBuffer[i][4]); - ((ALshort*)buffer)[5] = aluF2S(DryBuffer[i][5]+WetBuffer[i][5]); + ((ALshort*)buffer)[0] = aluF2S(DryBuffer[i][FRONT_LEFT] +WetBuffer[i][FRONT_LEFT]); + ((ALshort*)buffer)[1] = aluF2S(DryBuffer[i][FRONT_RIGHT]+WetBuffer[i][FRONT_RIGHT]); + ((ALshort*)buffer)[2] = aluF2S(DryBuffer[i][BACK_LEFT] +WetBuffer[i][BACK_LEFT]); + ((ALshort*)buffer)[3] = aluF2S(DryBuffer[i][BACK_RIGHT] +WetBuffer[i][BACK_RIGHT]); + ((ALshort*)buffer)[4] = aluF2S(DryBuffer[i][CENTER] +WetBuffer[i][CENTER]); + ((ALshort*)buffer)[5] = aluF2S(DryBuffer[i][LFE] +WetBuffer[i][LFE]); buffer = ((ALshort*)buffer) + 6; } break; -- cgit v1.2.3 From 73678f3b78a54d0dcc43abbd168ede2fd58bb205 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Mon, 31 Dec 2007 03:29:14 -0800 Subject: Allow psuedo 6.1 and 7.1 output This only does spatial calculations on the 4 corner speakers, but it's necessary groundwork for AL_EXT_MCFORMATS support. Spatial calculations for 6 speakers can be added later. --- Alc/ALu.c | 98 +++++++++++++++++++++++++++++++++++++++++++++++++++++++-- openalrc.sample | 4 +++ 2 files changed, 100 insertions(+), 2 deletions(-) (limited to 'Alc') diff --git a/Alc/ALu.c b/Alc/ALu.c index 682132e1..0473a4b0 100644 --- a/Alc/ALu.c +++ b/Alc/ALu.c @@ -64,6 +64,8 @@ typedef long long ALint64; enum { FRONT_LEFT = 0, FRONT_RIGHT, + SIDE_LEFT, + SIDE_RIGHT, BACK_LEFT, BACK_RIGHT, CENTER, @@ -72,6 +74,8 @@ enum { OUTPUTCHANNELS }; +/* 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) { switch(format) @@ -80,16 +84,24 @@ __inline ALuint aluBytesFromFormat(ALenum format) case AL_FORMAT_STEREO8: case AL_FORMAT_QUAD8: case AL_FORMAT_51CHN8: + case AL_FORMAT_61CHN8: + case AL_FORMAT_71CHN8: return 1; case AL_FORMAT_MONO16: case AL_FORMAT_STEREO16: case AL_FORMAT_QUAD16: case AL_FORMAT_51CHN16: + case AL_FORMAT_61CHN16: + case AL_FORMAT_71CHN16: return 2; case AL_FORMAT_MONO_FLOAT32: case AL_FORMAT_STEREO_FLOAT32: + case AL_FORMAT_QUAD32: + case AL_FORMAT_51CHN32: + case AL_FORMAT_61CHN32: + case AL_FORMAT_71CHN32: return 4; default: @@ -113,12 +125,24 @@ __inline ALuint aluChannelsFromFormat(ALenum format) case AL_FORMAT_QUAD8: case AL_FORMAT_QUAD16: + case AL_FORMAT_QUAD32: return 4; case AL_FORMAT_51CHN8: case AL_FORMAT_51CHN16: + case AL_FORMAT_51CHN32: return 6; + case AL_FORMAT_61CHN8: + case AL_FORMAT_61CHN16: + case AL_FORMAT_61CHN32: + return 7; + + case AL_FORMAT_71CHN8: + case AL_FORMAT_71CHN16: + case AL_FORMAT_71CHN32: + return 8; + default: return 0; } @@ -371,6 +395,9 @@ static ALvoid CalcSourceParams(ALCcontext *ALContext, ALsource *ALSource, case 4: /* TODO: Add center/lfe channel in spatial calculations? */ case 6: + /* TODO: Special paths for 6.1 and 7.1 output would be nice */ + case 7: + case 8: // Apply a scalar so each individual speaker has more weight PanningLR = 0.5f + (0.5f*Position[0]*1.41421356f); PanningLR = __min(1.0f, PanningLR); @@ -382,10 +409,14 @@ static ALvoid CalcSourceParams(ALCcontext *ALContext, ALsource *ALSource, drysend[FRONT_RIGHT] = ConeVolume * ListenerGain * DryMix * aluSqrt(( PanningLR)*(1.0f-PanningFB)); drysend[BACK_LEFT] = ConeVolume * ListenerGain * DryMix * aluSqrt((1.0f-PanningLR)*( PanningFB)); drysend[BACK_RIGHT] = ConeVolume * ListenerGain * DryMix * aluSqrt(( PanningLR)*( PanningFB)); + drysend[SIDE_LEFT] = 0.0f; + drysend[SIDE_RIGHT] = 0.0f; wetsend[FRONT_LEFT] = ListenerGain * WetMix * aluSqrt((1.0f-PanningLR)*(1.0f-PanningFB)); wetsend[FRONT_RIGHT] = ListenerGain * WetMix * aluSqrt(( PanningLR)*(1.0f-PanningFB)); wetsend[BACK_LEFT] = ListenerGain * WetMix * aluSqrt((1.0f-PanningLR)*( PanningFB)); wetsend[BACK_RIGHT] = ListenerGain * WetMix * aluSqrt(( PanningLR)*( PanningFB)); + wetsend[SIDE_LEFT] = 0.0f; + wetsend[SIDE_RIGHT] = 0.0f; break; default: break; @@ -396,12 +427,16 @@ static ALvoid CalcSourceParams(ALCcontext *ALContext, ALsource *ALSource, //1. Multi-channel buffers always play "normal" drysend[FRONT_LEFT] = SourceVolume * 1.0f * ListenerGain; drysend[FRONT_RIGHT] = SourceVolume * 1.0f * ListenerGain; + drysend[SIDE_LEFT] = SourceVolume * 1.0f * ListenerGain; + drysend[SIDE_RIGHT] = SourceVolume * 1.0f * ListenerGain; drysend[BACK_LEFT] = SourceVolume * 1.0f * ListenerGain; drysend[BACK_RIGHT] = SourceVolume * 1.0f * ListenerGain; drysend[CENTER] = SourceVolume * 1.0f * ListenerGain; drysend[LFE] = SourceVolume * 1.0f * ListenerGain; wetsend[FRONT_LEFT] = SourceVolume * 0.0f * ListenerGain; wetsend[FRONT_RIGHT] = SourceVolume * 0.0f * ListenerGain; + wetsend[SIDE_LEFT] = SourceVolume * 0.0f * ListenerGain; + wetsend[SIDE_RIGHT] = SourceVolume * 0.0f * ListenerGain; wetsend[BACK_LEFT] = SourceVolume * 0.0f * ListenerGain; wetsend[BACK_RIGHT] = SourceVolume * 0.0f * ListenerGain; wetsend[CENTER] = SourceVolume * 0.0f * ListenerGain; @@ -415,8 +450,8 @@ ALvoid aluMixData(ALCcontext *ALContext,ALvoid *buffer,ALsizei size,ALenum forma { static float DryBuffer[BUFFERSIZE][OUTPUTCHANNELS]; static float WetBuffer[BUFFERSIZE][OUTPUTCHANNELS]; - ALfloat DrySend[OUTPUTCHANNELS] = { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f }; - ALfloat WetSend[OUTPUTCHANNELS] = { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f }; + ALfloat DrySend[OUTPUTCHANNELS] = { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f }; + ALfloat WetSend[OUTPUTCHANNELS] = { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f }; ALuint BlockAlign,BufferSize; ALuint DataSize=0,DataPosInt=0,DataPosFrac=0; ALuint Channels,Bits,Frequency,ulExtraSamples; @@ -543,11 +578,15 @@ ALvoid aluMixData(ALCcontext *ALContext,ALvoid *buffer,ALsizei size,ALenum forma //Direct path final mix buffer and panning DryBuffer[j][FRONT_LEFT] += value*DrySend[FRONT_LEFT]; DryBuffer[j][FRONT_RIGHT] += value*DrySend[FRONT_RIGHT]; + DryBuffer[j][SIDE_LEFT] += value*DrySend[SIDE_LEFT]; + DryBuffer[j][SIDE_RIGHT] += value*DrySend[SIDE_RIGHT]; DryBuffer[j][BACK_LEFT] += value*DrySend[BACK_LEFT]; DryBuffer[j][BACK_RIGHT] += value*DrySend[BACK_RIGHT]; //Room path final mix buffer and panning WetBuffer[j][FRONT_LEFT] += value*WetSend[FRONT_LEFT]; WetBuffer[j][FRONT_RIGHT] += value*WetSend[FRONT_RIGHT]; + WetBuffer[j][SIDE_LEFT] += value*WetSend[SIDE_LEFT]; + WetBuffer[j][SIDE_RIGHT] += value*WetSend[SIDE_RIGHT]; WetBuffer[j][BACK_LEFT] += value*WetSend[BACK_LEFT]; WetBuffer[j][BACK_RIGHT] += value*WetSend[BACK_RIGHT]; } @@ -693,6 +732,34 @@ ALvoid aluMixData(ALCcontext *ALContext,ALvoid *buffer,ALsizei size,ALenum forma buffer = ((ALubyte*)buffer) + 6; } break; + case AL_FORMAT_61CHN8: + for(i = 0;i < SamplesToDo;i++) + { + ((ALubyte*)buffer)[0] = (ALubyte)((aluF2S(DryBuffer[i][FRONT_LEFT] +WetBuffer[i][FRONT_LEFT])>>8)+128); + ((ALubyte*)buffer)[1] = (ALubyte)((aluF2S(DryBuffer[i][FRONT_RIGHT]+WetBuffer[i][FRONT_RIGHT])>>8)+128); + ((ALubyte*)buffer)[2] = (ALubyte)((aluF2S(DryBuffer[i][SIDE_LEFT] +WetBuffer[i][SIDE_LEFT])>>8)+128); + ((ALubyte*)buffer)[3] = (ALubyte)((aluF2S(DryBuffer[i][SIDE_RIGHT] +WetBuffer[i][SIDE_RIGHT])>>8)+128); + ((ALubyte*)buffer)[4] = (ALubyte)((aluF2S(DryBuffer[i][BACK_LEFT] +WetBuffer[i][BACK_LEFT])>>8)+128); + ((ALubyte*)buffer)[5] = (ALubyte)((aluF2S(DryBuffer[i][BACK_RIGHT] +WetBuffer[i][BACK_RIGHT])>>8)+128); + ((ALubyte*)buffer)[6] = (ALubyte)((aluF2S(DryBuffer[i][LFE] +WetBuffer[i][LFE])>>8)+128); + buffer = ((ALubyte*)buffer) + 7; + } + break; + case AL_FORMAT_71CHN8: + for(i = 0;i < SamplesToDo;i++) + { + ((ALubyte*)buffer)[0] = (ALubyte)((aluF2S(DryBuffer[i][FRONT_LEFT] +WetBuffer[i][FRONT_LEFT])>>8)+128); + ((ALubyte*)buffer)[1] = (ALubyte)((aluF2S(DryBuffer[i][FRONT_RIGHT]+WetBuffer[i][FRONT_RIGHT])>>8)+128); + ((ALubyte*)buffer)[2] = (ALubyte)((aluF2S(DryBuffer[i][SIDE_LEFT] +WetBuffer[i][SIDE_LEFT])>>8)+128); + ((ALubyte*)buffer)[3] = (ALubyte)((aluF2S(DryBuffer[i][SIDE_RIGHT] +WetBuffer[i][SIDE_RIGHT])>>8)+128); + ((ALubyte*)buffer)[4] = (ALubyte)((aluF2S(DryBuffer[i][BACK_LEFT] +WetBuffer[i][BACK_LEFT])>>8)+128); + ((ALubyte*)buffer)[5] = (ALubyte)((aluF2S(DryBuffer[i][BACK_RIGHT] +WetBuffer[i][BACK_RIGHT])>>8)+128); + ((ALubyte*)buffer)[6] = (ALubyte)((aluF2S(DryBuffer[i][CENTER] +WetBuffer[i][CENTER])>>8)+128); + ((ALubyte*)buffer)[7] = (ALubyte)((aluF2S(DryBuffer[i][LFE] +WetBuffer[i][LFE])>>8)+128); + buffer = ((ALubyte*)buffer) + 8; + } + break; + case AL_FORMAT_MONO16: for(i = 0;i < SamplesToDo;i++) { @@ -731,6 +798,33 @@ ALvoid aluMixData(ALCcontext *ALContext,ALvoid *buffer,ALsizei size,ALenum forma buffer = ((ALshort*)buffer) + 6; } break; + case AL_FORMAT_61CHN16: + for(i = 0;i < SamplesToDo;i++) + { + ((ALshort*)buffer)[0] = aluF2S(DryBuffer[i][FRONT_LEFT] +WetBuffer[i][FRONT_LEFT]); + ((ALshort*)buffer)[1] = aluF2S(DryBuffer[i][FRONT_RIGHT]+WetBuffer[i][FRONT_RIGHT]); + ((ALshort*)buffer)[2] = aluF2S(DryBuffer[i][SIDE_LEFT] +WetBuffer[i][SIDE_LEFT]); + ((ALshort*)buffer)[3] = aluF2S(DryBuffer[i][SIDE_RIGHT] +WetBuffer[i][SIDE_RIGHT]); + ((ALshort*)buffer)[4] = aluF2S(DryBuffer[i][BACK_LEFT] +WetBuffer[i][BACK_LEFT]); + ((ALshort*)buffer)[5] = aluF2S(DryBuffer[i][BACK_RIGHT] +WetBuffer[i][BACK_RIGHT]); + ((ALshort*)buffer)[6] = aluF2S(DryBuffer[i][LFE] +WetBuffer[i][LFE]); + buffer = ((ALshort*)buffer) + 7; + } + break; + case AL_FORMAT_71CHN16: + for(i = 0;i < SamplesToDo;i++) + { + ((ALshort*)buffer)[0] = aluF2S(DryBuffer[i][FRONT_LEFT] +WetBuffer[i][FRONT_LEFT]); + ((ALshort*)buffer)[1] = aluF2S(DryBuffer[i][FRONT_RIGHT]+WetBuffer[i][FRONT_RIGHT]); + ((ALshort*)buffer)[2] = aluF2S(DryBuffer[i][SIDE_LEFT] +WetBuffer[i][SIDE_LEFT]); + ((ALshort*)buffer)[3] = aluF2S(DryBuffer[i][SIDE_RIGHT] +WetBuffer[i][SIDE_RIGHT]); + ((ALshort*)buffer)[4] = aluF2S(DryBuffer[i][BACK_LEFT] +WetBuffer[i][BACK_LEFT]); + ((ALshort*)buffer)[5] = aluF2S(DryBuffer[i][BACK_RIGHT] +WetBuffer[i][BACK_RIGHT]); + ((ALshort*)buffer)[6] = aluF2S(DryBuffer[i][CENTER] +WetBuffer[i][CENTER]); + ((ALshort*)buffer)[7] = aluF2S(DryBuffer[i][LFE] +WetBuffer[i][LFE]); + buffer = ((ALshort*)buffer) + 8; + } + break; default: break; diff --git a/openalrc.sample b/openalrc.sample index c456d544..cb4b28dc 100644 --- a/openalrc.sample +++ b/openalrc.sample @@ -13,10 +13,14 @@ format = AL_FORMAT_STEREO16 # Sets the output format. Can be one of: # AL_FORMAT_STEREO8 (8-bit stereo) # AL_FORMAT_QUAD8 (8-bit 4-channel) # AL_FORMAT_51CHN8 (8-bit 5.1 output) + # AL_FORMAT_61CHN8 (8-bit 6.1 output) + # AL_FORMAT_71CHN8 (8-bit 7.1 output) # AL_FORMAT_MONO16 (16-bit mono) # AL_FORMAT_STEREO16 (16-bit stereo) # AL_FORMAT_QUAD16 (16-bit 4-channel) # AL_FORMAT_51CHN16 (16-bit 5.1 output) + # AL_FORMAT_61CHN16 (16-bit 6.1 output) + # AL_FORMAT_71CHN16 (16-bit 7.1 output) # Default is AL_FORMAT_STEREO16 frequency = 44100 # Sets the output frequency. Default is 44100 -- cgit v1.2.3 From 1cbd625b4e88a75deafbed3d30b7e7068ec819c0 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Mon, 31 Dec 2007 03:45:26 -0800 Subject: Disable unnecessary calculations --- Alc/ALu.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'Alc') diff --git a/Alc/ALu.c b/Alc/ALu.c index 0473a4b0..d62dd1b4 100644 --- a/Alc/ALu.c +++ b/Alc/ALu.c @@ -578,15 +578,19 @@ ALvoid aluMixData(ALCcontext *ALContext,ALvoid *buffer,ALsizei size,ALenum forma //Direct path final mix buffer and panning DryBuffer[j][FRONT_LEFT] += value*DrySend[FRONT_LEFT]; DryBuffer[j][FRONT_RIGHT] += value*DrySend[FRONT_RIGHT]; +#if 0 /* FIXME: Re-enable when proper 6-channel spatialization is used */ DryBuffer[j][SIDE_LEFT] += value*DrySend[SIDE_LEFT]; DryBuffer[j][SIDE_RIGHT] += value*DrySend[SIDE_RIGHT]; +#endif DryBuffer[j][BACK_LEFT] += value*DrySend[BACK_LEFT]; DryBuffer[j][BACK_RIGHT] += value*DrySend[BACK_RIGHT]; //Room path final mix buffer and panning WetBuffer[j][FRONT_LEFT] += value*WetSend[FRONT_LEFT]; WetBuffer[j][FRONT_RIGHT] += value*WetSend[FRONT_RIGHT]; +#if 0 /* FIXME: Re-enable when proper 6-channel spatialization is used */ WetBuffer[j][SIDE_LEFT] += value*WetSend[SIDE_LEFT]; WetBuffer[j][SIDE_RIGHT] += value*WetSend[SIDE_RIGHT]; +#endif WetBuffer[j][BACK_LEFT] += value*WetSend[BACK_LEFT]; WetBuffer[j][BACK_RIGHT] += value*WetSend[BACK_RIGHT]; } -- cgit v1.2.3 From cb1d62f254a26f0bb1af545df9966312b08e1161 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Mon, 31 Dec 2007 04:50:34 -0800 Subject: Add paths for 4 to 7.1 channel buffer mixing --- Alc/ALu.c | 53 +++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 45 insertions(+), 8 deletions(-) (limited to 'Alc') diff --git a/Alc/ALu.c b/Alc/ALu.c index d62dd1b4..c35b050f 100644 --- a/Alc/ALu.c +++ b/Alc/ALu.c @@ -596,18 +596,55 @@ ALvoid aluMixData(ALCcontext *ALContext,ALvoid *buffer,ALsizei size,ALenum forma } else { - //First order interpolator (left) - value = (ALfloat)((ALshort)(((Data[k*2 ]*((1L<>FRACTIONBITS)); - //Direct path final mix buffer and panning (left) + //First order interpolator (front left) + value = (ALfloat)((ALshort)(((Data[k*Channels ]*((1L<>FRACTIONBITS)); DryBuffer[j][FRONT_LEFT] += value*DrySend[FRONT_LEFT]; - //Room path final mix buffer and panning (left) WetBuffer[j][FRONT_LEFT] += value*WetSend[FRONT_LEFT]; - //First order interpolator (right) - value = (ALfloat)((ALshort)(((Data[k*2+1]*((1L<>FRACTIONBITS)); - //Direct path final mix buffer and panning (right) + //First order interpolator (front right) + value = (ALfloat)((ALshort)(((Data[k*Channels+1]*((1L<>FRACTIONBITS)); DryBuffer[j][FRONT_RIGHT] += value*DrySend[FRONT_RIGHT]; - //Room path final mix buffer and panning (right) WetBuffer[j][FRONT_RIGHT] += value*WetSend[FRONT_RIGHT]; + if(Channels >= 4) + { + int i = 2; + if(Channels >= 7) + { + //First order interpolator (side left) + value = (ALfloat)((ALshort)(((Data[k*Channels+2]*((1L<>FRACTIONBITS)); + DryBuffer[j][SIDE_LEFT] += value*DrySend[SIDE_LEFT]; + WetBuffer[j][SIDE_LEFT] += value*WetSend[SIDE_LEFT]; + //First order interpolator (side right) + value = (ALfloat)((ALshort)(((Data[k*Channels+3]*((1L<>FRACTIONBITS)); + DryBuffer[j][SIDE_RIGHT] += value*DrySend[SIDE_RIGHT]; + WetBuffer[j][SIDE_RIGHT] += value*WetSend[SIDE_RIGHT]; + i += 2; + } + //First order interpolator (back left) + value = (ALfloat)((ALshort)(((Data[k*Channels+i]*((1L<>FRACTIONBITS)); + DryBuffer[j][BACK_LEFT] += value*DrySend[BACK_LEFT]; + WetBuffer[j][BACK_LEFT] += value*WetSend[BACK_LEFT]; + i++; + //First order interpolator (back right) + value = (ALfloat)((ALshort)(((Data[k*Channels+i]*((1L<>FRACTIONBITS)); + DryBuffer[j][BACK_RIGHT] += value*DrySend[BACK_RIGHT]; + WetBuffer[j][BACK_RIGHT] += value*WetSend[BACK_RIGHT]; + i++; + if(Channels >= 6) + { + if(Channels != 7) + { + //First order interpolator (center) + value = (ALfloat)((ALshort)(((Data[k*Channels+i]*((1L<>FRACTIONBITS)); + DryBuffer[j][CENTER] += value*DrySend[CENTER]; + WetBuffer[j][CENTER] += value*WetSend[CENTER]; + i++; + } + //First order interpolator (lfe) + value = (ALfloat)((ALshort)(((Data[k*Channels+i]*((1L<>FRACTIONBITS)); + DryBuffer[j][LFE] += value*DrySend[LFE]; + WetBuffer[j][LFE] += value*WetSend[LFE]; + } + } } DataPosFrac += increment; j++; -- cgit v1.2.3 From 42027a3f948170ef4c3425512c32806d0e58a388 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Mon, 31 Dec 2007 05:52:22 -0800 Subject: Advertise the AL_EXT_MCFORMATS extension --- Alc/ALc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Alc') diff --git a/Alc/ALc.c b/Alc/ALc.c index 376a3ce8..9bd4086d 100644 --- a/Alc/ALc.c +++ b/Alc/ALc.c @@ -360,7 +360,7 @@ static ALvoid InitContext(ALCcontext *pContext) pContext->lNumStereoSources = 1; pContext->lNumMonoSources = pContext->Device->MaxNoOfSources - pContext->lNumStereoSources; - strcpy(pContext->ExtensionList, "AL_EXT_EXPONENT_DISTANCE AL_EXT_FLOAT32 AL_EXT_IMA4 AL_EXT_LINEAR_DISTANCE AL_EXT_OFFSET"); + strcpy(pContext->ExtensionList, "AL_EXT_EXPONENT_DISTANCE AL_EXT_FLOAT32 AL_EXT_IMA4 AL_EXT_LINEAR_DISTANCE AL_EXT_MCFORMATS AL_EXT_OFFSET"); } -- cgit v1.2.3