[Scummvm-cvs-logs] CVS: scummvm/scumm dialogs.cpp,1.25,1.26 imuse.cpp,1.82,1.83 sound.cpp,1.51,1.52

Jamieson Christian jamieson630 at users.sourceforge.net
Sun Nov 17 10:00:02 CET 2002


Update of /cvsroot/scummvm/scummvm/scumm
In directory usw-pr-cvs1:/tmp/cvs-serv19893/scummvm/scumm

Modified Files:
	dialogs.cpp imuse.cpp sound.cpp 
Log Message:
Fixes to Master/SFX/Music volumes:
- All are in 0-255 range now. No 0-127 mismatches.
- Master volume now affects SFX and Music, consistent with LEC behavior.
- The [ and ] keys now affect Music volume, not Master. Consistent with LEC behavior.
Also changed [ and ] increment to 16, for 256/16 = 16 volume increments outside the GUI.

Index: dialogs.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/dialogs.cpp,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -d -r1.25 -r1.26
--- dialogs.cpp	14 Nov 2002 13:17:15 -0000	1.25
+++ dialogs.cpp	17 Nov 2002 17:59:00 -0000	1.26
@@ -596,7 +596,7 @@
 			_scumm->_imuse->set_master_volume(_soundVolumeMaster);
 		}
 
-		_scumm->_mixer->setVolume(_soundVolumeSfx);
+		_scumm->_mixer->setVolume(_soundVolumeSfx * _soundVolumeMaster / 255);
 		_scumm->_mixer->setMusicVolume(_soundVolumeMusic);
 		
 		g_config->setInt("master_volume", _soundVolumeMaster);

Index: imuse.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/imuse.cpp,v
retrieving revision 1.82
retrieving revision 1.83
diff -u -d -r1.82 -r1.83
--- imuse.cpp	16 Nov 2002 14:23:22 -0000	1.82
+++ imuse.cpp	17 Nov 2002 17:59:00 -0000	1.83
@@ -407,8 +407,8 @@
 
 	byte _queue_marker;
 	byte _queue_cleared;
-	byte _master_volume;					/* Master volume. 0-127 */
-	byte _music_volume;						/* Global music volume. 0-128 */
+	byte _master_volume;					// Master volume. 0-255
+	byte _music_volume;						// Global music volume. 0-255
 
 	uint16 _trigger_count;
 	ImTrigger _snm_triggers[16];	// Sam & Max triggers
@@ -467,8 +467,6 @@
 	void lock();
 	void unlock();
 
-	int set_master_volume_intern(uint vol);
-
 public:
 	~IMuseInternal();
 
@@ -1142,7 +1140,7 @@
 {
 	if (a < 8)
 		return _channel_volume_eff[a];
-	return _master_volume;
+	return (_master_volume * _music_volume / 255) >> 1;
 }
 
 Part *IMuseInternal::allocate_part(byte pri)
@@ -1425,48 +1423,50 @@
 
 int IMuseInternal::get_music_volume()
 {
-	return _music_volume * 2;
+	return _music_volume;
 }
 
 int IMuseInternal::set_music_volume(uint vol)
 {
-	if (vol > 256)
-		vol = 256;
+	if (vol > 255)
+		vol = 255;
 	else if (vol < 0)
 		vol = 0;
 
-	_music_volume = vol / 2;
+	if (_music_volume == vol)
+		return 0;
+	_music_volume = vol;
+	vol = vol * _master_volume / 255;
+	for (int i = 0; i < ARRAYSIZE (_channel_volume); i++) {
+		_channel_volume_eff[i] = _channel_volume[i] * vol / 255;
+	}
+	if (!_paused)
+		update_volumes();
 	return 0;
 }
 
-int IMuseInternal::set_master_volume_intern(uint vol)
+int IMuseInternal::set_master_volume (uint vol)
 {
-	if (vol > 127)
-		return -1;
-
-	vol = vol * _music_volume / 128;
+	if (vol > 255)
+		vol = 255;
+	else if (vol < 0)
+		vol = 0;
+	if (_master_volume == vol)
+		return 0;
 
 	_master_volume = vol;
-	for (int i = 0; i != 8; i++)
-		_channel_volume_eff[i] = (_channel_volume[i] + 1) * vol >> 7;
+	vol = vol * _music_volume / 255;
+	for (int i = 0; i < ARRAYSIZE (_channel_volume); i++) {
+		_channel_volume_eff[i] = _channel_volume[i] * vol / 255;
+	}
 	if (!_paused)
 		update_volumes();
-
 	return 0;
 }
 
-int IMuseInternal::set_master_volume(uint vol)
-{
-	// recalibrate from 0-256 range
-	vol = vol * 127 / 256;
-
-	return set_master_volume_intern(vol);
-}
-
 int IMuseInternal::get_master_volume()
 {
-	// recalibrate to 0-256 range
-	return _master_volume * 256 / 127;
+	return _master_volume;
 }
 
 int IMuseInternal::terminate()
@@ -1519,9 +1519,12 @@
 	if (param == 0) {
 		switch (cmd) {
 		case 6:
-			return set_master_volume_intern(b);
+			if (b > 127)
+				return -1;
+			else
+				return set_master_volume ((b << 1) | (b ? 0 : 1)); // Convert b from 0-127 to 0-255
 		case 7:
-			return _master_volume;
+			return _master_volume >> 1; // Convert from 0-255 to 0-127
 		case 8:
 			return start_sound(b) ? 0 : -1;
 		case 9:
@@ -1731,7 +1734,7 @@
 		return -1;
 
 	_channel_volume[chan] = vol;
-	_channel_volume_eff[chan] = _master_volume * (vol + 1) >> 7;
+	_channel_volume_eff[chan] = _master_volume * _music_volume * vol / 255 / 255;
 	update_volumes();
 	return 0;
 }
@@ -1896,7 +1899,7 @@
 
 	driv->init(this, syst);
 
-	_master_volume = 127;
+	_master_volume = 255;
 	if (_music_volume < 1)
 		_music_volume = kDefaultMusicVolume;
 
@@ -1924,25 +1927,13 @@
 
 void IMuseInternal::pause(bool paused)
 {
-	lock();
-
-	int i;
-	Part *part;
-
-	for (i = ARRAYSIZE(_parts), part = _parts; i != 0; i--, part++) {
-		if (part->_player) {
-			if (paused) {
-				part->_vol_eff = 0;
-			} else {
-				part->set_vol(part->_vol);
-			}
-			part->changed(IMuseDriver::pcVolume);
-		}
-	}
+	int vol = _music_volume;
+	if (paused)
+		_music_volume = 0;
+	update_volumes();
+	_music_volume = vol;
 
 	_paused = paused;
-
-	unlock();
 }
 
 

Index: sound.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/sound.cpp,v
retrieving revision 1.51
retrieving revision 1.52
diff -u -d -r1.51 -r1.52
--- sound.cpp	13 Nov 2002 15:08:22 -0000	1.51
+++ sound.cpp	17 Nov 2002 17:59:00 -0000	1.52
@@ -700,7 +700,7 @@
 
 		_scumm->_imuse->set_master_volume(_sound_volume_master);
 		_scumm->_imuse->set_music_volume(_sound_volume_music);
-		_scumm->_mixer->setVolume(_sound_volume_sfx);
+		_scumm->_mixer->setVolume(_sound_volume_sfx * _sound_volume_master / 255);
 		_scumm->_mixer->setMusicVolume(_sound_volume_music);
 	}
 	_sfxFile = openSfxFile();





More information about the Scummvm-git-logs mailing list