[PATCH 1/2] dsound: Fix rolloff factor calculation
Andrew Eikum
aeikum at codeweavers.com
Wed Dec 28 14:02:54 CST 2016
We should treat the rolloff factor as a factor of the distance of the
buffer. For example, a rolloff factor of 2 should treat the buffer as if
it were twice as far away from the listener as it is.
The previous calculation would instead double the decibels of
attenuation.
Signed-off-by: Andrew Eikum <aeikum at codeweavers.com>
---
This mostly fixes Bug 42090, which is a regression caused by
2edb4bf320f5c. It probably needs an implementation of the doppler
effect for a full fix.
dlls/dsound/sound3d.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/dlls/dsound/sound3d.c b/dlls/dsound/sound3d.c
index b416cdc01e..4f071258a2 100644
--- a/dlls/dsound/sound3d.c
+++ b/dlls/dsound/sound3d.c
@@ -205,9 +205,11 @@ void DSOUND_Calc3DBuffer(IDirectSoundBufferImpl *dsb)
if (flDistance < dsb->ds3db_ds3db.flMinDistance)
flDistance = dsb->ds3db_ds3db.flMinDistance;
+
+ flDistance = dsb->ds3db_ds3db.flMinDistance + (flDistance - dsb->ds3db_ds3db.flMinDistance) * dsb->device->ds3dl.flRolloffFactor;
/* attenuation proportional to the distance squared, converted to millibels as in lVolume*/
- lVolume -= log10(flDistance/dsb->ds3db_ds3db.flMinDistance * flDistance/dsb->ds3db_ds3db.flMinDistance)*1000 * dsb->device->ds3dl.flRolloffFactor;
+ lVolume -= log10(flDistance/dsb->ds3db_ds3db.flMinDistance * flDistance/dsb->ds3db_ds3db.flMinDistance)*1000;
TRACE("dist. att: Distance = %f, MinDistance = %f => adjusting volume %d to %f\n", flDistance, dsb->ds3db_ds3db.flMinDistance, dsb->ds3db_lVolume, lVolume);
/* conning */
--
2.11.0
More information about the wine-patches
mailing list