aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorPaul Gilbert2018-05-04 21:46:39 -0400
committerPaul Gilbert2018-05-04 21:46:39 -0400
commit9db2f3cd8412faaa4771a17a8479f107e54e148f (patch)
treec1f8ed76556fe952139fa2be8017a732b4b227a6 /engines
parent8fdf592fe12760150bffd309ed0839d8107c75cb (diff)
downloadscummvm-rg350-9db2f3cd8412faaa4771a17a8479f107e54e148f.tar.gz
scummvm-rg350-9db2f3cd8412faaa4771a17a8479f107e54e148f.tar.bz2
scummvm-rg350-9db2f3cd8412faaa4771a17a8479f107e54e148f.zip
XEEN: In progress splitting of music and sfx volumes in sound driver
Diffstat (limited to 'engines')
-rw-r--r--engines/xeen/sound.cpp39
-rw-r--r--engines/xeen/sound.h8
-rw-r--r--engines/xeen/sound_driver.cpp19
-rw-r--r--engines/xeen/sound_driver.h11
4 files changed, 45 insertions, 32 deletions
diff --git a/engines/xeen/sound.cpp b/engines/xeen/sound.cpp
index 9800af5403..ae70c1f5d8 100644
--- a/engines/xeen/sound.cpp
+++ b/engines/xeen/sound.cpp
@@ -29,7 +29,8 @@
namespace Xeen {
Sound::Sound(Audio::Mixer *mixer) : _mixer(mixer), _fxOn(true), _musicOn(true), _subtitles(false),
- _songData(nullptr), _effectsData(nullptr), _musicSide(0), _musicPercent(100) {
+ _songData(nullptr), _effectsData(nullptr), _musicSide(0), _musicPercent(100),
+ _musicVolume(0), _sfxVolume(0) {
_SoundDriver = new AdlibSoundDriver();
}
@@ -106,18 +107,6 @@ void Sound::setFxOn(bool isOn) {
g_vm->syncSoundSettings();
}
-void Sound::updateSoundSettings() {
- _fxOn = !ConfMan.getBool("sfx_mute");
- if (!_fxOn)
- stopFX();
-
- _musicOn = !ConfMan.getBool("music_mute");
- if (!_musicOn)
- stopSong();
-
- _subtitles = ConfMan.hasKey("subtitles") ? ConfMan.getBool("subtitles") : true;
-}
-
void Sound::loadEffectsData() {
// Stop any prior FX
stopFX();
@@ -160,8 +149,8 @@ void Sound::stopFX() {
_SoundDriver->stopFX();
}
-int Sound::songCommand(uint commandId, byte volume) {
- int result = _SoundDriver->songCommand(commandId, volume);
+int Sound::songCommand(uint commandId, byte musicVolume, byte sfxVolume) {
+ int result = _SoundDriver->songCommand(commandId, musicVolume, sfxVolume);
if (commandId == STOP_SONG) {
delete[] _songData;
_songData = nullptr;
@@ -212,8 +201,26 @@ void Sound::setMusicPercent(byte percent) {
assert(percent <= 100);
_musicPercent = percent;
- songCommand(SET_VOLUME, (int)percent * 127 / 100);
+ updateVolume();
}
+void Sound::updateSoundSettings() {
+ _fxOn = !ConfMan.getBool("sfx_mute");
+ if (!_fxOn)
+ stopFX();
+
+ _musicOn = !ConfMan.getBool("music_mute");
+ if (!_musicOn)
+ stopSong();
+
+ _subtitles = ConfMan.hasKey("subtitles") ? ConfMan.getBool("subtitles") : true;
+ _musicVolume = CLIP(ConfMan.getInt("music_volume"), 0, 255);
+ _sfxVolume = CLIP(ConfMan.getInt("sfx_volume"), 0, 255);
+ updateVolume();
+}
+
+void Sound::updateVolume() {
+ songCommand(SET_VOLUME, _musicPercent * _musicVolume / 100, _sfxVolume);
+}
} // End of namespace Xeen
diff --git a/engines/xeen/sound.h b/engines/xeen/sound.h
index 86303f682f..613299c6dc 100644
--- a/engines/xeen/sound.h
+++ b/engines/xeen/sound.h
@@ -40,6 +40,7 @@ private:
Audio::Mixer *_mixer;
Audio::SoundHandle _soundHandle;
byte _musicPercent;
+ int _musicVolume, _sfxVolume;
private:
/**
* Loads effects data that was embedded in the music driver
@@ -50,6 +51,11 @@ private:
* Updates any playing music
*/
void update();
+
+ /**
+ * Updates the music and sound effects playing volume
+ */
+ void updateVolume();
public:
bool _fxOn;
bool _musicOn;
@@ -73,7 +79,7 @@ public:
/**
* Executes special music command
*/
- int songCommand(uint commandId, byte volume = 0);
+ int songCommand(uint commandId, byte musicVolume = 0, byte sfxVolume = 0);
/**
* Stops any currently playing music
diff --git a/engines/xeen/sound_driver.cpp b/engines/xeen/sound_driver.cpp
index e79fcdd501..967f53ac49 100644
--- a/engines/xeen/sound_driver.cpp
+++ b/engines/xeen/sound_driver.cpp
@@ -225,7 +225,7 @@ void SoundDriver::playSong(const byte *data) {
debugC(1, kDebugSound, "Starting song");
}
-int SoundDriver::songCommand(uint commandId, byte volume) {
+int SoundDriver::songCommand(uint commandId, byte musicVolume, byte sfxVolume) {
if (commandId == STOP_SONG) {
_musicPlaying = false;
} else if (commandId == RESTART_SONG) {
@@ -262,7 +262,7 @@ const CommandFn SoundDriver::FX_COMMANDS[16] = {
/*------------------------------------------------------------------------*/
AdlibSoundDriver::AdlibSoundDriver() : _field180(0), _field181(0), _field182(0),
- _volume(127) {
+ _musicVolume(0), _sfxVolume(0) {
Common::fill(&_musInstrumentPtrs[0], &_musInstrumentPtrs[16], (const byte *)nullptr);
Common::fill(&_fxInstrumentPtrs[0], &_fxInstrumentPtrs[16], (const byte *)nullptr);
@@ -304,9 +304,9 @@ void AdlibSoundDriver::playSong(const byte *data) {
resetFrequencies();
}
-int AdlibSoundDriver::songCommand(uint commandId, byte volume) {
+int AdlibSoundDriver::songCommand(uint commandId, byte musicVolume, byte sfxVolume) {
Common::StackLock slock(_driverMutex);
- SoundDriver::songCommand(commandId, volume);
+ SoundDriver::songCommand(commandId, musicVolume, sfxVolume);
if (commandId == STOP_SONG) {
_field180 = 0;
@@ -320,7 +320,8 @@ int AdlibSoundDriver::songCommand(uint commandId, byte volume) {
_field182 = 63;
}
} else if (commandId == SET_VOLUME) {
- _volume = volume;
+ _musicVolume = musicVolume;
+ _sfxVolume = sfxVolume;
} else if (commandId == GET_STATUS) {
return _field180;
}
@@ -428,7 +429,7 @@ void AdlibSoundDriver::setOutputLevel(byte channelNum, uint level) {
(_channels[channelNum]._scalingValue & 0xC0));
}
-void AdlibSoundDriver::playInstrument(byte channelNum, const byte *data) {
+void AdlibSoundDriver::playInstrument(byte channelNum, const byte *data, byte volume) {
byte op1 = OPERATOR1_INDEXES[channelNum];
byte op2 = OPERATOR2_INDEXES[channelNum];
debugC(2, kDebugSound, "---START-playInstrument - %d", channelNum);
@@ -441,7 +442,7 @@ void AdlibSoundDriver::playInstrument(byte channelNum, const byte *data) {
int scalingVal = *data++;
_channels[channelNum]._scalingValue = scalingVal;
- scalingVal += (127 - _volume) / 2;
+ scalingVal += (127 - volume) / 2;
if (scalingVal > 63) {
scalingVal = 63;
@@ -535,7 +536,7 @@ bool AdlibSoundDriver::musPlayInstrument(const byte *&srcP, byte param) {
debugC(3, kDebugSound, "musPlayInstrument %d, %d", param, instrument);
if (param < 7)
- playInstrument(param, _musInstrumentPtrs[instrument]);
+ playInstrument(param, _musInstrumentPtrs[instrument], _musicVolume);
return false;
}
@@ -633,7 +634,7 @@ bool AdlibSoundDriver::fxPlayInstrument(const byte *&srcP, byte param) {
debugC(3, kDebugSound, "fxPlayInstrument %d, %d", param, instrument);
if (!_exclude7 || param != 7)
- playInstrument(param, _fxInstrumentPtrs[instrument]);
+ playInstrument(param, _fxInstrumentPtrs[instrument], _sfxVolume);
return false;
}
diff --git a/engines/xeen/sound_driver.h b/engines/xeen/sound_driver.h
index c78408b047..d4edd49c05 100644
--- a/engines/xeen/sound_driver.h
+++ b/engines/xeen/sound_driver.h
@@ -40,8 +40,7 @@ namespace OPL {
namespace Xeen {
enum MusicCommand {
- STOP_SONG = 0, RESTART_SONG = 1, SET_VOLUME = 0x100,
- GET_STATUS = 0xFFE0
+ STOP_SONG = 0, RESTART_SONG = 1, SET_VOLUME = 0x100, GET_STATUS = 0xFFE0
};
class SoundDriver;
@@ -170,7 +169,7 @@ public:
/**
* Executes special music command
*/
- virtual int songCommand(uint commandId, byte volume = 0);
+ virtual int songCommand(uint commandId, byte musicVolume = 0, byte sfxVolume = 0);
/**
* Returns whether music is currently playing
@@ -200,7 +199,7 @@ private:
int _field180;
int _field181;
int _field182;
- int _volume;
+ int _musicVolume, _sfxVolume;
private:
/**
* Initializes the state of the Adlib OPL driver
@@ -246,7 +245,7 @@ private:
/**
* Starts playing an instrument
*/
- void playInstrument(byte channelNum, const byte *data);
+ void playInstrument(byte channelNum, const byte *data, byte volume);
protected:
virtual bool musSetInstrument(const byte *&srcP, byte param);
virtual bool musSetPitchWheel(const byte *&srcP, byte param);
@@ -301,7 +300,7 @@ public:
/**
* Executes special music command
*/
- virtual int songCommand(uint commandId, byte volume = 0);
+ virtual int songCommand(uint commandId, byte musicVolume = 0, byte sfxVolume = 0);
};
} // End of namespace Xeen