aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--scumm/dialogs.cpp27
-rw-r--r--scumm/imuse.cpp17
-rw-r--r--scumm/imuse.h3
-rw-r--r--scumm/imuse_digi/dimuse.h2
-rw-r--r--scumm/imuse_internal.h4
-rw-r--r--scumm/input.cpp6
-rw-r--r--scumm/music.h2
-rw-r--r--scumm/player_mod.cpp2
-rw-r--r--scumm/player_mod.h2
-rw-r--r--scumm/player_v2.cpp4
-rw-r--r--scumm/player_v2.h2
-rw-r--r--scumm/player_v2a.cpp4
-rw-r--r--scumm/player_v2a.h2
-rw-r--r--scumm/player_v3a.cpp4
-rw-r--r--scumm/player_v3a.h2
-rw-r--r--scumm/saveload.cpp5
-rw-r--r--scumm/script_v6he.cpp2
-rw-r--r--scumm/scumm.cpp41
-rw-r--r--scumm/scumm.h1
19 files changed, 65 insertions, 67 deletions
diff --git a/scumm/dialogs.cpp b/scumm/dialogs.cpp
index 26ad9f8cf8..292301a615 100644
--- a/scumm/dialogs.cpp
+++ b/scumm/dialogs.cpp
@@ -462,31 +462,8 @@ void ConfigDialog::close() {
}
GUI_OptionsDialog::close();
-
- // Sync the engine with the config manager
- int soundVolumeMaster = ConfMan.getInt("master_volume");
- int soundVolumeMusic = ConfMan.getInt("music_volume");
- int soundVolumeSfx = ConfMan.getInt("sfx_volume");
- int soundVolumeSpeech = ConfMan.getInt("speech_volume");
-
- if (_vm->_imuseDigital) {
- _vm->_mixer->setVolume(soundVolumeMaster);
- _vm->_imuseDigital->setGroupMusicVolume(soundVolumeMusic / 2);
- _vm->_imuseDigital->setGroupSfxVolume(soundVolumeSfx / 2);
- _vm->_imuseDigital->setGroupVoiceVolume(soundVolumeSpeech / 2);
- return;
- }
-
- if (_vm->_imuse) {
- _vm->_imuse->set_music_volume(soundVolumeMusic);
- }
-
- if (_vm->_musicEngine) {
- _vm->_musicEngine->setMasterVolume(soundVolumeMaster);
- }
-
- _vm->_mixer->setVolume(soundVolumeSfx * soundVolumeMaster / 255);
- _vm->_mixer->setMusicVolume(soundVolumeMusic);
+
+ _vm->setupVolumes();
}
diff --git a/scumm/imuse.cpp b/scumm/imuse.cpp
index dd4f304d63..bdbb8c40d2 100644
--- a/scumm/imuse.cpp
+++ b/scumm/imuse.cpp
@@ -566,13 +566,13 @@ int IMuseInternal::query_queue(int param) {
}
}
-int IMuseInternal::set_music_volume(uint vol) {
+int IMuseInternal::setMusicVolume(uint vol) {
if (vol > 255)
vol = 255;
if (_music_volume == vol)
return 0;
_music_volume = vol;
- vol = vol * _master_volume / 255;
+ vol = _master_volume * _music_volume / 255;
for (uint i = 0; i < ARRAYSIZE(_channel_volume); i++) {
_channel_volume_eff[i] = _channel_volume[i] * vol / 255;
}
@@ -581,13 +581,13 @@ int IMuseInternal::set_music_volume(uint vol) {
return 0;
}
-int IMuseInternal::setMasterVolume(uint vol) {
+int IMuseInternal::setImuseMasterVolume(uint vol) {
if (vol > 255)
vol = 255;
if (_master_volume == vol)
return 0;
_master_volume = vol;
- vol = vol * _music_volume / 255;
+ vol = _master_volume * _music_volume / 255;
for (uint i = 0; i < ARRAYSIZE(_channel_volume); i++) {
_channel_volume_eff[i] = _channel_volume[i] * vol / 255;
}
@@ -685,8 +685,8 @@ int32 IMuseInternal::doCommand (int numargs, int a[]) {
if (a[1] > 127)
return -1;
else {
- warning ("IMuse doCommand(6) - setMasterVolume (%d)", a[1]);
- return setMasterVolume((a[1] << 1) |(a[1] ? 0 : 1)); // Convert from 0-127 to 0-255
+ warning ("IMuse doCommand(6) - setImuseMasterVolume (%d)", a[1]);
+ return setImuseMasterVolume((a[1] << 1) |(a[1] ? 0 : 1)); // Convert from 0-127 to 0-255
}
case 7:
warning ("IMuse doCommand(7) - getMasterVolume (%d)", a[1]);
@@ -1378,7 +1378,7 @@ int IMuseInternal::save_or_load(Serializer *ser, ScummEngine *scumm) {
// Load all sounds that we need
fix_players_after_load(scumm);
fix_parts_after_load();
- setMasterVolume(_master_volume);
+ setImuseMasterVolume(_master_volume);
if (_midi_native)
reallocateMidiChannels(_midi_native);
@@ -1745,8 +1745,7 @@ inline void IMuse::out() const { _system->unlockMutex(_mutex); }
void IMuse::on_timer(MidiDriver *midi) { in(); _target->on_timer(midi); out(); }
void IMuse::pause(bool paused) { in(); _target->pause(paused); out(); }
int IMuse::save_or_load(Serializer *ser, ScummEngine *scumm) { in(); int ret = _target->save_or_load(ser, scumm); out(); return ret; }
-int IMuse::set_music_volume(uint vol) { in(); int ret = _target->set_music_volume(vol); out(); return ret; }
-void IMuse::setMasterVolume(int vol) { in(); _target->setMasterVolume(vol); out(); }
+void IMuse::setMusicVolume(int vol) { in(); _target->setMusicVolume(vol); out(); }
void IMuse::startSound(int sound) { in(); _target->startSound(sound); out(); }
void IMuse::stopSound(int sound) { in(); _target->stopSound(sound); out(); }
void IMuse::stopAllSounds() { in(); _target->stopAllSounds(); out(); }
diff --git a/scumm/imuse.h b/scumm/imuse.h
index 3362f46079..e66aa472f7 100644
--- a/scumm/imuse.h
+++ b/scumm/imuse.h
@@ -61,8 +61,7 @@ public:
void on_timer(MidiDriver *midi);
void pause(bool paused);
int save_or_load(Serializer *ser, ScummEngine *scumm);
- int set_music_volume(uint vol);
- void setMasterVolume(int vol);
+ void setMusicVolume(int vol);
void startSound(int sound);
void stopSound(int sound);
void stopAllSounds();
diff --git a/scumm/imuse_digi/dimuse.h b/scumm/imuse_digi/dimuse.h
index d145e28376..b744718df6 100644
--- a/scumm/imuse_digi/dimuse.h
+++ b/scumm/imuse_digi/dimuse.h
@@ -154,7 +154,7 @@ public:
void setVolume(int soundId, int volume);
void setPan(int soundId, int pan);
void setFade(int soundId, int destVolume, int delay60HzTicks);
- void setMasterVolume(int vol) {}
+ void setMusicVolume(int vol) {}
void stopSound(int sound);
void stopAllSounds();
void pause(bool pause);
diff --git a/scumm/imuse_internal.h b/scumm/imuse_internal.h
index 7beced1692..7729d64766 100644
--- a/scumm/imuse_internal.h
+++ b/scumm/imuse_internal.h
@@ -450,8 +450,8 @@ public:
int terminate1();
int terminate2();
int save_or_load(Serializer *ser, ScummEngine *scumm);
- int set_music_volume(uint vol);
- int setMasterVolume(uint vol);
+ int setMusicVolume(uint vol);
+ int setImuseMasterVolume(uint vol);
bool startSound(int sound);
int stopSound(int sound);
int stopAllSounds();
diff --git a/scumm/input.cpp b/scumm/input.cpp
index 6263c00d06..9780831915 100644
--- a/scumm/input.cpp
+++ b/scumm/input.cpp
@@ -382,15 +382,13 @@ void ScummEngine::processKbd(bool smushMode) {
vol -= 16;
vol = vol & 0xF0;
ConfMan.set("music_volume", vol);
- if (_imuse)
- _imuse->set_music_volume (vol);
+ setupVolumes();
} else if (_lastKeyHit == ']') { // ] Music volume up
int vol = ConfMan.getInt("music_volume");
vol = (vol + 16) & 0xFF0;
if (vol > 255) vol = 255;
ConfMan.set("music_volume", vol);
- if (_imuse)
- _imuse->set_music_volume (vol);
+ setupVolumes();
} else if (_lastKeyHit == '-') { // - text speed down
if (_defaultTalkDelay < 9)
_defaultTalkDelay++;
diff --git a/scumm/music.h b/scumm/music.h
index ce0658ff26..27db7d747f 100644
--- a/scumm/music.h
+++ b/scumm/music.h
@@ -45,7 +45,7 @@ public:
* Set the output volume.
* @param vol the new output volume
*/
- virtual void setMasterVolume(int vol) = 0;
+ virtual void setMusicVolume(int vol) = 0;
/**
* Start playing the sound with the given id.
diff --git a/scumm/player_mod.cpp b/scumm/player_mod.cpp
index 61f4d700d2..c41f7c015a 100644
--- a/scumm/player_mod.cpp
+++ b/scumm/player_mod.cpp
@@ -59,7 +59,7 @@ Player_MOD::~Player_MOD() {
}
}
-void Player_MOD::setMasterVolume(int vol) {
+void Player_MOD::setMusicVolume(int vol) {
_maxvol = vol;
}
diff --git a/scumm/player_mod.h b/scumm/player_mod.h
index 8169ec7059..35d322e971 100644
--- a/scumm/player_mod.h
+++ b/scumm/player_mod.h
@@ -38,7 +38,7 @@ class Player_MOD : public AudioStream {
public:
Player_MOD(ScummEngine *scumm);
virtual ~Player_MOD();
- virtual void setMasterVolume(int vol);
+ virtual void setMusicVolume(int vol);
virtual void startChannel(int id, void *data, int size, int rate, uint8 vol, int loopStart = 0, int loopEnd = 0, int8 pan = 0);
virtual void stopChannel(int id);
diff --git a/scumm/player_v2.cpp b/scumm/player_v2.cpp
index c1b2a6b428..218dedbe46 100644
--- a/scumm/player_v2.cpp
+++ b/scumm/player_v2.cpp
@@ -374,7 +374,7 @@ Player_V2::Player_V2(ScummEngine *scumm, bool pcjr) {
_RNG = NG_PRESET;
set_pcjr(pcjr);
- setMasterVolume(255);
+ setMusicVolume(255);
_mixer->setupPremix(this);
}
@@ -416,7 +416,7 @@ void Player_V2::set_pcjr(bool pcjr) {
mutex_down();
}
-void Player_V2::setMasterVolume (int vol) {
+void Player_V2::setMusicVolume (int vol) {
if (vol > 255)
vol = 255;
diff --git a/scumm/player_v2.h b/scumm/player_v2.h
index 473df64e13..4f9c3939cf 100644
--- a/scumm/player_v2.h
+++ b/scumm/player_v2.h
@@ -78,7 +78,7 @@ public:
Player_V2(ScummEngine *scumm, bool pcjr);
virtual ~Player_V2();
- virtual void setMasterVolume(int vol);
+ virtual void setMusicVolume(int vol);
virtual void startSound(int sound);
virtual void stopSound(int sound);
virtual void stopAllSounds();
diff --git a/scumm/player_v2a.cpp b/scumm/player_v2a.cpp
index 216d2ad168..9a593c5cab 100644
--- a/scumm/player_v2a.cpp
+++ b/scumm/player_v2a.cpp
@@ -1178,8 +1178,8 @@ Player_V2A::~Player_V2A() {
#endif
}
-void Player_V2A::setMasterVolume (int vol) {
- _mod->setMasterVolume(vol);
+void Player_V2A::setMusicVolume (int vol) {
+ _mod->setMusicVolume(vol);
}
int Player_V2A::getSoundSlot (int id) const {
diff --git a/scumm/player_v2a.h b/scumm/player_v2a.h
index 2e72c65ce9..901f8f687c 100644
--- a/scumm/player_v2a.h
+++ b/scumm/player_v2a.h
@@ -43,7 +43,7 @@ public:
Player_V2A(ScummEngine *scumm);
virtual ~Player_V2A();
- virtual void setMasterVolume(int vol);
+ virtual void setMusicVolume(int vol);
virtual void startSound(int sound);
virtual void stopSound(int sound);
virtual void stopAllSounds();
diff --git a/scumm/player_v3a.cpp b/scumm/player_v3a.cpp
index cc25d2482f..52865cc5b8 100644
--- a/scumm/player_v3a.cpp
+++ b/scumm/player_v3a.cpp
@@ -75,8 +75,8 @@ Player_V3A::~Player_V3A() {
}
}
-void Player_V3A::setMasterVolume (int vol) {
- _mod->setMasterVolume(vol);
+void Player_V3A::setMusicVolume (int vol) {
+ _mod->setMusicVolume(vol);
}
int Player_V3A::getMusChan (int id) const {
diff --git a/scumm/player_v3a.h b/scumm/player_v3a.h
index ba330387be..99cb6fde07 100644
--- a/scumm/player_v3a.h
+++ b/scumm/player_v3a.h
@@ -42,7 +42,7 @@ public:
Player_V3A(ScummEngine *scumm);
virtual ~Player_V3A();
- virtual void setMasterVolume(int vol);
+ virtual void setMusicVolume(int vol);
virtual void startSound(int sound);
virtual void stopSound(int sound);
virtual void stopAllSounds();
diff --git a/scumm/saveload.cpp b/scumm/saveload.cpp
index 381da99c59..d4ee6c2d62 100644
--- a/scumm/saveload.cpp
+++ b/scumm/saveload.cpp
@@ -870,13 +870,14 @@ void ScummEngine::saveOrLoad(Serializer *s, uint32 savegameVersion) {
if (_imuse && (_saveSound || !_saveTemporaryState)) {
_imuse->save_or_load(s, this);
- _imuse->setMasterVolume(ConfMan.getInt("master_volume"));
- _imuse->set_music_volume(ConfMan.getInt("music_volume"));
}
if (_imuseDigital) {
_imuseDigital->saveOrLoad(s);
}
+
+ if (s->isLoading())
+ setupVolumes();
}
void ScummEngine::saveLoadResource(Serializer *ser, int type, int idx) {
diff --git a/scumm/script_v6he.cpp b/scumm/script_v6he.cpp
index 9ac4019aee..a8602475b9 100644
--- a/scumm/script_v6he.cpp
+++ b/scumm/script_v6he.cpp
@@ -1159,7 +1159,7 @@ void ScummEngine_v60he::o60_soundOps() {
int arg = pop();
switch (subOp) {
case 0xde:
- _imuse->set_music_volume(arg);
+ _imuse->setMusicVolume(arg);
break;
case 0xdf:
// Used in fbear introduction
diff --git a/scumm/scumm.cpp b/scumm/scumm.cpp
index 29a4681e44..f207fee4b8 100644
--- a/scumm/scumm.cpp
+++ b/scumm/scumm.cpp
@@ -1091,8 +1091,7 @@ int ScummEngine::init(GameDetector &detector) {
if (_imuse) {
_imuse->setBase(res.address[rtSound]);
- _imuse->setMasterVolume(ConfMan.getInt("master_volume"));
- _imuse->set_music_volume(ConfMan.getInt("music_volume"));
+ _imuse->setMusicVolume(ConfMan.getInt("music_volume"));
}
_sound->setupSound();
@@ -1326,16 +1325,10 @@ void ScummEngine::setupMusic(int midi) {
warning("MIDI driver depends on sound mixer, switching to null MIDI driver");
}
}
- _mixer->setVolume(ConfMan.getInt("sfx_volume") * ConfMan.getInt("master_volume") / 255);
- _mixer->setMusicVolume(ConfMan.getInt("music_volume"));
// Init iMuse
if (_features & GF_DIGI_IMUSE) {
_musicEngine = _imuseDigital = new IMuseDigital(this, 10);
- _mixer->setVolume(ConfMan.getInt("master_volume"));
- _imuseDigital->setGroupMusicVolume(ConfMan.getInt("music_volume") / 2);
- _imuseDigital->setGroupSfxVolume(ConfMan.getInt("sfx_volume") / 2);
- _imuseDigital->setGroupVoiceVolume(ConfMan.getInt("speech_volume") / 2);
} else if ((_features & GF_AMIGA) && (_version == 2)) {
_musicEngine = new Player_V2A(this);
} else if ((_features & GF_AMIGA) && (_version == 3)) {
@@ -1367,12 +1360,42 @@ void ScummEngine::setupMusic(int midi) {
}
if (midi == MDT_TOWNS)
_imuse->property(IMuse::PROP_DIRECT_PASSTHROUGH, 1);
- _imuse->set_music_volume(ConfMan.getInt("music_volume"));
}
}
+
+ setupVolumes();
+
#endif // ph0x-hack
}
+void ScummEngine::setupVolumes() {
+
+ // Sync the engine with the config manager
+ int soundVolumeMaster = ConfMan.getInt("master_volume");
+ int soundVolumeMusic = ConfMan.getInt("music_volume");
+ int soundVolumeSfx = ConfMan.getInt("sfx_volume");
+ int soundVolumeSpeech = ConfMan.getInt("speech_volume");
+
+ if (_imuse) {
+ _imuse->setMusicVolume(soundVolumeMusic);
+ }
+
+ if (_musicEngine) {
+ _musicEngine->setMusicVolume(soundVolumeMusic);
+ }
+
+ _mixer->setVolume(soundVolumeSfx * soundVolumeMaster / 255);
+ _mixer->setMusicVolume(soundVolumeMusic);
+
+ if (_imuseDigital) {
+ _mixer->setVolume(soundVolumeMaster);
+ _imuseDigital->setGroupMusicVolume(soundVolumeMusic / 2);
+ _imuseDigital->setGroupSfxVolume(soundVolumeSfx / 2);
+ _imuseDigital->setGroupVoiceVolume(soundVolumeSpeech / 2);
+ }
+}
+
+
#pragma mark -
#pragma mark --- Main loop ---
diff --git a/scumm/scumm.h b/scumm/scumm.h
index f6974feb45..79ece5d928 100644
--- a/scumm/scumm.h
+++ b/scumm/scumm.h
@@ -393,6 +393,7 @@ public:
void loadCJKFont();
void setupMusic(int midi);
+ void setupVolumes();
// Scumm main loop
int scummLoop(int delta);