NASSP icon indicating copy to clipboard operation
NASSP copied to clipboard

FadeInOutSound not working correctly at high frame rates

Open indy91 opened this issue 5 years ago • 1 comments

In the FadeInOutSound::play function in soundlib.cpp:

dt = oapiGetSimStep(); currentVolume -= int(round(double(fadeSlope) * dt));

If the frame rate is large enough, which makes dt a very small number, then the

round(double(fadeSlope) * dt)

part of the line rounds down to 0 and so currentVolume doesn't get decremented at all. Also depends on the magnitude of fadeSlope.

Potential fix is making currentVolume a double instead of an int and implementing some code that converts back to an integer safely before the Sound::play function is called. "ceil" instead of "round" just makes the fade in/out very fast at high framerates and would also make it a bit too fast at "normal" framerates, so that solution is not desirable.

indy91 avatar Oct 17 '20 18:10 indy91

Potentially fixed in PR #1170 with the latest 3 commits starting here: , which transition our volume to use a double precision floating point ranging from 0.0 to 1.0 instead of an integer from 0 to 255.

CaptainSwag101 avatar Mar 04 '24 22:03 CaptainSwag101

Closed via #1170.

CaptainSwag101 avatar Mar 10 '24 20:03 CaptainSwag101