aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2022-07-07 14:58:09 -0700
committerChris Robinson <[email protected]>2022-07-07 14:58:09 -0700
commitedadd221ea71b0fd4ba58d231c7aead85af118ec (patch)
treee747ad88d11ae63e40fd9e51fb232a0ac6ae3e72
parent43b0afdab4b4024001f8f7eb04aebf29bd72793e (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.
-rw-r--r--alc/panning.cpp22
-rw-r--r--alsoftrc.sample28
2 files changed, 29 insertions, 21 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()})
{
diff --git a/alsoftrc.sample b/alsoftrc.sample
index f2b17982..4ea548ce 100644
--- a/alsoftrc.sample
+++ b/alsoftrc.sample
@@ -305,22 +305,22 @@
## nfc:
# Enables near-field control filters. This simulates and compensates for low-
# frequency effects caused by the curvature of nearby sound-waves, which
-# creates a more realistic perception of sound distance. Note that the effect
-# may be stronger or weaker than intended if the application doesn't use or
-# specify an appropriate unit scale, or if incorrect speaker distances are set
-# in the decoder configuration file.
+# creates a more realistic perception of sound distance with surround sound
+# output. Note that the effect may be stronger or weaker than intended if the
+# application doesn't use or specify an appropriate unit scale, or if
+# incorrect speaker distances are set. For HRTF output, hrtf-mode must be set
+# to one of the ambi* values for this to function.
#nfc = false
-## nfc-ref-delay
-# Specifies the reference delay value for ambisonic output when NFC filters
-# are enabled. If channels is set to one of the ambi* formats, this option
-# enables NFC-HOA output with the specified Reference Delay parameter. The
-# specified value can then be shared with an appropriate NFC-HOA decoder to
-# reproduce correct near-field effects. Keep in mind that despite being
-# designed for higher-order ambisonics, this also applies to first-order
-# output. When left unset, normal output is created with no near-field
-# simulation. Requires the nfc option to also be enabled.
-#nfc-ref-delay =
+## speaker-dist:
+# Specifies the speaker distance in meters, used by the near-field control
+# filters with surround sound output. For ambisonic output modes, this value
+# is the basis for the NFC-HOA Reference Delay parameter (calculated as
+# delay_seconds = speaker_dist/343.3). This value is not used when a decoder
+# configuration is set for the output mode (since they specify the per-speaker
+# distances, overriding this setting), or when the NFC filters are off. Valid
+# values range from 0.1 to 10.
+#speaker-dist = 1
## quad:
# Decoder configuration file for Quadraphonic channel output. See