Closed CallumCVM closed 11 months ago
@walbourn I checked the function EnableDefaultCurves that you mentioned and it sets a volume curve that is 1.0f at a distance of both 0.0f AND 1.0f (aka max volume regardless of distance). Is this intentional? It doesn't seem to match the description you gave of it having linear falloff.
EnableDefaultCurves is implemented based on this code from XACT:
if (SUCCEEDED(hr)) {
static X3DAUDIO_DISTANCE_CURVE_POINT DefaultCurvePoints[2] = { 0.0f, 1.0f, 1.0f, 1.0f };
static X3DAUDIO_DISTANCE_CURVE DefaultCurve = { (X3DAUDIO_DISTANCE_CURVE_POINT*)&DefaultCurvePoints[0], 2 };
if (pEmitter->pVolumeCurve == NULL) {
pEmitter->pVolumeCurve = &DefaultCurve;
}
if (pEmitter->pLFECurve == NULL) {
pEmitter->pLFECurve = &DefaultCurve;
}
X3DAudioCalculate(X3DInstance, pListener, pEmitter, (X3DAUDIO_CALCULATE_MATRIX | X3DAUDIO_CALCULATE_DOPPLER | X3DAUDIO_CALCULATE_EMITTER_ANGLE), pDSPSettings);
}
I see that my description of the default curve is probably wrong since it seems to turn off distance attenuation as you note. I'm not sure why as its' difficult to locate the old XACT docs these days and when you go look at them, they aren't really that detailed.
That said, the easy fix is to just use X3DAudioDefault_LinearCurve
from the x3daudio.h header. I'll look at adding a EnableLinearCurves helper as well.
Thanks @walbourn, I did indeed implement it using the curves myself already as you suggested. Thanks for the help, issue resolved.
Possibly also worth noting that the default curves (those used when not calling EnableDefaultCurves or setting curves manually) do also not have any attenuation/falloff (that I could notice). Hope this helps.
You control this through the standard
X3DAUDIO_LISTENER
andX3DAUDIO_EMITTER
structures. DirectX Tool Kit for Audio has derived helper classes AudioListener and AudioEmitter.The fall-off curves are provided via the
X3DAUDIO_EMITTER
structure per Microsoft Learn.Default curves are used if these pointers are
nullptr
per the documentation which are generally 'square-of-distance'. There is a helperAudioEmitter::EnableDefaultCurves
which will instead set a number of built-in curves which are consistent with those used by legacy XACT which uses linear falloff. You can also provide pointers to your own custom curves.https://github.com/microsoft/DirectXTK/wiki/AudioEmitter#custom-distance-curves