From 1671a83f55bee46ee57cc0c8869e943d67f14ea5 Mon Sep 17 00:00:00 2001 From: Andrew Eikum Date: Wed, 28 Dec 2016 14:02:54 -0600 Subject: [PATCH] dsound: Fix rolloff factor calculation. 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 Signed-off-by: Alexandre Julliard --- 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 b416cdc01e9..4f071258a2e 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 */