SCI: Handle master volume inside music drivers
svn-id: r47261
This commit is contained in:
parent
dc45c729a9
commit
1a570df5dc
9 changed files with 53 additions and 18 deletions
|
@ -178,6 +178,8 @@ Common::Error SciEngine::run() {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
syncSoundSettings();
|
||||||
|
|
||||||
_gamestate->_gui->init(_gamestate->usesOldGfxFunctions());
|
_gamestate->_gui->init(_gamestate->usesOldGfxFunctions());
|
||||||
|
|
||||||
debug("Emulating SCI version %s\n", getSciVersionDesc(getSciVersion()).c_str());
|
debug("Emulating SCI version %s\n", getSciVersionDesc(getSciVersion()).c_str());
|
||||||
|
@ -187,6 +189,8 @@ Common::Error SciEngine::run() {
|
||||||
game_exit(_gamestate);
|
game_exit(_gamestate);
|
||||||
script_free_breakpoints(_gamestate);
|
script_free_breakpoints(_gamestate);
|
||||||
|
|
||||||
|
ConfMan.flushToDisk();
|
||||||
|
|
||||||
delete _gamestate->_soundCmd;
|
delete _gamestate->_soundCmd;
|
||||||
delete _gamestate->_gui;
|
delete _gamestate->_gui;
|
||||||
delete _gamestate->_event;
|
delete _gamestate->_event;
|
||||||
|
@ -281,4 +285,21 @@ void SciEngine::pauseEngineIntern(bool pause) {
|
||||||
_mixer->pauseAll(pause);
|
_mixer->pauseAll(pause);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SciEngine::syncSoundSettings() {
|
||||||
|
Engine::syncSoundSettings();
|
||||||
|
|
||||||
|
#ifndef USE_OLD_MUSIC_FUNCTIONS
|
||||||
|
bool mute = false;
|
||||||
|
if (ConfMan.hasKey("mute"))
|
||||||
|
mute = ConfMan.getBool("mute");
|
||||||
|
|
||||||
|
int soundVolumeMusic = (mute ? 0 : ConfMan.getInt("music_volume"));
|
||||||
|
|
||||||
|
if (_gamestate && _gamestate->_soundCmd) {
|
||||||
|
int vol = (soundVolumeMusic + 1) * SoundCommandParser::kMaxSciVolume / Audio::Mixer::kMaxMixerVolume;
|
||||||
|
_gamestate->_soundCmd->setMasterVolume(vol);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
} // End of namespace Sci
|
} // End of namespace Sci
|
||||||
|
|
|
@ -122,6 +122,7 @@ public:
|
||||||
Common::Error saveGameState(int slot, const char *desc);
|
Common::Error saveGameState(int slot, const char *desc);
|
||||||
bool canLoadGameStateCurrently();
|
bool canLoadGameStateCurrently();
|
||||||
bool canSaveGameStateCurrently();
|
bool canSaveGameStateCurrently();
|
||||||
|
void syncSoundSettings();
|
||||||
|
|
||||||
const char* getGameID() const;
|
const char* getGameID() const;
|
||||||
int getResourceVersion() const;
|
int getResourceVersion() const;
|
||||||
|
|
|
@ -40,7 +40,7 @@ namespace Sci {
|
||||||
#define DISABLE_VOLUME_FADING
|
#define DISABLE_VOLUME_FADING
|
||||||
|
|
||||||
SciMusic::SciMusic(SciVersion soundVersion)
|
SciMusic::SciMusic(SciVersion soundVersion)
|
||||||
: _soundVersion(soundVersion), _soundOn(true) {
|
: _soundVersion(soundVersion), _soundOn(true), _masterVolume(0) {
|
||||||
|
|
||||||
// Reserve some space in the playlist, to avoid expensive insertion
|
// Reserve some space in the playlist, to avoid expensive insertion
|
||||||
// operations
|
// operations
|
||||||
|
@ -57,12 +57,6 @@ SciMusic::~SciMusic() {
|
||||||
void SciMusic::init() {
|
void SciMusic::init() {
|
||||||
// system init
|
// system init
|
||||||
_pMixer = g_system->getMixer();
|
_pMixer = g_system->getMixer();
|
||||||
_pMixer->setVolumeForSoundType(Audio::Mixer::kSFXSoundType, ConfMan.getInt(
|
|
||||||
"sfx_volume"));
|
|
||||||
_pMixer->setVolumeForSoundType(Audio::Mixer::kSpeechSoundType,
|
|
||||||
ConfMan.getInt("speech_volume"));
|
|
||||||
_pMixer->setVolumeForSoundType(Audio::Mixer::kMusicSoundType,
|
|
||||||
ConfMan.getInt("music_volume"));
|
|
||||||
// SCI sound init
|
// SCI sound init
|
||||||
_dwTempo = 0;
|
_dwTempo = 0;
|
||||||
|
|
||||||
|
@ -469,15 +463,16 @@ void SciMusic::soundResume(MusicEntry *pSnd) {
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16 SciMusic::soundGetMasterVolume() {
|
uint16 SciMusic::soundGetMasterVolume() {
|
||||||
return (_pMixer->getVolumeForSoundType(Audio::Mixer::kMusicSoundType) + 8) * 0xF / Audio::Mixer::kMaxMixerVolume;
|
return _masterVolume;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SciMusic::soundSetMasterVolume(uint16 vol) {
|
void SciMusic::soundSetMasterVolume(uint16 vol) {
|
||||||
vol = vol & 0xF; // 0..15
|
_masterVolume = vol;
|
||||||
vol = vol * Audio::Mixer::kMaxMixerVolume / 0xF;
|
|
||||||
// "master volume" is music and SFX only, speech (audio resources) are supposed to be unaffected
|
Common::StackLock lock(_mutex);
|
||||||
_pMixer->setVolumeForSoundType(Audio::Mixer::kMusicSoundType, vol);
|
|
||||||
_pMixer->setVolumeForSoundType(Audio::Mixer::kSFXSoundType, vol);
|
if (_pMidiDrv)
|
||||||
|
_pMidiDrv->setVolume(vol);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SciMusic::printPlayList(Console *con) {
|
void SciMusic::printPlayList(Console *con) {
|
||||||
|
|
|
@ -226,6 +226,7 @@ private:
|
||||||
MusicList _playList;
|
MusicList _playList;
|
||||||
bool _soundOn;
|
bool _soundOn;
|
||||||
byte _reverb;
|
byte _reverb;
|
||||||
|
byte _masterVolume;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // End of namespace Sci
|
} // End of namespace Sci
|
||||||
|
|
|
@ -229,7 +229,7 @@ int MidiDriver_Adlib::open(bool isSCI0) {
|
||||||
|
|
||||||
MidiDriver_Emulated::open();
|
MidiDriver_Emulated::open();
|
||||||
|
|
||||||
_mixer->playInputStream(Audio::Mixer::kMusicSoundType, &_mixerSoundHandle, this, -1, _mixer->kMaxChannelVolume, 0, DisposeAfterUse::NO);
|
_mixer->playInputStream(Audio::Mixer::kPlainSoundType, &_mixerSoundHandle, this, -1, _mixer->kMaxChannelVolume, 0, DisposeAfterUse::NO);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -541,7 +541,7 @@ int MidiDriver_Amiga::open() {
|
||||||
|
|
||||||
MidiDriver_Emulated::open();
|
MidiDriver_Emulated::open();
|
||||||
|
|
||||||
_mixer->playInputStream(Audio::Mixer::kMusicSoundType, &_mixerSoundHandle, this, -1, _mixer->kMaxChannelVolume, 0, DisposeAfterUse::NO);
|
_mixer->playInputStream(Audio::Mixer::kPlainSoundType, &_mixerSoundHandle, this, -1, _mixer->kMaxChannelVolume, 0, DisposeAfterUse::NO);
|
||||||
|
|
||||||
return Common::kNoError;
|
return Common::kNoError;
|
||||||
}
|
}
|
||||||
|
|
|
@ -219,7 +219,7 @@ int MidiDriver_PCJr::open(int channels) {
|
||||||
|
|
||||||
MidiDriver_Emulated::open();
|
MidiDriver_Emulated::open();
|
||||||
|
|
||||||
_mixer->playInputStream(Audio::Mixer::kMusicSoundType, &_mixerSoundHandle, this, -1, _mixer->kMaxChannelVolume, 0, DisposeAfterUse::NO);
|
_mixer->playInputStream(Audio::Mixer::kPlainSoundType, &_mixerSoundHandle, this, -1, _mixer->kMaxChannelVolume, 0, DisposeAfterUse::NO);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
#include "sci/sound/iterator/iterator.h" // for SongIteratorStatus
|
#include "sci/sound/iterator/iterator.h" // for SongIteratorStatus
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "common/config-manager.h"
|
||||||
#include "sci/sound/music.h"
|
#include "sci/sound/music.h"
|
||||||
#include "sci/sound/soundcmd.h"
|
#include "sci/sound/soundcmd.h"
|
||||||
|
|
||||||
|
@ -610,8 +611,13 @@ void SoundCommandParser::cmdMasterVolume(reg_t obj, int16 value) {
|
||||||
_acc = make_reg(0, _state->sfx_getVolume());
|
_acc = make_reg(0, _state->sfx_getVolume());
|
||||||
#else
|
#else
|
||||||
debugC(2, kDebugLevelSound, "cmdMasterVolume: %d", value);
|
debugC(2, kDebugLevelSound, "cmdMasterVolume: %d", value);
|
||||||
if (_argc > 1) // the first parameter is the sound command
|
if (_argc > 1) { // the first parameter is the sound command
|
||||||
_music->soundSetMasterVolume(obj.toSint16());
|
int vol = CLIP<int16>(obj.toSint16(), 0, kMaxSciVolume);
|
||||||
|
vol = vol * Audio::Mixer::kMaxMixerVolume / kMaxSciVolume;
|
||||||
|
ConfMan.setInt("music_volume", vol);
|
||||||
|
ConfMan.setInt("sfx_volume", vol);
|
||||||
|
g_engine->syncSoundSettings();
|
||||||
|
}
|
||||||
_acc = make_reg(0, _music->soundGetMasterVolume());
|
_acc = make_reg(0, _music->soundGetMasterVolume());
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -1090,4 +1096,10 @@ void SoundCommandParser::resetDriver() {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SoundCommandParser::setMasterVolume(int vol) {
|
||||||
|
#ifndef USE_OLD_MUSIC_FUNCTIONS
|
||||||
|
_music->soundSetMasterVolume(vol);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
} // End of namespace Sci
|
} // End of namespace Sci
|
||||||
|
|
|
@ -49,6 +49,10 @@ public:
|
||||||
SoundCommandParser(ResourceManager *resMan, SegManager *segMan, AudioPlayer *audio, SciVersion soundVersion);
|
SoundCommandParser(ResourceManager *resMan, SegManager *segMan, AudioPlayer *audio, SciVersion soundVersion);
|
||||||
~SoundCommandParser();
|
~SoundCommandParser();
|
||||||
|
|
||||||
|
enum {
|
||||||
|
kMaxSciVolume = 15
|
||||||
|
};
|
||||||
|
|
||||||
#ifdef USE_OLD_MUSIC_FUNCTIONS
|
#ifdef USE_OLD_MUSIC_FUNCTIONS
|
||||||
void updateSfxState(SfxState *newState) { _state = newState; }
|
void updateSfxState(SfxState *newState) { _state = newState; }
|
||||||
#endif
|
#endif
|
||||||
|
@ -59,6 +63,7 @@ public:
|
||||||
void reconstructPlayList(int savegame_version);
|
void reconstructPlayList(int savegame_version);
|
||||||
void printPlayList(Console *con);
|
void printPlayList(Console *con);
|
||||||
void resetDriver();
|
void resetDriver();
|
||||||
|
void setMasterVolume(int vol);
|
||||||
|
|
||||||
#ifndef USE_OLD_MUSIC_FUNCTIONS
|
#ifndef USE_OLD_MUSIC_FUNCTIONS
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue