[Scummvm-git-logs] scummvm master -> bf3b87fb8e1b2c4bcc5961ce77aa8400dd3335fb
mgerhardy
martin.gerhardy at gmail.com
Mon Dec 7 08:16:12 UTC 2020
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
bf3b87fb8e TWINE: implemented Sound::setSamplePosition
Commit: bf3b87fb8e1b2c4bcc5961ce77aa8400dd3335fb
https://github.com/scummvm/scummvm/commit/bf3b87fb8e1b2c4bcc5961ce77aa8400dd3335fb
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-12-07T04:57:21+01:00
Commit Message:
TWINE: implemented Sound::setSamplePosition
should fix https://bugs.scummvm.org/ticket/12003 (Sound effects very loud for offscreen objects)
Changed paths:
engines/twine/sound.cpp
diff --git a/engines/twine/sound.cpp b/engines/twine/sound.cpp
index 638c60886d..fb875fd8f7 100644
--- a/engines/twine/sound.cpp
+++ b/engines/twine/sound.cpp
@@ -45,17 +45,21 @@ Sound::~Sound() {
_engine->_system->getMixer()->stopAll();
}
-void Sound::setSamplePosition(int32 chan, int32 x, int32 y, int32 z) {
- int32 distance;
- distance = ABS(_engine->_movements->getDistance3D(_engine->_grid->newCameraX << 9, _engine->_grid->newCameraY << 8, _engine->_grid->newCameraZ << 9, x, y, z));
+void Sound::setSamplePosition(int32 channelIdx, int32 x, int32 y, int32 z) {
+ if (channelIdx < 0 || channelIdx >= NUM_CHANNELS) {
+ return;
+ }
+ const int32 camX = _engine->_grid->newCameraX << 9;
+ const int32 camY = _engine->_grid->newCameraY << 8;
+ const int32 camZ = _engine->_grid->newCameraZ << 9;
+ int32 distance = _engine->_movements->getDistance3D(camX, camY, camZ, x, y, z);
distance = _engine->_collision->getAverageValue(0, distance, 10000, 255);
if (distance > 255) { // don't play it if its to far away
distance = 255;
}
-#if 0 // TODO
- Mix_SetDistance(chan, distance);
-#endif
+ const byte targetVolume = CLIP(255 - distance, 0, 255);
+ _engine->_system->getMixer()->setChannelVolume(samplesPlaying[channelIdx], targetVolume);
}
void Sound::playFlaSample(int32 index, int32 repeat, int32 x, int32 y) {
More information about the Scummvm-git-logs
mailing list