[Scummvm-cvs-logs] SF.net SVN: scummvm: [33065] scummvm/branches/gsoc2008-rtl/engines

cpage88 at users.sourceforge.net cpage88 at users.sourceforge.net
Tue Jul 15 00:10:05 CEST 2008


Revision: 33065
          http://scummvm.svn.sourceforge.net/scummvm/?rev=33065&view=rev
Author:   cpage88
Date:     2008-07-14 15:10:04 -0700 (Mon, 14 Jul 2008)

Log Message:
-----------
AGOS: Got rid of _masterVolume and replaced with _musicVolume and _sfxVolume so that music and sfx are separately controlled via the Options menu

Modified Paths:
--------------
    scummvm/branches/gsoc2008-rtl/engines/agos/agos.cpp
    scummvm/branches/gsoc2008-rtl/engines/agos/input.cpp
    scummvm/branches/gsoc2008-rtl/engines/agos/midi.cpp
    scummvm/branches/gsoc2008-rtl/engines/agos/midi.h
    scummvm/branches/gsoc2008-rtl/engines/scumm/scumm.cpp

Modified: scummvm/branches/gsoc2008-rtl/engines/agos/agos.cpp
===================================================================
--- scummvm/branches/gsoc2008-rtl/engines/agos/agos.cpp	2008-07-14 21:04:42 UTC (rev 33064)
+++ scummvm/branches/gsoc2008-rtl/engines/agos/agos.cpp	2008-07-14 22:10:04 UTC (rev 33065)
@@ -572,7 +572,7 @@
 		if (ret)
 			warning("MIDI Player init failed: \"%s\"", _midi.getErrorName (ret));
 
-		_midi.setVolume(ConfMan.getInt("music_volume"));
+		_midi.setVolume(ConfMan.getInt("music_volume"), ConfMan.getInt("sfx_volume"));
 
 
 		_midiEnabled = true;
@@ -1083,7 +1083,8 @@
 void AGOSEngine::syncSoundSettings() {
 	_mixer->setVolumeForSoundType(Audio::Mixer::kSFXSoundType, ConfMan.getInt("sfx_volume"));
 	_mixer->setVolumeForSoundType(Audio::Mixer::kMusicSoundType, ConfMan.getInt("music_volume"));
-	_midi.setVolume(ConfMan.getInt("music_volume"));
+	_mixer->setVolumeForSoundType(Audio::Mixer::kSpeechSoundType, ConfMan.getInt("speech_volume"));
+	_midi.setVolume(ConfMan.getInt("music_volume"), ConfMan.getInt("sfx_volume"));
 }
 
 } // End of namespace AGOS

Modified: scummvm/branches/gsoc2008-rtl/engines/agos/input.cpp
===================================================================
--- scummvm/branches/gsoc2008-rtl/engines/agos/input.cpp	2008-07-14 21:04:42 UTC (rev 33064)
+++ scummvm/branches/gsoc2008-rtl/engines/agos/input.cpp	2008-07-14 22:10:04 UTC (rev 33065)
@@ -563,14 +563,14 @@
 	case Common::KEYCODE_PLUS:
 	case Common::KEYCODE_KP_PLUS:
 		if (_midiEnabled) {
-			_midi.setVolume(_midi.getVolume() + 16);
+			_midi.setVolume(_midi.getMusicVolume() + 16, _midi.getSFXVolume() + 16);
 		}
 		_mixer->setVolumeForSoundType(Audio::Mixer::kMusicSoundType, _mixer->getVolumeForSoundType(Audio::Mixer::kMusicSoundType) + 16);
 		break;
 	case Common::KEYCODE_MINUS:
 	case Common::KEYCODE_KP_MINUS:
 		if (_midiEnabled) {
-			_midi.setVolume(_midi.getVolume() - 16);
+			_midi.setVolume(_midi.getMusicVolume() - 16, _midi.getSFXVolume() - 16);
 		}
 		_mixer->setVolumeForSoundType(Audio::Mixer::kMusicSoundType, _mixer->getVolumeForSoundType(Audio::Mixer::kMusicSoundType) - 16);
 		break;

Modified: scummvm/branches/gsoc2008-rtl/engines/agos/midi.cpp
===================================================================
--- scummvm/branches/gsoc2008-rtl/engines/agos/midi.cpp	2008-07-14 21:04:42 UTC (rev 33064)
+++ scummvm/branches/gsoc2008-rtl/engines/agos/midi.cpp	2008-07-14 22:10:04 UTC (rev 33065)
@@ -49,7 +49,9 @@
 	_enable_sfx = true;
 	_current = 0;
 
-	_masterVolume = 255;
+	_musicVolume = 255;
+	_sfxVolume = 255;
+
 	resetVolumeTable();
 	_paused = false;
 
@@ -104,10 +106,13 @@
 
 	byte channel = (byte)(b & 0x0F);
 	if ((b & 0xFFF0) == 0x07B0) {
-		// Adjust volume changes by master volume.
+		// Adjust volume changes by master music and master sfx volume.
 		byte volume = (byte)((b >> 16) & 0x7F);
 		_current->volume[channel] = volume;
-		volume = volume * _masterVolume / 255;
+		if (_current == &_sfx)
+			volume = volume * _sfxVolume / 255;
+		else if (_current == &_music)
+			volume = volume * _musicVolume / 255;
 		b = (b & 0xFF00FFFF) | (volume << 16);
 	} else if ((b & 0xF0) == 0xC0 && _map_mt32_to_gm) {
 		b = (b & 0xFFFF00FF) | (MidiDriver::_mt32ToGm[(b >> 8) & 0xFF] << 8);
@@ -133,8 +138,12 @@
 	if (!_current->channel[channel])
 		_current->channel[channel] = (channel == 9) ? _driver->getPercussionChannel() : _driver->allocateChannel();
 	if (_current->channel[channel]) {
-		if (channel == 9)
-			_current->channel[9]->volume(_current->volume[9] * _masterVolume / 255);
+		if (channel == 9) {
+			if (_current == &_sfx)
+				_current->channel[9]->volume(_current->volume[9] * _sfxVolume / 255);
+			else if (_current == &_music)
+				_current->channel[9]->volume(_current->volume[9] * _musicVolume / 255);
+		}
 		_current->channel[channel]->send(b);
 		if ((b & 0xFFF0) == 0x79B0) {
 			// We have received a "Reset All Controllers" message
@@ -143,7 +152,10 @@
 			// consistent behaviour, explicitly set the volume to
 			// what we think it should be.
 
-			_current->channel[channel]->volume(_current->volume[channel] * _masterVolume / 255);
+			if (_current == &_sfx)
+				_current->channel[channel]->volume(_current->volume[channel] * _sfxVolume / 255);
+			else if (_current == &_music)
+				_current->channel[channel]->volume(_current->volume[channel] * _musicVolume / 255);
 		}
 	}
 }
@@ -255,30 +267,36 @@
 	Common::StackLock lock(_mutex);
 	for (int i = 0; i < 16; ++i) {
 		if (_music.channel[i])
-			_music.channel[i]->volume(_paused ? 0 : (_music.volume[i] * _masterVolume / 255));
+			_music.channel[i]->volume(_paused ? 0 : (_music.volume[i] * _musicVolume / 255));
 		if (_sfx.channel[i])
-			_sfx.channel[i]->volume(_paused ? 0 : (_sfx.volume[i] * _masterVolume / 255));
+			_sfx.channel[i]->volume(_paused ? 0 : (_sfx.volume[i] * _sfxVolume / 255));
 	}
 }
 
-void MidiPlayer::setVolume(int volume) {
-	if (volume < 0)
-		volume = 0;
-	else if (volume > 255)
-		volume = 255;
+void MidiPlayer::setVolume(int musicVol, int sfxVol) {
+	if (musicVol < 0)
+		musicVol = 0;
+	else if (musicVol > 255)
+		musicVol = 255;
+	if (sfxVol < 0)
+		sfxVol = 0;
+	else if (sfxVol > 255)
+		sfxVol = 255;
 
-	if (_masterVolume == volume)
+	if (_musicVolume == musicVol && _sfxVolume == sfxVol)
 		return;
-	_masterVolume = volume;
 
+	_musicVolume = musicVol;
+	_sfxVolume = sfxVol;
+
 	// Now tell all the channels this.
 	Common::StackLock lock(_mutex);
 	if (_driver && !_paused) {
 		for (int i = 0; i < 16; ++i) {
 			if (_music.channel[i])
-				_music.channel[i]->volume(_music.volume[i] * _masterVolume / 255);
+				_music.channel[i]->volume(_music.volume[i] * _musicVolume / 255);
 			if (_sfx.channel[i])
-				_sfx.channel[i]->volume(_sfx.volume[i] * _masterVolume / 255);
+				_sfx.channel[i]->volume(_sfx.volume[i] * _sfxVolume / 255);
 		}
 	}
 }
@@ -354,7 +372,7 @@
 	for (i = 0; i < 16; ++i) {
 		_music.volume[i] = _sfx.volume[i] = 127;
 		if (_driver)
-			_driver->send(((_masterVolume >> 1) << 16) | 0x7B0 | i);
+			_driver->send(((_musicVolume >> 1) << 16) | 0x7B0 | i);
 	}
 }
 

Modified: scummvm/branches/gsoc2008-rtl/engines/agos/midi.h
===================================================================
--- scummvm/branches/gsoc2008-rtl/engines/agos/midi.h	2008-07-14 21:04:42 UTC (rev 33064)
+++ scummvm/branches/gsoc2008-rtl/engines/agos/midi.h	2008-07-14 22:10:04 UTC (rev 33065)
@@ -68,6 +68,8 @@
 
 	// These are maintained for both music and SFX
 	byte _masterVolume;    // 0-255
+	byte _musicVolume;
+	byte _sfxVolume;
 	bool _paused;
 
 	// These are only used for music.
@@ -103,8 +105,9 @@
 	void stop();
 	void pause(bool b);
 
-	int  getVolume() { return _masterVolume; }
-	void setVolume(int volume);
+	int  getMusicVolume() { return _musicVolume; }
+	int  getSFXVolume() { return _sfxVolume; }
+	void setVolume(int musicVol, int sfxVol);
 	void setDriver(MidiDriver *md);
 
 public:

Modified: scummvm/branches/gsoc2008-rtl/engines/scumm/scumm.cpp
===================================================================
--- scummvm/branches/gsoc2008-rtl/engines/scumm/scumm.cpp	2008-07-14 21:04:42 UTC (rev 33064)
+++ scummvm/branches/gsoc2008-rtl/engines/scumm/scumm.cpp	2008-07-14 22:10:04 UTC (rev 33065)
@@ -1673,7 +1673,6 @@
 		_musicEngine->setMusicVolume(soundVolumeMusic);
 	}
 
-	_mixer->setVolumeForSoundType(Audio::Mixer::kPlainSoundType, soundVolumeMusic);
 	_mixer->setVolumeForSoundType(Audio::Mixer::kSFXSoundType, soundVolumeSfx);
 	_mixer->setVolumeForSoundType(Audio::Mixer::kMusicSoundType, soundVolumeMusic);
 	_mixer->setVolumeForSoundType(Audio::Mixer::kSpeechSoundType, soundVolumeSpeech);


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list