GRIM: Use the full volume range

This commit is contained in:
Bastien Bouclet 2012-02-09 12:04:59 +01:00
parent d372e62681
commit 6baf47fd65
4 changed files with 26 additions and 14 deletions

View File

@ -81,9 +81,9 @@ static const char HELP_STRING[] =
" -e, --music-driver=MODE Select music driver (see README for details)\n"
" -q, --language=LANG Select language (en,de,fr,it,pt,es,jp,zh,kr,se,gb,\n"
" hb,ru,cz)\n"
" -m, --music-volume=NUM Set the music volume, 0-127 (default: 127)\n"
" -s, --sfx-volume=NUM Set the sfx volume, 0-127 (default: 127)\n"
" -r, --speech-volume=NUM Set the speech volume, 0-127 (default: 127)\n"
" -m, --music-volume=NUM Set the music volume, 0-255 (default: 192)\n"
" -s, --sfx-volume=NUM Set the sfx volume, 0-255 (default: 192)\n"
" -r, --speech-volume=NUM Set the speech volume, 0-255 (default: 192)\n"
" --speech-mode=NUM Set the mode of speech 1-Text only, 2-Speech Only, 3-Speech and Text\n"
" --midi-gain=NUM Set the gain for MIDI playback, 0-1000 (default:\n"
" 100) (only supported by some MIDI drivers)\n"
@ -137,9 +137,9 @@ void registerDefaults() {
ConfMan.registerDefault("show_fps", "false");
// Sound & Music
ConfMan.registerDefault("music_volume", 127);
ConfMan.registerDefault("sfx_volume", 127);
ConfMan.registerDefault("speech_volume", 127);
ConfMan.registerDefault("music_volume", 192);
ConfMan.registerDefault("sfx_volume", 192);
ConfMan.registerDefault("speech_volume", 192);
ConfMan.registerDefault("speech_mute", false);
ConfMan.registerDefault("speech_mode", "3");
ConfMan.registerDefault("multi_midi", false);

View File

@ -104,7 +104,7 @@ GrimEngine::GrimEngine(OSystem *syst, uint32 gameFlags, GrimGameType gameType, C
_softRenderer = true;
#endif
_mixer->setVolumeForSoundType(Audio::Mixer::kPlainSoundType, 127);
_mixer->setVolumeForSoundType(Audio::Mixer::kPlainSoundType, 192);
_mixer->setVolumeForSoundType(Audio::Mixer::kSFXSoundType, ConfMan.getInt("sfx_volume"));
_mixer->setVolumeForSoundType(Audio::Mixer::kSpeechSoundType, ConfMan.getInt("speech_volume"));
_mixer->setVolumeForSoundType(Audio::Mixer::kMusicSoundType, ConfMan.getInt("music_volume"));

View File

@ -22,7 +22,7 @@
#include "engines/grim/registry.h"
#include "base/commandLine.h"
#include "audio/mixer.h"
#include "common/config-manager.h"
@ -55,9 +55,9 @@ Registry::Registry() : _dirty(true) {
_dataPath = ConfMan.get("path");
_savePath = ConfMan.get("savepath");
_lastSet = ConfMan.get("last_set");
_musicVolume = ConfMan.get("music_volume");
_sfxVolume = ConfMan.get("sfx_volume");
_voiceVolume = ConfMan.get("speech_volume");
_musicVolume = convertVolumeFromMixer(ConfMan.getInt("music_volume"));
_sfxVolume = convertVolumeFromMixer(ConfMan.getInt("sfx_volume"));
_voiceVolume = convertVolumeFromMixer(ConfMan.getInt("speech_volume"));
_lastSavedGame = ConfMan.get("last_saved_game");
_gamma = ConfMan.get("gamma");
_voiceEffects = ConfMan.get("voice_effects");
@ -188,9 +188,9 @@ void Registry::save() {
ConfMan.set("path", _dataPath);
ConfMan.set("savepath", _savePath);
ConfMan.set("last_set", _lastSet);
ConfMan.set("music_volume", _musicVolume);
ConfMan.set("sfx_volume", _sfxVolume);
ConfMan.set("speech_volume", _voiceVolume);
ConfMan.setInt("music_volume", convertVolumeToMixer(_musicVolume));
ConfMan.setInt("sfx_volume", convertVolumeToMixer(_sfxVolume));
ConfMan.setInt("speech_volume", convertVolumeToMixer(_voiceVolume));
ConfMan.set("last_saved_game", _lastSavedGame);
ConfMan.set("gamma", _gamma);
ConfMan.set("speech_effects", _voiceEffects);
@ -209,4 +209,12 @@ void Registry::save() {
_dirty = false;
}
uint Registry::convertVolumeToMixer(const Common::String &grimVolume) {
return CLIP<uint>(atoi(grimVolume.c_str()) * 2, 0, Audio::Mixer::kMaxMixerVolume);
}
Common::String Registry::convertVolumeFromMixer(uint volume) {
return Common::String::format("%d", CLIP<uint>(volume / 2, 0, 127));
}
} // end of namespace Grim

View File

@ -61,6 +61,10 @@ private:
Common::String _engineSpeed;
bool _dirty;
uint convertVolumeToMixer(const Common::String &volume);
Common::String convertVolumeFromMixer(uint volume);
};
extern Registry *g_registry;