aboutsummaryrefslogtreecommitdiffstats
path: root/Alc
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2017-12-15 22:59:51 -0800
committerChris Robinson <[email protected]>2017-12-15 22:59:51 -0800
commit30007263e5ffe1883d634081dcbfcc65dbf58cc4 (patch)
treec5425a3a3d6dce7f0b6ac94cd7f576ec4b0fe1a6 /Alc
parentff3d31e17f37cdc6c2740b73a5e5ea1407bccb35 (diff)
Allow storing multiple buffers in a ALbufferlistitem
This will be to allow buffer layering, multiple buffers of the same format and sample rate that are mixed together prior to resampling, filtering, and panning. This will allow composing sounds from individual components that can be swapped around on different invocations (e.g. layer SoundA and SoundB on one instance and SoundA and SoundC on a different instance for a slightly different sound, then just SoundA for a third instance, and so on). The longest buffer within the list item determines the length of the list item. More work needs to be done to fully support it, namely the ability to specity multiple buffers to layer for static and streaming sources. Also the behavior of loop points for layered static sources should be worked out. Should also consider allowing each layer to have a sample offset.
Diffstat (limited to 'Alc')
-rw-r--r--Alc/ALu.c2
-rw-r--r--Alc/mixer.c10
2 files changed, 8 insertions, 4 deletions
diff --git a/Alc/ALu.c b/Alc/ALu.c
index 0da610d1..5f0c556a 100644
--- a/Alc/ALu.c
+++ b/Alc/ALu.c
@@ -1450,7 +1450,7 @@ static void CalcSourceParams(ALvoice *voice, ALCcontext *context, bool force)
while(BufferListItem != NULL)
{
const ALbuffer *buffer;
- if((buffer=BufferListItem->buffer) != NULL)
+ if(BufferListItem->num_buffers >= 1 && (buffer=BufferListItem->buffers[0]) != NULL)
{
if(props->SpatializeMode == SpatializeOn ||
(props->SpatializeMode == SpatializeAuto && buffer->FmtChannels == FmtMono))
diff --git a/Alc/mixer.c b/Alc/mixer.c
index c77488bc..37bdf6ac 100644
--- a/Alc/mixer.c
+++ b/Alc/mixer.c
@@ -362,9 +362,13 @@ ALboolean MixSource(ALvoice *voice, ALsource *Source, ALCdevice *Device, ALsizei
memcpy(SrcData, voice->PrevSamples[chan], MAX_PRE_SAMPLES*sizeof(ALfloat));
SrcDataSize = MAX_PRE_SAMPLES;
+ /* TODO: Handle multi-buffer items by adding them together in
+ * SrcData. Need to work out how to deal with looping (loop
+ * points).
+ */
if(isstatic)
{
- const ALbuffer *ALBuffer = BufferListItem->buffer;
+ const ALbuffer *ALBuffer = BufferListItem->buffers[0];
const ALubyte *Data = ALBuffer->data;
ALsizei DataSize;
@@ -421,7 +425,7 @@ ALboolean MixSource(ALvoice *voice, ALsource *Source, ALCdevice *Device, ALsizei
while(tmpiter && SrcBufferSize > SrcDataSize)
{
const ALbuffer *ALBuffer;
- if((ALBuffer=tmpiter->buffer) != NULL)
+ if(tmpiter->num_buffers >= 1 && (ALBuffer=tmpiter->buffers[0]) != NULL)
{
const ALubyte *Data = ALBuffer->data;
ALsizei DataSize = ALBuffer->SampleLen;
@@ -637,7 +641,7 @@ ALboolean MixSource(ALvoice *voice, ALsource *Source, ALCdevice *Device, ALsizei
ALsizei LoopStart = 0;
ALsizei LoopEnd = 0;
- if((ALBuffer=BufferListItem->buffer) != NULL)
+ if(BufferListItem->num_buffers >= 1 && (ALBuffer=BufferListItem->buffers[0]) != NULL)
{
DataSize = ALBuffer->SampleLen;
LoopStart = ALBuffer->LoopStart;