[Scummvm-cvs-logs] scummvm master -> b403a6f3ac6ba9210025fb3b6222272d54487d7e

dreammaster dreammaster at scummvm.org
Thu Nov 1 11:38:35 CET 2012


This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
79d7d3d708 TONY: fix volumes of sound effects.
b403a6f3ac Merge pull request #290 from rasky/fix_sfx_volumes


Commit: 79d7d3d708c0395c65448a6b8acd231a61bce0ca
    https://github.com/scummvm/scummvm/commit/79d7d3d708c0395c65448a6b8acd231a61bce0ca
Author: Giovanni Bajo (rasky at develer.com)
Date: 2012-10-26T11:29:04-07:00

Commit Message:
TONY: fix volumes of sound effects.

The game was using a logarithmic scale (through DirectSound)
so we need a log->linear conversion to feed the mixer.

Changed paths:
    engines/tony/sound.cpp



diff --git a/engines/tony/sound.cpp b/engines/tony/sound.cpp
index 20386d6..8697d7c 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;
 }


Commit: b403a6f3ac6ba9210025fb3b6222272d54487d7e
    https://github.com/scummvm/scummvm/commit/b403a6f3ac6ba9210025fb3b6222272d54487d7e
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2012-11-01T03:38:04-07:00

Commit Message:
Merge pull request #290 from rasky/fix_sfx_volumes

TONY: fix volumes of sound effects.

Changed paths:
    engines/tony/sound.cpp









More information about the Scummvm-git-logs mailing list