aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2012-10-05 06:03:19 -0700
committerChris Robinson <[email protected]>2012-10-05 06:03:19 -0700
commita6287fd407b87b0bf983dcf8fc17ac66c0ae7d23 (patch)
tree68ce82ccac121b92982af6c2d944f4a856057ca7
parent16bdf79d4cbb87a90ff70d981d02eecb0fc4bed1 (diff)
Add a special resampler for matching sample rates
-rw-r--r--Alc/ALu.c2
-rw-r--r--Alc/mixer.c2
-rw-r--r--Alc/mixer_c.c10
-rw-r--r--Alc/mixer_defs.h1
4 files changed, 13 insertions, 2 deletions
diff --git a/Alc/ALu.c b/Alc/ALu.c
index 6d75e20e..8dfe87e5 100644
--- a/Alc/ALu.c
+++ b/Alc/ALu.c
@@ -54,7 +54,7 @@ ALfloat ZScale = 1.0f;
static ResamplerFunc SelectResampler(enum Resampler Resampler, ALuint increment)
{
if(increment == FRACTIONONE)
- return Resample_point32_C;
+ return Resample_copy32_C;
switch(Resampler)
{
case PointResampler:
diff --git a/Alc/mixer.c b/Alc/mixer.c
index 7671f1b3..5b180f1e 100644
--- a/Alc/mixer.c
+++ b/Alc/mixer.c
@@ -116,7 +116,7 @@ ALvoid MixSource(ALsource *Source, ALCdevice *Device, ALuint SamplesToDo)
DataPosFrac = Source->position_fraction;
Looping = Source->Looping;
increment = Source->Params.Step;
- Resampler = Source->Resampler;
+ Resampler = (increment==FRACTIONONE) ? PointResampler : Source->Resampler;
NumChannels = Source->NumChannels;
SampleSize = Source->SampleSize;
diff --git a/Alc/mixer_c.c b/Alc/mixer_c.c
index b1ffb11b..28eee188 100644
--- a/Alc/mixer_c.c
+++ b/Alc/mixer_c.c
@@ -1,5 +1,7 @@
#include "config.h"
+#include <assert.h>
+
#include "alMain.h"
#include "alu.h"
#include "alSource.h"
@@ -13,6 +15,14 @@ static __inline ALfloat lerp32(const ALfloat *vals, ALuint frac)
static __inline ALfloat cubic32(const ALfloat *vals, ALuint frac)
{ return cubic(vals[-1], vals[0], vals[1], vals[2], frac * (1.0f/FRACTIONONE)); }
+void Resample_copy32_C(const ALfloat *data, ALuint frac,
+ ALuint increment, ALfloat *RESTRICT OutBuffer, ALuint BufferSize)
+{
+ (void)frac;
+ assert(increment==FRACTIONONE);
+ memcpy(OutBuffer, data, (BufferSize+1)*sizeof(ALfloat));
+}
+
#define DECL_TEMPLATE(Sampler) \
void Resample_##Sampler##_C(const ALfloat *data, ALuint frac, \
ALuint increment, ALfloat *RESTRICT OutBuffer, ALuint BufferSize) \
diff --git a/Alc/mixer_defs.h b/Alc/mixer_defs.h
index ecbd879a..f2a180fd 100644
--- a/Alc/mixer_defs.h
+++ b/Alc/mixer_defs.h
@@ -10,6 +10,7 @@ struct DirectParams;
struct SendParams;
/* C resamplers */
+void Resample_copy32_C(const ALfloat *src, ALuint frac, ALuint increment, ALfloat *RESTRICT dst, ALuint dstlen);
void Resample_point32_C(const ALfloat *src, ALuint frac, ALuint increment, ALfloat *RESTRICT dst, ALuint dstlen);
void Resample_lerp32_C(const ALfloat *src, ALuint frac, ALuint increment, ALfloat *RESTRICT dst, ALuint dstlen);
void Resample_cubic32_C(const ALfloat *src, ALuint frac, ALuint increment, ALfloat *RESTRICT dst, ALuint dstlen);