diff options
author | Max Horn | 2002-07-28 15:03:45 +0000 |
---|---|---|
committer | Max Horn | 2002-07-28 15:03:45 +0000 |
commit | 6dd5de48f91a3c693432723eb083491c0c3d4d74 (patch) | |
tree | eb8a34305616f7cf54e5fd60cc604f721ff87051 | |
parent | 14cd6ec272c5c854cc8a5990de8f8ba128847b01 (diff) | |
download | scummvm-rg350-6dd5de48f91a3c693432723eb083491c0c3d4d74.tar.gz scummvm-rg350-6dd5de48f91a3c693432723eb083491c0c3d4d74.tar.bz2 scummvm-rg350-6dd5de48f91a3c693432723eb083491c0c3d4d74.zip |
added constants for the default volumes; changed the volume ranges from 0-255 to 0-256
svn-id: r4670
-rw-r--r-- | gameDetector.cpp | 4 | ||||
-rw-r--r-- | gui/dialog.cpp | 6 | ||||
-rw-r--r-- | scumm.h | 6 | ||||
-rw-r--r-- | scummvm.cpp | 4 | ||||
-rw-r--r-- | sound.cpp | 6 | ||||
-rw-r--r-- | sound/imuse.cpp | 30 | ||||
-rw-r--r-- | sound/mixer.cpp | 19 |
7 files changed, 46 insertions, 29 deletions
diff --git a/gameDetector.cpp b/gameDetector.cpp index e273f8b121..4905ff347b 100644 --- a/gameDetector.cpp +++ b/gameDetector.cpp @@ -489,8 +489,8 @@ int GameDetector::detectMain(int argc, char **argv) #else _gfx_mode = GFX_NORMAL; #endif - _sfx_volume = 192; - _music_volume = 192; + _sfx_volume = kDefaultSFXVolume; + _music_volume = kDefaultMusicVolume; #if defined(USE_NULL_DRIVER) _gfx_driver = GD_NULL; diff --git a/gui/dialog.cpp b/gui/dialog.cpp index a6bb965f98..338bfc2db5 100644 --- a/gui/dialog.cpp +++ b/gui/dialog.cpp @@ -412,9 +412,9 @@ SoundDialog::SoundDialog(NewGui *gui) musicVolumeSlider = new SliderWidget(this, 110, 33, 80, 16, "Volume2", kMusicVolumeChanged); sfxVolumeSlider = new SliderWidget(this, 110, 53, 80, 16, "Volume3", kSfxVolumeChanged); - masterVolumeSlider->setMinValue(0); masterVolumeSlider->setMaxValue(255); - musicVolumeSlider->setMinValue(0); musicVolumeSlider->setMaxValue(255); - sfxVolumeSlider->setMinValue(0); sfxVolumeSlider->setMaxValue(255); + masterVolumeSlider->setMinValue(0); masterVolumeSlider->setMaxValue(256); + musicVolumeSlider->setMinValue(0); musicVolumeSlider->setMaxValue(256); + sfxVolumeSlider->setMinValue(0); sfxVolumeSlider->setMaxValue(256); masterVolumeLabel = new StaticTextWidget(this, 195, 17, 60, 16, "Volume1", kTextAlignLeft); musicVolumeLabel = new StaticTextWidget(this, 195, 37, 60, 16, "Volume2", kTextAlignLeft); @@ -61,6 +61,12 @@ enum { KEY_SET_OPTIONS = 3456 // WinCE }; +enum { + kDefaultMasterVolume = 192, + kDefaultSFXVolume = 192, + kDefaultMusicVolume = 192 +}; + struct ScummPoint { int x, y; }; diff --git a/scummvm.cpp b/scummvm.cpp index d9f96d0b38..d1c60cc260 100644 --- a/scummvm.cpp +++ b/scummvm.cpp @@ -1529,8 +1529,8 @@ Scumm *Scumm::createFromDetector(GameDetector *detector, OSystem *syst) warning("Adlib music was selected, switching to midi null driver"); } } - scumm->_mixer->set_volume(128); - scumm->_mixer->set_music_volume(128); + scumm->_mixer->set_volume(kDefaultSFXVolume); + scumm->_mixer->set_music_volume(kDefaultMusicVolume); /* HACK !!! */ g_scumm = scumm; @@ -588,9 +588,9 @@ void Scumm::setupSound() if (_imuse) { _imuse->setBase(res.address[rtSound]); - _sound_volume_music = scummcfg->getInt("music_volume", 192); - _sound_volume_master = scummcfg->getInt("master_volume", 192); - _sound_volume_sfx = scummcfg->getInt("sfx_volume", 192); + _sound_volume_music = scummcfg->getInt("music_volume", kDefaultMusicVolume); + _sound_volume_master = scummcfg->getInt("master_volume", kDefaultMasterVolume); + _sound_volume_sfx = scummcfg->getInt("sfx_volume", kDefaultSFXVolume); _imuse->set_master_volume(_sound_volume_master); _imuse->set_music_volume(_sound_volume_music); diff --git a/sound/imuse.cpp b/sound/imuse.cpp index 8e0e99e099..200a1ab008 100644 --- a/sound/imuse.cpp +++ b/sound/imuse.cpp @@ -342,8 +342,8 @@ private: byte _queue_marker; byte _queue_cleared; - byte _master_volume; - byte _music_volume; /* Global music volume. Percantage */ + byte _master_volume; /* Master volume. 0-127 */ + byte _music_volume; /* Global music volume. 0-128 */ uint16 _trigger_count; @@ -1250,20 +1250,17 @@ int IMuseInternal::query_queue(int param) int IMuseInternal::get_music_volume() { - return _music_volume; + return _music_volume * 2; } int IMuseInternal::set_music_volume(uint vol) { - // recalibrate from 0-255 range - vol = vol * 100 / 255; + if (vol > 256) + vol = 256; + else if (vol < 0) + vol = 0; - if (vol > 100) - vol = 100; - else if (vol < 1) - vol = 1; - - _music_volume = vol; + _music_volume = vol / 2; return 0; } @@ -1271,14 +1268,14 @@ int IMuseInternal::set_master_volume(uint vol) { int i; - // recalibrate from 0-255 range - vol = vol * 127 / 255; + // recalibrate from 0-256 range + vol = vol * 127 / 256; if (vol > 127) return -1; if (_music_volume > 0) - vol = vol / (100 / _music_volume); + vol = vol * _music_volume / 128; _master_volume = vol; for (i = 0; i != 8; i++) @@ -1289,7 +1286,8 @@ int IMuseInternal::set_master_volume(uint vol) int IMuseInternal::get_master_volume() { - return _master_volume; + // recalibrate to 0-256 range + return _master_volume * 256 / 127; } int IMuseInternal::terminate() @@ -1637,7 +1635,7 @@ int IMuseInternal::initialize(OSystem *syst, MidiDriver *midi, SoundMixer *mixer _master_volume = 127; if (_music_volume < 1) - _music_volume = 60; + _music_volume = kDefaultMusicVolume; for (i = 0; i != 8; i++) _channel_volume[i] = _channel_volume_eff[i] = _volchan_table[i] = 127; diff --git a/sound/mixer.cpp b/sound/mixer.cpp index 55c612ee29..545b10eb80 100644 --- a/sound/mixer.cpp +++ b/sound/mixer.cpp @@ -195,12 +195,24 @@ void SoundMixer::setup_premix(void *param, PremixProc *proc) void SoundMixer::set_volume(int volume) { - for (int i = 0; i != 256; i++) - _volume_table[i] = ((int8)i) * volume; + // Check range + if (volume > 256) + volume = 256; + else if (volume < 0) + volume = 0; + + for (int i = 0; i < 256; i++) + _volume_table[i] = (i + 1) * volume - 1; } void SoundMixer::set_music_volume(int volume) { + // Check range + if (volume > 256) + volume = 256; + else if (volume < 0) + volume = 0; + _music_volume = volume; } @@ -818,7 +830,8 @@ void SoundMixer::Channel_MP3_CDMUSIC::mix(int16 *data, uint len) { mad_fixed_t const *ch; mad_timer_t frame_duration; - unsigned char volume = _mixer->_music_volume * 32 / 255; +// unsigned char volume = _mixer->_music_volume * 32 / 255; + unsigned char volume = _mixer->_music_volume >> 3; if (_to_be_destroyed) { real_destroy(); |