aboutsummaryrefslogtreecommitdiff
path: root/sound
diff options
context:
space:
mode:
authorMax Horn2002-07-28 15:03:45 +0000
committerMax Horn2002-07-28 15:03:45 +0000
commit6dd5de48f91a3c693432723eb083491c0c3d4d74 (patch)
treeeb8a34305616f7cf54e5fd60cc604f721ff87051 /sound
parent14cd6ec272c5c854cc8a5990de8f8ba128847b01 (diff)
downloadscummvm-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
Diffstat (limited to 'sound')
-rw-r--r--sound/imuse.cpp30
-rw-r--r--sound/mixer.cpp19
2 files changed, 30 insertions, 19 deletions
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();