diff options
author | Chris Robinson <[email protected]> | 2016-03-09 23:43:57 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2016-03-09 23:43:57 -0800 |
commit | a45715751640992e8caeac8c36b5ecb23ba3c190 (patch) | |
tree | 5ae3f2d8611487be37ff1c52eb2eeabfc4b62d69 | |
parent | 3e2672ec9f5c2a84a0f871bd0379ee387f9a95ce (diff) |
Organize the dry buffer properties into a struct
-rw-r--r-- | Alc/ALc.c | 145 | ||||
-rw-r--r-- | Alc/ALu.c | 30 | ||||
-rw-r--r-- | Alc/effects/autowah.c | 2 | ||||
-rw-r--r-- | Alc/effects/chorus.c | 4 | ||||
-rw-r--r-- | Alc/effects/compressor.c | 4 | ||||
-rw-r--r-- | Alc/effects/dedicated.c | 3 | ||||
-rw-r--r-- | Alc/effects/distortion.c | 2 | ||||
-rw-r--r-- | Alc/effects/echo.c | 6 | ||||
-rw-r--r-- | Alc/effects/equalizer.c | 4 | ||||
-rw-r--r-- | Alc/effects/flanger.c | 6 | ||||
-rw-r--r-- | Alc/effects/modulator.c | 4 | ||||
-rw-r--r-- | Alc/effects/reverb.c | 37 | ||||
-rw-r--r-- | Alc/panning.c | 40 | ||||
-rw-r--r-- | OpenAL32/Include/alMain.h | 44 |
14 files changed, 175 insertions, 156 deletions
@@ -1433,63 +1433,63 @@ void SetDefaultWFXChannelOrder(ALCdevice *device) ALuint i; for(i = 0;i < MAX_OUTPUT_CHANNELS;i++) - device->ChannelName[i] = InvalidChannel; + device->Dry.ChannelName[i] = InvalidChannel; switch(device->FmtChans) { case DevFmtMono: - device->ChannelName[0] = FrontCenter; + device->Dry.ChannelName[0] = FrontCenter; break; case DevFmtStereo: - device->ChannelName[0] = FrontLeft; - device->ChannelName[1] = FrontRight; + device->Dry.ChannelName[0] = FrontLeft; + device->Dry.ChannelName[1] = FrontRight; break; case DevFmtQuad: - device->ChannelName[0] = FrontLeft; - device->ChannelName[1] = FrontRight; - device->ChannelName[2] = BackLeft; - device->ChannelName[3] = BackRight; + device->Dry.ChannelName[0] = FrontLeft; + device->Dry.ChannelName[1] = FrontRight; + device->Dry.ChannelName[2] = BackLeft; + device->Dry.ChannelName[3] = BackRight; break; case DevFmtX51: - device->ChannelName[0] = FrontLeft; - device->ChannelName[1] = FrontRight; - device->ChannelName[2] = FrontCenter; - device->ChannelName[3] = LFE; - device->ChannelName[4] = SideLeft; - device->ChannelName[5] = SideRight; + device->Dry.ChannelName[0] = FrontLeft; + device->Dry.ChannelName[1] = FrontRight; + device->Dry.ChannelName[2] = FrontCenter; + device->Dry.ChannelName[3] = LFE; + device->Dry.ChannelName[4] = SideLeft; + device->Dry.ChannelName[5] = SideRight; break; case DevFmtX51Rear: - device->ChannelName[0] = FrontLeft; - device->ChannelName[1] = FrontRight; - device->ChannelName[2] = FrontCenter; - device->ChannelName[3] = LFE; - device->ChannelName[4] = BackLeft; - device->ChannelName[5] = BackRight; + device->Dry.ChannelName[0] = FrontLeft; + device->Dry.ChannelName[1] = FrontRight; + device->Dry.ChannelName[2] = FrontCenter; + device->Dry.ChannelName[3] = LFE; + device->Dry.ChannelName[4] = BackLeft; + device->Dry.ChannelName[5] = BackRight; break; case DevFmtX61: - device->ChannelName[0] = FrontLeft; - device->ChannelName[1] = FrontRight; - device->ChannelName[2] = FrontCenter; - device->ChannelName[3] = LFE; - device->ChannelName[4] = BackCenter; - device->ChannelName[5] = SideLeft; - device->ChannelName[6] = SideRight; + device->Dry.ChannelName[0] = FrontLeft; + device->Dry.ChannelName[1] = FrontRight; + device->Dry.ChannelName[2] = FrontCenter; + device->Dry.ChannelName[3] = LFE; + device->Dry.ChannelName[4] = BackCenter; + device->Dry.ChannelName[5] = SideLeft; + device->Dry.ChannelName[6] = SideRight; break; case DevFmtX71: - device->ChannelName[0] = FrontLeft; - device->ChannelName[1] = FrontRight; - device->ChannelName[2] = FrontCenter; - device->ChannelName[3] = LFE; - device->ChannelName[4] = BackLeft; - device->ChannelName[5] = BackRight; - device->ChannelName[6] = SideLeft; - device->ChannelName[7] = SideRight; + device->Dry.ChannelName[0] = FrontLeft; + device->Dry.ChannelName[1] = FrontRight; + device->Dry.ChannelName[2] = FrontCenter; + device->Dry.ChannelName[3] = LFE; + device->Dry.ChannelName[4] = BackLeft; + device->Dry.ChannelName[5] = BackRight; + device->Dry.ChannelName[6] = SideLeft; + device->Dry.ChannelName[7] = SideRight; break; case DevFmtBFormat3D: - device->ChannelName[0] = BFormatW; - device->ChannelName[1] = BFormatX; - device->ChannelName[2] = BFormatY; - device->ChannelName[3] = BFormatZ; + device->Dry.ChannelName[0] = BFormatW; + device->Dry.ChannelName[1] = BFormatX; + device->Dry.ChannelName[2] = BFormatY; + device->Dry.ChannelName[3] = BFormatZ; break; } } @@ -1503,27 +1503,27 @@ void SetDefaultChannelOrder(ALCdevice *device) ALuint i; for(i = 0;i < MAX_OUTPUT_CHANNELS;i++) - device->ChannelName[i] = InvalidChannel; + device->Dry.ChannelName[i] = InvalidChannel; switch(device->FmtChans) { case DevFmtX51Rear: - device->ChannelName[0] = FrontLeft; - device->ChannelName[1] = FrontRight; - device->ChannelName[2] = BackLeft; - device->ChannelName[3] = BackRight; - device->ChannelName[4] = FrontCenter; - device->ChannelName[5] = LFE; + device->Dry.ChannelName[0] = FrontLeft; + device->Dry.ChannelName[1] = FrontRight; + device->Dry.ChannelName[2] = BackLeft; + device->Dry.ChannelName[3] = BackRight; + device->Dry.ChannelName[4] = FrontCenter; + device->Dry.ChannelName[5] = LFE; return; case DevFmtX71: - device->ChannelName[0] = FrontLeft; - device->ChannelName[1] = FrontRight; - device->ChannelName[2] = BackLeft; - device->ChannelName[3] = BackRight; - device->ChannelName[4] = FrontCenter; - device->ChannelName[5] = LFE; - device->ChannelName[6] = SideLeft; - device->ChannelName[7] = SideRight; + device->Dry.ChannelName[0] = FrontLeft; + device->Dry.ChannelName[1] = FrontRight; + device->Dry.ChannelName[2] = BackLeft; + device->Dry.ChannelName[3] = BackRight; + device->Dry.ChannelName[4] = FrontCenter; + device->Dry.ChannelName[5] = LFE; + device->Dry.ChannelName[6] = SideLeft; + device->Dry.ChannelName[7] = SideRight; return; /* Same as WFX order */ @@ -1853,8 +1853,9 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const ALCint *attrList) al_free(device->Bs2b); device->Bs2b = NULL; - al_free(device->DryBuffer); - device->DryBuffer = NULL; + al_free(device->Dry.Buffer); + device->Dry.Buffer = NULL; + device->Dry.NumChannels = 0; device->VirtOut.Buffer = NULL; device->VirtOut.NumChannels = 0; device->RealOut.Buffer = NULL; @@ -2118,11 +2119,11 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const ALCint *attrList) aluInitPanning(device); /* With HRTF, allocate two extra channels for the post-filter output. */ - size = device->NumChannels * sizeof(device->DryBuffer[0]); + size = device->Dry.NumChannels * sizeof(device->Dry.Buffer[0]); if(device->Hrtf || device->Uhj_Encoder) - size += 2 * sizeof(device->DryBuffer[0]); - device->DryBuffer = al_calloc(16, size); - if(!device->DryBuffer) + size += 2 * sizeof(device->Dry.Buffer[0]); + device->Dry.Buffer = al_calloc(16, size); + if(!device->Dry.Buffer) { ERR("Failed to allocate "SZFMT" bytes for mix buffer\n", size); return ALC_INVALID_DEVICE; @@ -2130,17 +2131,17 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const ALCint *attrList) if(device->Hrtf || device->Uhj_Encoder) { - device->VirtOut.Buffer = device->DryBuffer; - device->VirtOut.NumChannels = device->NumChannels; - device->RealOut.Buffer = device->DryBuffer + device->NumChannels; + device->VirtOut.Buffer = device->Dry.Buffer; + device->VirtOut.NumChannels = device->Dry.NumChannels; + device->RealOut.Buffer = device->Dry.Buffer + device->Dry.NumChannels; device->RealOut.NumChannels = 2; } else { device->VirtOut.Buffer = NULL; device->VirtOut.NumChannels = 0; - device->RealOut.Buffer = device->DryBuffer; - device->RealOut.NumChannels = device->NumChannels; + device->RealOut.Buffer = device->Dry.Buffer; + device->RealOut.NumChannels = device->Dry.NumChannels; } SetMixerFPUMode(&oldMode); @@ -2278,8 +2279,9 @@ static ALCvoid FreeDevice(ALCdevice *device) AL_STRING_DEINIT(device->DeviceName); - al_free(device->DryBuffer); - device->DryBuffer = NULL; + al_free(device->Dry.Buffer); + device->Dry.Buffer = NULL; + device->Dry.NumChannels = 0; device->VirtOut.Buffer = NULL; device->VirtOut.NumChannels = 0; device->RealOut.Buffer = NULL; @@ -3383,7 +3385,8 @@ ALC_API ALCdevice* ALC_APIENTRY alcOpenDevice(const ALCchar *deviceName) AL_STRING_INIT(device->Hrtf_Name); device->Render_Mode = NormalRender; AL_STRING_INIT(device->DeviceName); - device->DryBuffer = NULL; + device->Dry.Buffer = NULL; + device->Dry.NumChannels = 0; device->VirtOut.Buffer = NULL; device->VirtOut.NumChannels = 0; device->RealOut.Buffer = NULL; @@ -3642,7 +3645,8 @@ ALC_API ALCdevice* ALC_APIENTRY alcCaptureOpenDevice(const ALCchar *deviceName, AL_STRING_INIT(device->Hrtf_Name); AL_STRING_INIT(device->DeviceName); - device->DryBuffer = NULL; + device->Dry.Buffer = NULL; + device->Dry.NumChannels = 0; device->VirtOut.Buffer = NULL; device->VirtOut.NumChannels = 0; device->RealOut.Buffer = NULL; @@ -3836,7 +3840,8 @@ ALC_API ALCdevice* ALC_APIENTRY alcLoopbackOpenDeviceSOFT(const ALCchar *deviceN device->Uhj_Encoder = NULL; device->Render_Mode = NormalRender; AL_STRING_INIT(device->DeviceName); - device->DryBuffer = NULL; + device->Dry.Buffer = NULL; + device->Dry.NumChannels = 0; device->VirtOut.Buffer = NULL; device->VirtOut.NumChannels = 0; device->RealOut.Buffer = NULL; @@ -394,8 +394,8 @@ ALvoid CalcNonAttnSourceParams(ALvoice *voice, const ALsource *ALSource, const A Relative = ALSource->HeadRelative; DirectChannels = ALSource->DirectChannels; - voice->Direct.OutBuffer = Device->DryBuffer; - voice->Direct.OutChannels = Device->NumChannels; + voice->Direct.OutBuffer = Device->Dry.Buffer; + voice->Direct.OutChannels = Device->Dry.NumChannels; for(i = 0;i < NumSends;i++) { SendSlots[i] = ALSource->Send[i].Slot; @@ -526,7 +526,7 @@ ALvoid CalcNonAttnSourceParams(ALvoice *voice, const ALsource *ALSource, const A /* Build a rotate + conversion matrix (B-Format -> N3D), and include * scaling for first-order content on second- or third-order output. */ - scale = Device->AmbiScale * 1.732050808f; + scale = Device->Dry.AmbiScale * 1.732050808f; aluMatrixfSet(&matrix, 1.414213562f, 0.0f, 0.0f, 0.0f, 0.0f, -N[0]*scale, N[1]*scale, -N[2]*scale, @@ -535,8 +535,8 @@ ALvoid CalcNonAttnSourceParams(ALvoice *voice, const ALsource *ALSource, const A ); for(c = 0;c < num_channels;c++) - ComputeFirstOrderGains(Device->AmbiCoeffs, Device->NumChannels, matrix.m[c], DryGain, - voice->Direct.Gains[c].Target); + ComputeFirstOrderGains(Device->Dry.AmbiCoeffs, Device->Dry.NumChannels, matrix.m[c], + DryGain, voice->Direct.Gains[c].Target); /* Rebuild the matrix, without the second- or third-order output * scaling (effects take first-order content, and will do the scaling @@ -722,8 +722,8 @@ ALvoid CalcNonAttnSourceParams(ALvoice *voice, const ALsource *ALSource, const A else { CalcAngleCoeffs(chans[c].angle, chans[c].elevation, coeffs); - ComputePanningGains(Device->AmbiCoeffs, Device->NumChannels, coeffs, DryGain, - voice->Direct.Gains[c].Target); + ComputePanningGains(Device->Dry.AmbiCoeffs, Device->Dry.NumChannels, coeffs, + DryGain, voice->Direct.Gains[c].Target); } for(i = 0;i < NumSends;i++) @@ -859,8 +859,8 @@ ALvoid CalcSourceParams(ALvoice *voice, const ALsource *ALSource, const ALCconte WetGainHFAuto = ALSource->WetGainHFAuto; RoomRolloffBase = ALSource->RoomRolloffFactor; - voice->Direct.OutBuffer = Device->DryBuffer; - voice->Direct.OutChannels = Device->NumChannels; + voice->Direct.OutBuffer = Device->Dry.Buffer; + voice->Direct.OutChannels = Device->Dry.NumChannels; for(i = 0;i < NumSends;i++) { SendSlots[i] = ALSource->Send[i].Slot; @@ -1223,8 +1223,8 @@ ALvoid CalcSourceParams(ALvoice *voice, const ALsource *ALSource, const ALCconte else { CalcDirectionCoeffs(dir, coeffs); - ComputePanningGains(Device->AmbiCoeffs, Device->NumChannels, coeffs, DryGain, - voice->Direct.Gains[0].Target); + ComputePanningGains(Device->Dry.AmbiCoeffs, Device->Dry.NumChannels, coeffs, + DryGain, voice->Direct.Gains[0].Target); } for(i = 0;i < NumSends;i++) @@ -1452,8 +1452,8 @@ ALvoid aluMixData(ALCdevice *device, ALvoid *buffer, ALsizei size) { const ALeffectslot *slot = VECTOR_ELEM(ctx->ActiveAuxSlots, i); ALeffectState *state = slot->EffectState; - V(state,process)(SamplesToDo, slot->WetBuffer, device->DryBuffer, - device->NumChannels); + V(state,process)(SamplesToDo, slot->WetBuffer, device->Dry.Buffer, + device->Dry.NumChannels); } ctx = ctx->next; @@ -1463,8 +1463,8 @@ ALvoid aluMixData(ALCdevice *device, ALvoid *buffer, ALsizei size) { const ALeffectslot *slot = device->DefaultSlot; ALeffectState *state = slot->EffectState; - V(state,process)(SamplesToDo, slot->WetBuffer, device->DryBuffer, - device->NumChannels); + V(state,process)(SamplesToDo, slot->WetBuffer, device->Dry.Buffer, + device->Dry.NumChannels); } /* Increment the clock time. Every second's worth of samples is diff --git a/Alc/effects/autowah.c b/Alc/effects/autowah.c index 09aecf15..20ae26e4 100644 --- a/Alc/effects/autowah.c +++ b/Alc/effects/autowah.c @@ -75,7 +75,7 @@ static ALvoid ALautowahState_update(ALautowahState *state, const ALCdevice *devi state->PeakGain = slot->EffectProps.Autowah.PeakGain; state->Resonance = slot->EffectProps.Autowah.Resonance; - ComputeAmbientGains(device->AmbiCoeffs, device->NumChannels, slot->Gain, state->Gain); + ComputeAmbientGains(device->Dry.AmbiCoeffs, device->Dry.NumChannels, slot->Gain, state->Gain); } static ALvoid ALautowahState_process(ALautowahState *state, ALuint SamplesToDo, const ALfloat (*restrict SamplesIn)[BUFFERSIZE], ALfloat (*restrict SamplesOut)[BUFFERSIZE], ALuint NumChannels) diff --git a/Alc/effects/chorus.c b/Alc/effects/chorus.c index 1c9efd47..e212cd75 100644 --- a/Alc/effects/chorus.c +++ b/Alc/effects/chorus.c @@ -113,9 +113,9 @@ static ALvoid ALchorusState_update(ALchorusState *state, const ALCdevice *Device /* Gains for left and right sides */ CalcXYZCoeffs(-1.0f, 0.0f, 0.0f, coeffs); - ComputePanningGains(Device->AmbiCoeffs, Device->NumChannels, coeffs, Slot->Gain, state->Gain[0]); + ComputePanningGains(Device->Dry.AmbiCoeffs, Device->Dry.NumChannels, coeffs, Slot->Gain, state->Gain[0]); CalcXYZCoeffs( 1.0f, 0.0f, 0.0f, coeffs); - ComputePanningGains(Device->AmbiCoeffs, Device->NumChannels, coeffs, Slot->Gain, state->Gain[1]); + ComputePanningGains(Device->Dry.AmbiCoeffs, Device->Dry.NumChannels, coeffs, Slot->Gain, state->Gain[1]); phase = Slot->EffectProps.Chorus.Phase; rate = Slot->EffectProps.Chorus.Rate; diff --git a/Alc/effects/compressor.c b/Alc/effects/compressor.c index e835a5aa..ae859793 100644 --- a/Alc/effects/compressor.c +++ b/Alc/effects/compressor.c @@ -63,7 +63,7 @@ static ALvoid ALcompressorState_update(ALcompressorState *state, const ALCdevice state->Enabled = slot->EffectProps.Compressor.OnOff; - scale = device->AmbiScale; + scale = device->Dry.AmbiScale; aluMatrixfSet(&matrix, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, scale, 0.0f, 0.0f, @@ -71,7 +71,7 @@ static ALvoid ALcompressorState_update(ALcompressorState *state, const ALCdevice 0.0f, 0.0f, 0.0f, scale ); for(i = 0;i < 4;i++) - ComputeFirstOrderGains(device->AmbiCoeffs, device->NumChannels, + ComputeFirstOrderGains(device->Dry.AmbiCoeffs, device->Dry.NumChannels, matrix.m[i], slot->Gain, state->Gain[i]); } diff --git a/Alc/effects/dedicated.c b/Alc/effects/dedicated.c index 06aad17c..2706a672 100644 --- a/Alc/effects/dedicated.c +++ b/Alc/effects/dedicated.c @@ -71,7 +71,8 @@ static ALvoid ALdedicatedState_update(ALdedicatedState *state, const ALCdevice * { ALfloat coeffs[MAX_AMBI_COEFFS]; CalcXYZCoeffs(0.0f, 0.0f, -1.0f, coeffs); - ComputePanningGains(device->AmbiCoeffs, device->NumChannels, coeffs, Gain, state->gains); + ComputePanningGains(device->Dry.AmbiCoeffs, device->Dry.NumChannels, + coeffs, Gain, state->gains); } } } diff --git a/Alc/effects/distortion.c b/Alc/effects/distortion.c index 697758f0..92eb1a6d 100644 --- a/Alc/effects/distortion.c +++ b/Alc/effects/distortion.c @@ -83,7 +83,7 @@ static ALvoid ALdistortionState_update(ALdistortionState *state, const ALCdevice cutoff / (frequency*4.0f), calc_rcpQ_from_bandwidth(cutoff / (frequency*4.0f), bandwidth) ); - ComputeAmbientGains(Device->AmbiCoeffs, Device->NumChannels, Slot->Gain, state->Gain); + ComputeAmbientGains(Device->Dry.AmbiCoeffs, Device->Dry.NumChannels, Slot->Gain, state->Gain); } static ALvoid ALdistortionState_process(ALdistortionState *state, ALuint SamplesToDo, const ALfloat (*restrict SamplesIn)[BUFFERSIZE], ALfloat (*restrict SamplesOut)[BUFFERSIZE], ALuint NumChannels) diff --git a/Alc/effects/echo.c b/Alc/effects/echo.c index ebb6cf12..1f5925ef 100644 --- a/Alc/effects/echo.c +++ b/Alc/effects/echo.c @@ -104,11 +104,13 @@ static ALvoid ALechoState_update(ALechoState *state, const ALCdevice *Device, co /* First tap panning */ CalcXYZCoeffs(-lrpan, 0.0f, 0.0f, coeffs); - ComputePanningGains(Device->AmbiCoeffs, Device->NumChannels, coeffs, gain, state->Gain[0]); + ComputePanningGains(Device->Dry.AmbiCoeffs, Device->Dry.NumChannels, coeffs, + gain, state->Gain[0]); /* Second tap panning */ CalcXYZCoeffs( lrpan, 0.0f, 0.0f, coeffs); - ComputePanningGains(Device->AmbiCoeffs, Device->NumChannels, coeffs, gain, state->Gain[1]); + ComputePanningGains(Device->Dry.AmbiCoeffs, Device->Dry.NumChannels, coeffs, + gain, state->Gain[1]); } static ALvoid ALechoState_process(ALechoState *state, ALuint SamplesToDo, const ALfloat (*restrict SamplesIn)[BUFFERSIZE], ALfloat (*restrict SamplesOut)[BUFFERSIZE], ALuint NumChannels) diff --git a/Alc/effects/equalizer.c b/Alc/effects/equalizer.c index 051e8c7f..479a8536 100644 --- a/Alc/effects/equalizer.c +++ b/Alc/effects/equalizer.c @@ -103,7 +103,7 @@ static ALvoid ALequalizerState_update(ALequalizerState *state, const ALCdevice * aluMatrixf matrix; ALuint i; - gain = device->AmbiScale; + gain = device->Dry.AmbiScale; aluMatrixfSet(&matrix, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, gain, 0.0f, 0.0f, @@ -111,7 +111,7 @@ static ALvoid ALequalizerState_update(ALequalizerState *state, const ALCdevice * 0.0f, 0.0f, 0.0f, gain ); for(i = 0;i < MAX_EFFECT_CHANNELS;i++) - ComputeFirstOrderGains(device->AmbiCoeffs, device->NumChannels, + ComputeFirstOrderGains(device->Dry.AmbiCoeffs, device->Dry.NumChannels, matrix.m[i], slot->Gain, state->Gain[i]); /* Calculate coefficients for the each type of filter. Note that the shelf diff --git a/Alc/effects/flanger.c b/Alc/effects/flanger.c index 21536f04..d29e0f25 100644 --- a/Alc/effects/flanger.c +++ b/Alc/effects/flanger.c @@ -113,9 +113,11 @@ static ALvoid ALflangerState_update(ALflangerState *state, const ALCdevice *Devi /* Gains for left and right sides */ CalcXYZCoeffs(-1.0f, 0.0f, 0.0f, coeffs); - ComputePanningGains(Device->AmbiCoeffs, Device->NumChannels, coeffs, Slot->Gain, state->Gain[0]); + ComputePanningGains(Device->Dry.AmbiCoeffs, Device->Dry.NumChannels, coeffs, + Slot->Gain, state->Gain[0]); CalcXYZCoeffs( 1.0f, 0.0f, 0.0f, coeffs); - ComputePanningGains(Device->AmbiCoeffs, Device->NumChannels, coeffs, Slot->Gain, state->Gain[1]); + ComputePanningGains(Device->Dry.AmbiCoeffs, Device->Dry.NumChannels, coeffs, + Slot->Gain, state->Gain[1]); phase = Slot->EffectProps.Flanger.Phase; rate = Slot->EffectProps.Flanger.Rate; diff --git a/Alc/effects/modulator.c b/Alc/effects/modulator.c index cd6ccb22..4183b908 100644 --- a/Alc/effects/modulator.c +++ b/Alc/effects/modulator.c @@ -122,7 +122,7 @@ static ALvoid ALmodulatorState_update(ALmodulatorState *state, const ALCdevice * state->Filter[i].process = ALfilterState_processC; } - scale = Device->AmbiScale; + scale = Device->Dry.AmbiScale; aluMatrixfSet(&matrix, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, scale, 0.0f, 0.0f, @@ -130,7 +130,7 @@ static ALvoid ALmodulatorState_update(ALmodulatorState *state, const ALCdevice * 0.0f, 0.0f, 0.0f, scale ); for(i = 0;i < MAX_EFFECT_CHANNELS;i++) - ComputeFirstOrderGains(Device->AmbiCoeffs, Device->NumChannels, + ComputeFirstOrderGains(Device->Dry.AmbiCoeffs, Device->Dry.NumChannels, matrix.m[i], Slot->Gain, state->Gain[i]); } diff --git a/Alc/effects/reverb.c b/Alc/effects/reverb.c index a92fbd5b..a1b27876 100644 --- a/Alc/effects/reverb.c +++ b/Alc/effects/reverb.c @@ -681,7 +681,7 @@ static ALvoid UpdateMixedPanning(const ALCdevice *Device, const ALfloat *Reflect if(!(length > FLT_EPSILON)) { for(i = 0;i < Device->RealOut.NumChannels;i++) - State->Early.PanGain[i&3][Device->VirtOut.NumChannels+i] = Gain * EarlyGain; + State->Early.PanGain[i&3][Device->Dry.NumChannels+i] = Gain * EarlyGain; } else { @@ -697,11 +697,11 @@ static ALvoid UpdateMixedPanning(const ALCdevice *Device, const ALfloat *Reflect length = minf(length, 1.0f); CalcDirectionCoeffs(pan, coeffs); - ComputePanningGains(Device->AmbiCoeffs, Device->VirtOut.NumChannels, coeffs, Gain, DirGains); - for(i = 0;i < Device->VirtOut.NumChannels;i++) + ComputePanningGains(Device->Dry.AmbiCoeffs, Device->Dry.NumChannels, coeffs, Gain, DirGains); + for(i = 0;i < Device->Dry.NumChannels;i++) State->Early.PanGain[3][i] = DirGains[i] * EarlyGain * length; for(i = 0;i < Device->RealOut.NumChannels;i++) - State->Early.PanGain[i&3][Device->VirtOut.NumChannels+i] = Gain * EarlyGain * (1.0f-length); + State->Early.PanGain[i&3][Device->Dry.NumChannels+i] = Gain * EarlyGain * (1.0f-length); } memset(State->Late.PanGain, 0, sizeof(State->Late.PanGain)); @@ -709,7 +709,7 @@ static ALvoid UpdateMixedPanning(const ALCdevice *Device, const ALfloat *Reflect if(!(length > FLT_EPSILON)) { for(i = 0;i < Device->RealOut.NumChannels;i++) - State->Late.PanGain[i&3][Device->VirtOut.NumChannels+i] = Gain * LateGain; + State->Late.PanGain[i&3][Device->Dry.NumChannels+i] = Gain * LateGain; } else { @@ -721,11 +721,11 @@ static ALvoid UpdateMixedPanning(const ALCdevice *Device, const ALfloat *Reflect length = minf(length, 1.0f); CalcDirectionCoeffs(pan, coeffs); - ComputePanningGains(Device->AmbiCoeffs, Device->VirtOut.NumChannels, coeffs, Gain, DirGains); - for(i = 0;i < Device->VirtOut.NumChannels;i++) + ComputePanningGains(Device->Dry.AmbiCoeffs, Device->Dry.NumChannels, coeffs, Gain, DirGains); + for(i = 0;i < Device->Dry.NumChannels;i++) State->Late.PanGain[3][i] = DirGains[i] * LateGain * length; for(i = 0;i < Device->RealOut.NumChannels;i++) - State->Late.PanGain[i&3][Device->VirtOut.NumChannels+i] = Gain * LateGain * (1.0f-length); + State->Late.PanGain[i&3][Device->Dry.NumChannels+i] = Gain * LateGain * (1.0f-length); } } @@ -738,13 +738,14 @@ static ALvoid UpdateDirectPanning(const ALCdevice *Device, const ALfloat *Reflec ALuint i; /* Apply a boost of about 3dB to better match the expected stereo output volume. */ - ComputeAmbientGains(Device->AmbiCoeffs, Device->NumChannels, Gain*1.414213562f, AmbientGains); + ComputeAmbientGains(Device->Dry.AmbiCoeffs, Device->Dry.NumChannels, + Gain*1.414213562f, AmbientGains); memset(State->Early.PanGain, 0, sizeof(State->Early.PanGain)); length = sqrtf(ReflectionsPan[0]*ReflectionsPan[0] + ReflectionsPan[1]*ReflectionsPan[1] + ReflectionsPan[2]*ReflectionsPan[2]); if(!(length > FLT_EPSILON)) { - for(i = 0;i < Device->NumChannels;i++) + for(i = 0;i < Device->Dry.NumChannels;i++) State->Early.PanGain[i&3][i] = AmbientGains[i] * EarlyGain; } else @@ -761,8 +762,9 @@ static ALvoid UpdateDirectPanning(const ALCdevice *Device, const ALfloat *Reflec length = minf(length, 1.0f); CalcDirectionCoeffs(pan, coeffs); - ComputePanningGains(Device->AmbiCoeffs, Device->NumChannels, coeffs, Gain, DirGains); - for(i = 0;i < Device->NumChannels;i++) + ComputePanningGains(Device->Dry.AmbiCoeffs, Device->Dry.NumChannels, coeffs, + Gain, DirGains); + for(i = 0;i < Device->Dry.NumChannels;i++) State->Early.PanGain[i&3][i] = lerp(AmbientGains[i], DirGains[i], length) * EarlyGain; } @@ -770,7 +772,7 @@ static ALvoid UpdateDirectPanning(const ALCdevice *Device, const ALfloat *Reflec length = sqrtf(LateReverbPan[0]*LateReverbPan[0] + LateReverbPan[1]*LateReverbPan[1] + LateReverbPan[2]*LateReverbPan[2]); if(!(length > FLT_EPSILON)) { - for(i = 0;i < Device->NumChannels;i++) + for(i = 0;i < Device->Dry.NumChannels;i++) State->Late.PanGain[i&3][i] = AmbientGains[i] * LateGain; } else @@ -783,8 +785,9 @@ static ALvoid UpdateDirectPanning(const ALCdevice *Device, const ALfloat *Reflec length = minf(length, 1.0f); CalcDirectionCoeffs(pan, coeffs); - ComputePanningGains(Device->AmbiCoeffs, Device->NumChannels, coeffs, Gain, DirGains); - for(i = 0;i < Device->NumChannels;i++) + ComputePanningGains(Device->Dry.AmbiCoeffs, Device->Dry.NumChannels, coeffs, + Gain, DirGains); + for(i = 0;i < Device->Dry.NumChannels;i++) State->Late.PanGain[i&3][i] = lerp(AmbientGains[i], DirGains[i], length) * LateGain; } } @@ -833,7 +836,7 @@ static ALvoid Update3DPanning(const ALCdevice *Device, const ALfloat *Reflection for(i = 0;i < 4;i++) { CalcDirectionCoeffs(PanDirs[i], coeffs); - ComputePanningGains(Device->AmbiCoeffs, Device->NumChannels, coeffs, + ComputePanningGains(Device->Dry.AmbiCoeffs, Device->Dry.NumChannels, coeffs, Gain*EarlyGain*gain[i], State->Early.PanGain[i]); } @@ -864,7 +867,7 @@ static ALvoid Update3DPanning(const ALCdevice *Device, const ALfloat *Reflection for(i = 0;i < 4;i++) { CalcDirectionCoeffs(PanDirs[i], coeffs); - ComputePanningGains(Device->AmbiCoeffs, Device->NumChannels, coeffs, + ComputePanningGains(Device->Dry.AmbiCoeffs, Device->Dry.NumChannels, coeffs, Gain*LateGain*gain[i], State->Late.PanGain[i]); } } diff --git a/Alc/panning.c b/Alc/panning.c index b17df007..8ac1d4d2 100644 --- a/Alc/panning.c +++ b/Alc/panning.c @@ -426,9 +426,9 @@ static bool LoadChannelSetup(ALCdevice *device) for(j = 0;j < MAX_AMBI_COEFFS;++j) chanmap[i].Config[j] = coeffs[j]; } - SetChannelMap(device->ChannelName, device->AmbiCoeffs, chanmap, count, - &device->NumChannels, isfuma); - device->AmbiScale = ambiscale; + SetChannelMap(device->Dry.ChannelName, device->Dry.AmbiCoeffs, chanmap, count, + &device->Dry.NumChannels, isfuma); + device->Dry.AmbiScale = ambiscale; return true; } @@ -499,9 +499,9 @@ ALvoid aluInitPanning(ALCdevice *device) size_t count = 0; ALuint i; - device->AmbiScale = 1.0f; - memset(device->AmbiCoeffs, 0, sizeof(device->AmbiCoeffs)); - device->NumChannels = 0; + device->Dry.AmbiScale = 1.0f; + memset(device->Dry.AmbiCoeffs, 0, sizeof(device->Dry.AmbiCoeffs)); + device->Dry.NumChannels = 0; if(device->Hrtf) { @@ -525,14 +525,14 @@ ALvoid aluInitPanning(ALCdevice *device) ambiscale = FIRST_ORDER_SCALE; for(i = 0;i < count;i++) - device->ChannelName[i] = chanmap[i].ChanName; + device->Dry.ChannelName[i] = chanmap[i].ChanName; for(;i < MAX_OUTPUT_CHANNELS;i++) - device->ChannelName[i] = InvalidChannel; - SetChannelMap(device->ChannelName, device->AmbiCoeffs, chanmap, count, - &device->NumChannels, AL_TRUE); - device->AmbiScale = ambiscale; + device->Dry.ChannelName[i] = InvalidChannel; + SetChannelMap(device->Dry.ChannelName, device->Dry.AmbiCoeffs, chanmap, count, + &device->Dry.NumChannels, AL_TRUE); + device->Dry.AmbiScale = ambiscale; - for(i = 0;i < device->NumChannels;i++) + for(i = 0;i < device->Dry.NumChannels;i++) { int chan = GetChannelIdxByName(device, CubeInfo[i].Channel); GetLerpedHrtfCoeffs(device->Hrtf, CubeInfo[i].Elevation, CubeInfo[i].Angle, 1.0f, 1.0f, @@ -547,12 +547,12 @@ ALvoid aluInitPanning(ALCdevice *device) ambiscale = FIRST_ORDER_SCALE; for(i = 0;i < count;i++) - device->ChannelName[i] = chanmap[i].ChanName; + device->Dry.ChannelName[i] = chanmap[i].ChanName; for(;i < MAX_OUTPUT_CHANNELS;i++) - device->ChannelName[i] = InvalidChannel; - SetChannelMap(device->ChannelName, device->AmbiCoeffs, chanmap, count, - &device->NumChannels, AL_TRUE); - device->AmbiScale = ambiscale; + device->Dry.ChannelName[i] = InvalidChannel; + SetChannelMap(device->Dry.ChannelName, device->Dry.AmbiCoeffs, chanmap, count, + &device->Dry.NumChannels, AL_TRUE); + device->Dry.AmbiScale = ambiscale; return; } @@ -611,9 +611,9 @@ ALvoid aluInitPanning(ALCdevice *device) break; } - SetChannelMap(device->ChannelName, device->AmbiCoeffs, chanmap, count, - &device->NumChannels, AL_TRUE); - device->AmbiScale = ambiscale; + SetChannelMap(device->Dry.ChannelName, device->Dry.AmbiCoeffs, chanmap, count, + &device->Dry.NumChannels, AL_TRUE); + device->Dry.AmbiScale = ambiscale; } void aluInitEffectPanning(ALeffectslot *slot) diff --git a/OpenAL32/Include/alMain.h b/OpenAL32/Include/alMain.h index f79002fe..837b2be8 100644 --- a/OpenAL32/Include/alMain.h +++ b/OpenAL32/Include/alMain.h @@ -431,25 +431,25 @@ struct ALCdevice_struct ALCboolean Connected; enum DeviceType Type; - ALuint Frequency; - ALuint UpdateSize; - ALuint NumUpdates; + ALuint Frequency; + ALuint UpdateSize; + ALuint NumUpdates; enum DevFmtChannels FmtChans; enum DevFmtType FmtType; - ALboolean IsHeadphones; + ALboolean IsHeadphones; al_string DeviceName; ATOMIC(ALCenum) LastError; // Maximum number of sources that can be created - ALuint MaxNoOfSources; + ALuint MaxNoOfSources; // Maximum number of slots that can be created - ALuint AuxiliaryEffectSlotMax; + ALuint AuxiliaryEffectSlotMax; - ALCuint NumMonoSources; - ALCuint NumStereoSources; - ALuint NumAuxSends; + ALCuint NumMonoSources; + ALCuint NumStereoSources; + ALuint NumAuxSends; // Map of Buffers for this device UIntMap BufferMap; @@ -481,11 +481,6 @@ struct ALCdevice_struct // Device flags ALuint Flags; - enum Channel ChannelName[MAX_OUTPUT_CHANNELS]; - ChannelConfig AmbiCoeffs[MAX_OUTPUT_CHANNELS]; - ALfloat AmbiScale; /* Scale for first-order XYZ inputs using AmbCoeffs. */ - ALuint NumChannels; - ALuint64 ClockBase; ALuint SamplesDone; @@ -494,8 +489,19 @@ struct ALCdevice_struct alignas(16) ALfloat ResampledData[BUFFERSIZE]; alignas(16) ALfloat FilteredData[BUFFERSIZE]; - /* Dry path buffer mix (will be aliased by the virtual or real output). */ - alignas(16) ALfloat (*DryBuffer)[BUFFERSIZE]; + /* The "dry" path corresponds to the main output. */ + struct { + /* Channel names for the dry buffer mix. */ + enum Channel ChannelName[MAX_OUTPUT_CHANNELS]; + /* Ambisonic coefficients for mixing to the dry buffer. */ + ChannelConfig AmbiCoeffs[MAX_OUTPUT_CHANNELS]; + /* Scale for first-order XYZ inputs using AmbiCoeffs. */ + ALfloat AmbiScale; + + /* Dry buffer will be aliased by the virtual or real output. */ + ALfloat (*Buffer)[BUFFERSIZE]; + ALuint NumChannels; + } Dry; /* Virtual output, to be post-processed to the real output. */ struct { @@ -680,15 +686,15 @@ const ALCchar *DevFmtChannelsString(enum DevFmtChannels chans) DECL_CONST; /** * GetChannelIdxByName * - * Returns the device's channel index given a channel name (e.g. FrontCenter), - * or -1 if it doesn't exist. + * Returns the dry buffer's channel index for the given channel name (e.g. + * FrontCenter), or -1 if it doesn't exist. */ inline ALint GetChannelIdxByName(const ALCdevice *device, enum Channel chan) { ALint i = 0; for(i = 0;i < MAX_OUTPUT_CHANNELS;i++) { - if(device->ChannelName[i] == chan) + if(device->Dry.ChannelName[i] == chan) return i; } return -1; |