diff options
author | Chris Robinson <[email protected]> | 2022-07-07 14:58:09 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2022-07-07 14:58:09 -0700 |
commit | edadd221ea71b0fd4ba58d231c7aead85af118ec (patch) | |
tree | e747ad88d11ae63e40fd9e51fb232a0ac6ae3e72 /alc | |
parent | 43b0afdab4b4024001f8f7eb04aebf29bd72793e (diff) |
Add a speaker-dist config option
This can be used to specify an average speaker distance without having the
modify the decoder config files. This also sets a default value of 1, letting
near-field effects work (if imprecisely) without an explicitly-configured
distance.
Diffstat (limited to 'alc')
-rw-r--r-- | alc/panning.cpp | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/alc/panning.cpp b/alc/panning.cpp index d0afd577..32ccd080 100644 --- a/alc/panning.cpp +++ b/alc/panning.cpp @@ -611,10 +611,16 @@ void InitPanning(ALCdevice *device, const bool hqdec=false, const bool stablize= { return BFChannelConfig{1.0f/n3dscale[acn], acn}; }); AllocChannels(device, count, 0); - float nfc_delay{device->configValue<float>("decoder", "nfc-ref-delay").value_or(0.0f)}; - if(nfc_delay > 0.0f) - InitNearFieldCtrl(device, nfc_delay * SpeedOfSoundMetersPerSec, device->mAmbiOrder, - true); + float avg_dist{}; + if(auto distopt = device->configValue<float>("decoder", "speaker-dist")) + avg_dist = *distopt; + else if(auto delayopt = device->configValue<float>("decoder", "nfc-ref-delay")) + { + WARN("nfc-ref-delay is deprecated, use speaker-dist instead\n"); + avg_dist = *delayopt * SpeedOfSoundMetersPerSec; + } + + InitNearFieldCtrl(device, avg_dist, device->mAmbiOrder, true); return; } } @@ -1016,11 +1022,13 @@ void aluInitRenderer(ALCdevice *device, int hrtf_id, al::optional<StereoEncoding spkr_count += 1.0f; } } + + const float avg_dist{(accum_dist > 0.0f && spkr_count > 0) ? accum_dist/spkr_count : + device->configValue<float>("decoder", "speaker-dist").value_or(1.0f)}; + InitNearFieldCtrl(device, avg_dist, decoder.mOrder, decoder.mIs3D); + if(spkr_count > 0) - { - InitNearFieldCtrl(device, accum_dist / spkr_count, decoder.mOrder, decoder.mIs3D); InitDistanceComp(device, decoder.mChannels, speakerdists); - } } if(auto *ambidec{device->AmbiDecoder.get()}) { |