aboutsummaryrefslogtreecommitdiffstats
path: root/al/source.cpp
diff options
context:
space:
mode:
authorBoris I. Bendovsky <[email protected]>2022-07-15 15:14:55 +0300
committerBoris I. Bendovsky <[email protected]>2022-07-17 21:06:41 +0300
commit7e9c0285b45d9f7b3af9c72fc62fb1e00d18fe70 (patch)
treec49490b1c783285412229a54dee300303a1453cd /al/source.cpp
parent6f3500f458bdcce254d65095ed949119302b6c38 (diff)
[EAX_SOURCE] Fix source's occlusion and exclusion contribution
Source's oclussion and exclusion properties should be taken into account only for listener's environment (see p. 16, p. 56, pp. 62-63 and p. 64 of "EAX® 4.0 Programmer’s Guide").
Diffstat (limited to 'al/source.cpp')
-rw-r--r--al/source.cpp61
1 files changed, 44 insertions, 17 deletions
diff --git a/al/source.cpp b/al/source.cpp
index 6483473d..8856bafc 100644
--- a/al/source.cpp
+++ b/al/source.cpp
@@ -4016,27 +4016,44 @@ EaxAlLowPassParam ALsource::eax_create_direct_filter_param() const noexcept
eax_.source.flOcclusionDirectRatio,
eax_.source.flOcclusionLFRatio);
+ const auto has_source_occlusion = (eax_.source.lOcclusion != 0);
+
auto gain_hf_mb =
static_cast<float>(eax_.source.lDirectHF) +
- static_cast<float>(eax_.source.lObstruction) +
- (static_cast<float>(eax_.source.lOcclusion) * eax_.source.flOcclusionDirectRatio);
+ static_cast<float>(eax_.source.lObstruction);
for (auto i = std::size_t{}; i < EAX_MAX_FXSLOTS; ++i)
{
if(!eax_active_fx_slots_[i])
continue;
- const auto& send = eax_.sends[i];
+ if(has_source_occlusion) {
+ const auto& fx_slot = eax_al_context_->eax_get_fx_slot(i);
+ const auto& fx_slot_eax = fx_slot.eax_get_eax_fx_slot();
+ const auto is_environmental_fx = ((fx_slot_eax.ulFlags & EAXFXSLOTFLAGS_ENVIRONMENT) != 0);
+ const auto is_primary = (eax_primary_fx_slot_id_.value_or(-1) == fx_slot.eax_get_index());
+ const auto is_listener_environment = (is_environmental_fx && is_primary);
- if(send.lOcclusion == 0)
- continue;
+ if(is_listener_environment) {
+ gain_mb += eax_calculate_dst_occlusion_mb(
+ eax_.source.lOcclusion,
+ eax_.source.flOcclusionDirectRatio,
+ eax_.source.flOcclusionLFRatio);
- gain_mb += eax_calculate_dst_occlusion_mb(
- send.lOcclusion,
- send.flOcclusionDirectRatio,
- send.flOcclusionLFRatio);
+ gain_hf_mb += static_cast<float>(eax_.source.lOcclusion) * eax_.source.flOcclusionDirectRatio;
+ }
+ }
- gain_hf_mb += static_cast<float>(send.lOcclusion) * send.flOcclusionDirectRatio;
+ const auto& send = eax_.sends[i];
+
+ if(send.lOcclusion != 0) {
+ gain_mb += eax_calculate_dst_occlusion_mb(
+ send.lOcclusion,
+ send.flOcclusionDirectRatio,
+ send.flOcclusionLFRatio);
+
+ gain_hf_mb += static_cast<float>(send.lOcclusion) * send.flOcclusionDirectRatio;
+ }
}
const auto al_low_pass_param = EaxAlLowPassParam{
@@ -4052,27 +4069,37 @@ EaxAlLowPassParam ALsource::eax_create_room_filter_param(
{
const auto& fx_slot_eax = fx_slot.eax_get_eax_fx_slot();
const auto is_environmental_fx = ((fx_slot_eax.ulFlags & EAXFXSLOTFLAGS_ENVIRONMENT) != 0);
+ const auto is_primary = (eax_primary_fx_slot_id_.value_or(-1) == fx_slot.eax_get_index());
+ const auto is_listener_environment = (is_environmental_fx && is_primary);
const auto gain_mb =
(static_cast<float>(fx_slot_eax.lOcclusion) * fx_slot_eax.flOcclusionLFRatio) +
static_cast<float>((is_environmental_fx ? eax_.source.lRoom : 0) + send.lSend) +
- eax_calculate_dst_occlusion_mb(
- eax_.source.lOcclusion,
- eax_.source.flOcclusionRoomRatio,
- eax_.source.flOcclusionLFRatio) +
+ (is_listener_environment ?
+ eax_calculate_dst_occlusion_mb(
+ eax_.source.lOcclusion,
+ eax_.source.flOcclusionRoomRatio,
+ eax_.source.flOcclusionLFRatio) :
+ 0.0f) +
eax_calculate_dst_occlusion_mb(
send.lOcclusion,
send.flOcclusionRoomRatio,
send.flOcclusionLFRatio) +
- (static_cast<float>(eax_.source.lExclusion) * eax_.source.flExclusionLFRatio) +
+ (is_listener_environment ?
+ (static_cast<float>(eax_.source.lExclusion) * eax_.source.flExclusionLFRatio) :
+ 0.0f) +
(static_cast<float>(send.lExclusion) * send.flExclusionLFRatio);
const auto gain_hf_mb =
static_cast<float>(fx_slot_eax.lOcclusion) +
static_cast<float>((is_environmental_fx ? eax_.source.lRoomHF : 0) + send.lSendHF) +
- (static_cast<float>(eax_.source.lOcclusion) * eax_.source.flOcclusionRoomRatio) +
+ (is_listener_environment ?
+ ((static_cast<float>(eax_.source.lOcclusion) * eax_.source.flOcclusionRoomRatio)) :
+ 0.0f) +
(static_cast<float>(send.lOcclusion) * send.flOcclusionRoomRatio) +
- static_cast<float>(eax_.source.lExclusion + send.lExclusion);
+ (is_listener_environment ?
+ static_cast<float>(eax_.source.lExclusion + send.lExclusion) :
+ 0.0f);
const auto al_low_pass_param = EaxAlLowPassParam{
level_mb_to_gain(gain_mb),