From 6dd5de48f91a3c693432723eb083491c0c3d4d74 Mon Sep 17 00:00:00 2001 From: Max Horn Date: Sun, 28 Jul 2002 15:03:45 +0000 Subject: added constants for the default volumes; changed the volume ranges from 0-255 to 0-256 svn-id: r4670 --- sound/mixer.cpp | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'sound/mixer.cpp') 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(); -- cgit v1.2.3