aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorPaul Gilbert2012-11-01 03:38:04 -0700
committerPaul Gilbert2012-11-01 03:38:04 -0700
commitb403a6f3ac6ba9210025fb3b6222272d54487d7e (patch)
tree7568c131fbb42648a42dcee2de1ac0f0f8cc106b /engines
parentfdc80fd952120ecb8a4941edd4c2e404cdc5fa33 (diff)
parent79d7d3d708c0395c65448a6b8acd231a61bce0ca (diff)
downloadscummvm-rg350-b403a6f3ac6ba9210025fb3b6222272d54487d7e.tar.gz
scummvm-rg350-b403a6f3ac6ba9210025fb3b6222272d54487d7e.tar.bz2
scummvm-rg350-b403a6f3ac6ba9210025fb3b6222272d54487d7e.zip
Merge pull request #290 from rasky/fix_sfx_volumes
TONY: fix volumes of sound effects.
Diffstat (limited to 'engines')
-rw-r--r--engines/tony/sound.cpp24
1 files changed, 20 insertions, 4 deletions
diff --git a/engines/tony/sound.cpp b/engines/tony/sound.cpp
index 20386d6353..8697d7ce29 100644
--- a/engines/tony/sound.cpp
+++ b/engines/tony/sound.cpp
@@ -36,6 +36,19 @@
namespace Tony {
+/*
+ * Tony uses a [0,63] volume scale (where 0 is silent and 63 is loudest).
+ * The original game engine linearly mapped this scale into DirectSound's
+ * [-10000, 0] scale (where -10000 is silent), which is a logarithmic scale.
+ *
+ * This means that Tony's scale is logarithmic as well, and must be converted
+ * to the linear scale used by the mixer.
+ */
+static int remapVolume(int volume) {
+ double dsvol = (double)(63 - volume) * -10000.0 / 63.0;
+ return (int)((double)Audio::Mixer::kMaxChannelVolume * pow(10.0, dsvol / 2000.0) + 0.5);
+}
+
/****************************************************************************\
* FPSOUND Methods
\****************************************************************************/
@@ -104,6 +117,9 @@ void FPSound::setMasterVolume(int volume) {
if (!_soundSupported)
return;
+ // WORKAROUND: We don't use remapVolume() here, so that the main option screen exposes
+ // a linear scale to the user. This is an improvement over the original game
+ // where the user had to deal with a logarithmic volume scale.
g_system->getMixer()->setVolumeForSoundType(Audio::Mixer::kPlainSoundType, CLIP<int>(volume, 0, 63) * Audio::Mixer::kMaxChannelVolume / 63);
}
@@ -364,7 +380,7 @@ void FPSfx::setVolume(int volume) {
}
if (g_system->getMixer()->isSoundHandleActive(_handle))
- g_system->getMixer()->setChannelVolume(_handle, volume * Audio::Mixer::kMaxChannelVolume / 63);
+ g_system->getMixer()->setChannelVolume(_handle, remapVolume(volume));
}
/**
@@ -376,7 +392,7 @@ void FPSfx::setVolume(int volume) {
void FPSfx::getVolume(int *volumePtr) {
if (g_system->getMixer()->isSoundHandleActive(_handle))
- *volumePtr = g_system->getMixer()->getChannelVolume(_handle) * 63 / Audio::Mixer::kMaxChannelVolume;
+ *volumePtr = _lastVolume;
else
*volumePtr = 0;
}
@@ -669,7 +685,7 @@ void FPStream::setVolume(int volume) {
}
if (g_system->getMixer()->isSoundHandleActive(_handle))
- g_system->getMixer()->setChannelVolume(_handle, volume * Audio::Mixer::kMaxChannelVolume / 63);
+ g_system->getMixer()->setChannelVolume(_handle, remapVolume(volume));
}
/**
@@ -681,7 +697,7 @@ void FPStream::setVolume(int volume) {
void FPStream::getVolume(int *volumePtr) {
if (g_system->getMixer()->isSoundHandleActive(_handle))
- *volumePtr = g_system->getMixer()->getChannelVolume(_handle) * 63 / Audio::Mixer::kMaxChannelVolume;
+ *volumePtr = _lastVolume;
else
*volumePtr = 0;
}