diff options
-rw-r--r-- | Alc/ALc.c | 2 | ||||
-rw-r--r-- | Alc/mixer.c | 62 | ||||
-rw-r--r-- | OpenAL32/Include/alSource.h | 2 | ||||
-rw-r--r-- | OpenAL32/Include/alu.h | 2 | ||||
-rw-r--r-- | OpenAL32/alSource.c | 2 |
5 files changed, 34 insertions, 36 deletions
@@ -1022,7 +1022,7 @@ static void alc_initconfig(void) WARN("Invalid resampler: %s\n", str); } } - aluInitResamplers(); + aluInitMixer(); str = getenv("ALSOFT_TRAP_ERROR"); if(str && (strcasecmp(str, "true") == 0 || strtol(str, NULL, 0) == 1)) diff --git a/Alc/mixer.c b/Alc/mixer.c index b2084c62..93119e6a 100644 --- a/Alc/mixer.c +++ b/Alc/mixer.c @@ -46,20 +46,9 @@ extern inline void InitiatePositionArrays(ALuint frac, ALuint increment, ALuint alignas(16) ALfloat CubicLUT[FRACTIONONE][4]; -void aluInitResamplers(void) -{ - ALuint i; - for(i = 0;i < FRACTIONONE;i++) - { - ALfloat mu = (ALfloat)i / FRACTIONONE; - ALfloat mu2 = mu*mu, mu3 = mu*mu*mu; - CubicLUT[i][0] = -0.5f*mu3 + mu2 + -0.5f*mu; - CubicLUT[i][1] = 1.5f*mu3 + -2.5f*mu2 + 1.0f; - CubicLUT[i][2] = -1.5f*mu3 + 2.0f*mu2 + 0.5f*mu; - CubicLUT[i][3] = 0.5f*mu3 + -0.5f*mu2; - } -} - +static HrtfMixerFunc MixHrtfSamples = MixHrtf_C; +static MixerFunc MixSamples = Mix_C; +static ResamplerFunc ResampleSamples = Resample_point32_C; static inline HrtfMixerFunc SelectHrtfMixer(void) { @@ -124,6 +113,25 @@ static inline ResamplerFunc SelectResampler(enum Resampler resampler) } +void aluInitMixer(void) +{ + ALuint i; + for(i = 0;i < FRACTIONONE;i++) + { + ALfloat mu = (ALfloat)i / FRACTIONONE; + ALfloat mu2 = mu*mu, mu3 = mu*mu*mu; + CubicLUT[i][0] = -0.5f*mu3 + mu2 + -0.5f*mu; + CubicLUT[i][1] = 1.5f*mu3 + -2.5f*mu2 + 1.0f; + CubicLUT[i][2] = -1.5f*mu3 + 2.0f*mu2 + 0.5f*mu; + CubicLUT[i][3] = 0.5f*mu3 + -0.5f*mu2; + } + + MixHrtfSamples = SelectHrtfMixer(); + MixSamples = SelectMixer(); + ResampleSamples = SelectResampler(DefaultResampler); +} + + static inline ALfloat Sample_ALbyte(ALbyte val) { return val * (1.0f/127.0f); } @@ -206,15 +214,12 @@ static const ALfloat *DoFilters(ALfilterState *lpfilter, ALfilterState *hpfilter ALvoid MixSource(ALvoice *voice, ALsource *Source, ALCdevice *Device, ALuint SamplesToDo) { - MixerFunc Mix; - HrtfMixerFunc HrtfMix; ResamplerFunc Resample; ALbufferlistitem *BufferListItem; ALuint DataPosInt, DataPosFrac; ALboolean isbformat = AL_FALSE; ALboolean Looping; ALuint increment; - enum Resampler Resampler; ALenum State; ALuint OutPos; ALuint NumChannels; @@ -229,7 +234,6 @@ ALvoid MixSource(ALvoice *voice, ALsource *Source, ALCdevice *Device, ALuint Sam DataPosInt = Source->position; DataPosFrac = Source->position_fraction; Looping = Source->Looping; - Resampler = Source->Resampler; NumChannels = Source->NumChannels; SampleSize = Source->SampleSize; increment = voice->Step; @@ -249,15 +253,13 @@ ALvoid MixSource(ALvoice *voice, ALsource *Source, ALCdevice *Device, ALuint Sam IrSize = (Device->Hrtf ? GetHrtfIrSize(Device->Hrtf) : 0); - Mix = SelectMixer(); - HrtfMix = SelectHrtfMixer(); Resample = ((increment == FRACTIONONE && DataPosFrac == 0) ? - Resample_copy32_C : SelectResampler(Resampler)); + Resample_copy32_C : ResampleSamples); OutPos = 0; do { - const ALuint BufferPrePadding = ResamplerPrePadding[Resampler]; - const ALuint BufferPadding = ResamplerPadding[Resampler]; + const ALuint BufferPrePadding = ResamplerPrePadding[DefaultResampler]; + const ALuint BufferPadding = ResamplerPadding[DefaultResampler]; ALuint SrcBufferSize, DstBufferSize; /* Figure out how many buffer samples will be needed */ @@ -467,12 +469,12 @@ ALvoid MixSource(ALvoice *voice, ALsource *Source, ALCdevice *Device, ALuint Sam parms->Filters[chan].ActiveType ); if(!voice->IsHrtf) - Mix(samples, parms->OutChannels, parms->OutBuffer, parms->Gains[chan], - parms->Counter, OutPos, DstBufferSize); + MixSamples(samples, parms->OutChannels, parms->OutBuffer, parms->Gains[chan], + parms->Counter, OutPos, DstBufferSize); else - HrtfMix(parms->OutBuffer, samples, parms->Counter, voice->Offset, - OutPos, IrSize, &parms->Hrtf[chan].Params, - &parms->Hrtf[chan].State, DstBufferSize); + MixHrtfSamples(parms->OutBuffer, samples, parms->Counter, voice->Offset, + OutPos, IrSize, &parms->Hrtf[chan].Params, + &parms->Hrtf[chan].State, DstBufferSize); } /* Only the first channel for B-Format buffers (W channel) goes to @@ -492,8 +494,8 @@ ALvoid MixSource(ALvoice *voice, ALsource *Source, ALCdevice *Device, ALuint Sam Device->FilteredData, ResampledData, DstBufferSize, parms->Filters[chan].ActiveType ); - Mix(samples, 1, parms->OutBuffer, &parms->Gain, - parms->Counter, OutPos, DstBufferSize); + MixSamples(samples, 1, parms->OutBuffer, &parms->Gain, + parms->Counter, OutPos, DstBufferSize); } } /* Update positions */ diff --git a/OpenAL32/Include/alSource.h b/OpenAL32/Include/alSource.h index fe2867b1..f67d5f3b 100644 --- a/OpenAL32/Include/alSource.h +++ b/OpenAL32/Include/alSource.h @@ -77,8 +77,6 @@ typedef struct ALsource { volatile ALfloat Radius; - enum Resampler Resampler; - /** * Last user-specified offset, and the offset type (bytes, samples, or * seconds). diff --git a/OpenAL32/Include/alu.h b/OpenAL32/Include/alu.h index 2edc0d0c..f5fc9fa4 100644 --- a/OpenAL32/Include/alu.h +++ b/OpenAL32/Include/alu.h @@ -216,7 +216,7 @@ inline ALfloat cubic(ALfloat val0, ALfloat val1, ALfloat val2, ALfloat val3, ALu } -void aluInitResamplers(void); +void aluInitMixer(void); ALvoid aluInitPanning(ALCdevice *Device); diff --git a/OpenAL32/alSource.c b/OpenAL32/alSource.c index ee9e1fcd..67fb45a9 100644 --- a/OpenAL32/alSource.c +++ b/OpenAL32/alSource.c @@ -2549,8 +2549,6 @@ static ALvoid InitSourceParams(ALsource *Source) Source->DistanceModel = DefaultDistanceModel; - Source->Resampler = DefaultResampler; - Source->state = AL_INITIAL; Source->new_state = AL_NONE; Source->SourceType = AL_UNDETERMINED; |