diff options
author | Paweł Kołodziejski | 2004-04-05 18:24:36 +0000 |
---|---|---|
committer | Paweł Kołodziejski | 2004-04-05 18:24:36 +0000 |
commit | f141ad488b1fd4d96214cb35e0ab4034173efb81 (patch) | |
tree | 88bc5d0055ef63fc6afa9180620c3a35c5e661f4 /scumm | |
parent | 781809ee2be3c1ad15e3e9a62296f27241ac9cd0 (diff) | |
download | scummvm-rg350-f141ad488b1fd4d96214cb35e0ab4034173efb81.tar.gz scummvm-rg350-f141ad488b1fd4d96214cb35e0ab4034173efb81.tar.bz2 scummvm-rg350-f141ad488b1fd4d96214cb35e0ab4034173efb81.zip |
added voice group volume to scumm engine for imuse digital and implemeted volume groups control
svn-id: r13468
Diffstat (limited to 'scumm')
-rw-r--r-- | scumm/dialogs.cpp | 13 | ||||
-rw-r--r-- | scumm/imuse_digi/dimuse.cpp | 81 | ||||
-rw-r--r-- | scumm/imuse_digi/dimuse.h | 22 | ||||
-rw-r--r-- | scumm/imuse_digi/dimuse_sndmgr.h | 1 | ||||
-rw-r--r-- | scumm/script_v8.cpp | 12 | ||||
-rw-r--r-- | scumm/scumm.cpp | 4 |
6 files changed, 101 insertions, 32 deletions
diff --git a/scumm/dialogs.cpp b/scumm/dialogs.cpp index cd3d2adf4d..e58fa6d270 100644 --- a/scumm/dialogs.cpp +++ b/scumm/dialogs.cpp @@ -30,6 +30,7 @@ #include "scumm/sound.h" #include "scumm/scumm.h" #include "scumm/imuse.h" +#include "scumm/imuse_digi/dimuse.h" #include "scumm/player_v2.h" #include "scumm/verbs.h" #include "sound/mididrv.h" @@ -430,7 +431,7 @@ ConfigDialog::ConfigDialog(ScummEngine *scumm) // // Some misc options // - subtitlesCheckbox = new GUI::CheckboxWidget(this, 15, 62, 200, 16, "Show subtitles", 0, 'S'); + subtitlesCheckbox = new GUI::CheckboxWidget(this, 15, 78, 200, 16, "Show subtitles", 0, 'S'); // // Create the sub dialog(s) @@ -469,10 +470,20 @@ void ConfigDialog::close() { int soundVolumeMaster = ConfMan.getInt("master_volume"); int soundVolumeMusic = ConfMan.getInt("music_volume"); int soundVolumeSfx = ConfMan.getInt("sfx_volume"); + int soundVolumeVoice = ConfMan.getInt("voice_volume"); + + if (_vm->_imuseDigital) { + _vm->_mixer->setVolume(soundVolumeMaster); + _vm->_imuseDigital->setGroupMusicVolume(soundVolumeMusic / 2); + _vm->_imuseDigital->setGroupSfxVolume(soundVolumeSfx / 2); + _vm->_imuseDigital->setGroupVoiceVolume(soundVolumeVoice / 2); + return; + } if (_vm->_imuse) { _vm->_imuse->set_music_volume(soundVolumeMusic); } + if (_vm->_musicEngine) { _vm->_musicEngine->setMasterVolume(soundVolumeMaster); } diff --git a/scumm/imuse_digi/dimuse.cpp b/scumm/imuse_digi/dimuse.cpp index a4869b712e..1c5721f33b 100644 --- a/scumm/imuse_digi/dimuse.cpp +++ b/scumm/imuse_digi/dimuse.cpp @@ -20,6 +20,7 @@ #include "stdafx.h" #include "common/timer.h" +#include "common/config-manager.h" #include "scumm/actor.h" #include "scumm/scumm.h" @@ -46,6 +47,9 @@ IMuseDigital::IMuseDigital(ScummEngine *scumm) _mutex = g_system->createMutex(); _pause = false; _sound = new ImuseDigiSndMgr(_vm); + _volVoice = 0; + _volSfx = 0; + _volMusic = 0; resetState(); _vm->_timer->installTimerProc(timer_handler, 1000000 / 25, this); } @@ -60,6 +64,28 @@ IMuseDigital::~IMuseDigital() { g_system->deleteMutex(_mutex); } +void IMuseDigital::resetState() { + _curMusicState = 0; + _curMusicSeq = 0; + _curMusicCue = 0; + memset(_attributes, 0, sizeof(_attributes)); + _curSeqAtribPos = 0; +} + +static const Common::String &kTransientDomain = Common::ConfigManager::kTransientDomain; + +void IMuseDigital::setGroupVoiceVolume(int volume) { + _volVoice = volume; +} + +void IMuseDigital::setGroupMusicVolume(int volume) { + _volMusic = volume; +} + +void IMuseDigital::setGroupSfxVolume(int volume) { + _volSfx = volume; +} + void IMuseDigital::callback() { Common::StackLock lock(_mutex, "IMuseDigital::callback()"); int l = 0; @@ -113,14 +139,22 @@ void IMuseDigital::callback() { } int pan = (_track[l].pan != 64) ? 2 * _track[l].pan - 127 : 0; + int vol = _track[l].vol / 1000; + + if (_track[l].soundGroup == 1) + vol = (vol * _volVoice) / 128; + if (_track[l].soundGroup == 2) + vol = (vol * _volSfx) / 128; + if (_track[l].soundGroup == 3) + vol = (vol * _volMusic) / 128; if (_vm->_mixer->isReady()) { if (_track[l].stream2) { if (!_track[l].started) { _track[l].started = true; - _vm->_mixer->playInputStream(&_track[l].handle, _track[l].stream2, true, _track[l].vol / 1000, _track[l].pan, -1, false); + _vm->_mixer->playInputStream(&_track[l].handle, _track[l].stream2, false, _track[l].vol / 1000, _track[l].pan, -1, false); } else { - _vm->_mixer->setChannelVolume(_track[l].handle, _track[l].vol / 1000); + _vm->_mixer->setChannelVolume(_track[l].handle, vol); _vm->_mixer->setChannelBalance(_track[l].handle, pan); } continue; @@ -174,7 +208,7 @@ void IMuseDigital::callback() { result = mixer_size; if (_vm->_mixer->isReady()) { - _vm->_mixer->setChannelVolume(_track[l].handle, _track[l].vol / 1000); + _vm->_mixer->setChannelVolume(_track[l].handle, vol); _vm->_mixer->setChannelBalance(_track[l].handle, pan); _track[l].stream->append(data, result); _track[l].regionOffset += result; @@ -345,7 +379,7 @@ void IMuseDigital::startSound(int soundId, const char *soundName, int soundType, } else { _track[l].stream2 = NULL; _track[l].stream = makeAppendableAudioStream(freq, mixerFlags, 100000); - _vm->_mixer->playInputStream(&_track[l].handle, _track[l].stream, true, _track[l].vol / 1000, _track[l].pan, -1); + _vm->_mixer->playInputStream(&_track[l].handle, _track[l].stream, false, _track[l].vol / 1000, _track[l].pan, -1); } _track[l].used = true; @@ -373,7 +407,7 @@ void IMuseDigital::stopSound(int soundId) { void IMuseDigital::setPriority(int soundId, int priority) { Common::StackLock lock(_mutex, "IMuseDigital::setPriority()"); - debug(5, "IMuseDigital::setPrioritySound(%d, %d)", soundId, priority); + debug(5, "IMuseDigital::setPriority(%d, %d)", soundId, priority); assert ((priority >= 0) && (priority <= 127)); @@ -386,7 +420,7 @@ void IMuseDigital::setPriority(int soundId, int priority) { void IMuseDigital::setVolume(int soundId, int volume) { Common::StackLock lock(_mutex, "IMuseDigital::setVolume()"); - debug(5, "IMuseDigital::setVolumeSound(%d, %d)", soundId, volume); + debug(5, "IMuseDigital::setVolume(%d, %d)", soundId, volume); for (int l = 0; l < MAX_DIGITAL_TRACKS; l++) { if ((_track[l].soundId == soundId) && _track[l].used) { _track[l].vol = volume * 1000; @@ -396,7 +430,7 @@ void IMuseDigital::setVolume(int soundId, int volume) { void IMuseDigital::setPan(int soundId, int pan) { Common::StackLock lock(_mutex, "IMuseDigital::setPan()"); - debug(5, "IMuseDigital::setVolumeSound(%d, %d)", soundId, pan); + debug(5, "IMuseDigital::setPan(%d, %d)", soundId, pan); for (int l = 0; l < MAX_DIGITAL_TRACKS; l++) { if ((_track[l].soundId == soundId) && _track[l].used) { _track[l].pan = pan; @@ -404,6 +438,17 @@ void IMuseDigital::setPan(int soundId, int pan) { } } +void IMuseDigital::selectGroupVolume(int soundId, int groupId) { + Common::StackLock lock(_mutex, "IMuseDigital::setGroupVolume()"); + debug(5, "IMuseDigital::setGroupVolume(%d, %d)", soundId, groupId); + assert((groupId >= 1) && (groupId <= 3)); + for (int l = 0; l < MAX_DIGITAL_TRACKS; l++) { + if ((_track[l].soundId == soundId) && _track[l].used) { + _track[l].soundGroup = groupId; + } + } +} + void IMuseDigital::setFade(int soundId, int destVolume, int delay60HzTicks) { Common::StackLock lock(_mutex, "IMuseDigital::setFade()"); debug(5, "IMuseDigital::setFade(%d, %d, %d)", soundId, destVolume, delay60HzTicks); @@ -497,8 +542,8 @@ void IMuseDigital::parseScriptCmds(int a, int b, int c, int d, int e, int f, int break; case 12: // ImuseSetParam switch (sub_cmd) { - case 0x400: // set group volume - debug(5, "set group volume (0x400), soundId(%d), group volume(%d)", soundId, d); + case 0x400: // select group volume + selectGroupVolume(soundId, d); break; case 0x500: // set priority setPriority(soundId, d); @@ -593,17 +638,17 @@ void IMuseDigital::parseScriptCmds(int a, int b, int c, int d, int e, int f, int _attributes[b] = c; } break; - case 0x2000: // ImuseSetMasterSFXVolume - debug(5, "ImuseSetMasterSFXVolume (%d)", b); - // TODO + case 0x2000: // ImuseSetGroupSfxVolume + debug(5, "ImuseSetGroupSFXVolume (%d)", b); +// setGroupSfxVolume(b); break; - case 0x2001: // ImuseSetMasterVoiceVolume - debug(5, "ImuseSetMasterVoiceVolume (%d)", b); - // TODO + case 0x2001: // ImuseSetGroupVoiceVolume + debug(5, "ImuseSetGroupVoiceVolume (%d)", b); +// setGroupVoiceVolume(b); break; - case 0x2002: // ImuseSetMasterMusicVolume - debug(5, "ImuseSetMasterMusicVolume (%d)", b); - // TODO + case 0x2002: // ImuseSetGroupMusicVolume + debug(5, "ImuseSetGroupMusicVolume (%d)", b); +// setGroupMusicVolume(b); break; default: warning("IMuseDigital::doCommand DEFAULT command %d", cmd); diff --git a/scumm/imuse_digi/dimuse.h b/scumm/imuse_digi/dimuse.h index 8f3c86b81c..995ed5f856 100644 --- a/scumm/imuse_digi/dimuse.h +++ b/scumm/imuse_digi/dimuse.h @@ -76,6 +76,11 @@ private: OSystem::MutexRef _mutex; ScummEngine *_vm; ImuseDigiSndMgr *_sound; + + int _volVoice; + int _volSfx; + int _volMusic; + bool _pause; int _attributes[188]; @@ -125,18 +130,21 @@ public: { debug(5, "startSfx(%d)", soundId); startSound(soundId, NULL, IMUSE_RESOURCE, IMUSE_SFX, NULL, 0, 127, priority); } void startSound(int soundId) { error("MusicEngine::startSound() Should be never called"); } - void resetState() { - _curMusicState = 0; - _curMusicSeq = 0; - _curMusicCue = 0; - memset(_attributes, 0, sizeof(_attributes)); - _curSeqAtribPos = 0; - } + + void resetState(); + + void setGroupVoiceVolume(int volume); + void setGroupSfxVolume(int volume); + void setGroupMusicVolume(int volume); + int getGroupVoiceVolume() { return _volVoice; } + int getGroupSfxVolume() { return _volSfx; } + int getGroupMusicVolume() { return _volMusic; } void setPriority(int soundId, int priority); void setVolume(int soundId, int volume); void setPan(int soundId, int pan); void setFade(int soundId, int destVolume, int delay60HzTicks); + void selectGroupVolume(int soundId, int groupId); void setMasterVolume(int vol) {} void stopSound(int soundId); void stopAllSounds() { stopAllSounds(false); } diff --git a/scumm/imuse_digi/dimuse_sndmgr.h b/scumm/imuse_digi/dimuse_sndmgr.h index 61cc4370c5..c0d1b28783 100644 --- a/scumm/imuse_digi/dimuse_sndmgr.h +++ b/scumm/imuse_digi/dimuse_sndmgr.h @@ -41,6 +41,7 @@ public: #define IMUSE_RESOURCE 1 #define IMUSE_BUNDLE 2 + #define IMUSE_VOICE 1 #define IMUSE_SFX 2 #define IMUSE_MUSIC 3 diff --git a/scumm/script_v8.cpp b/scumm/script_v8.cpp index ddefb92d52..7a86e404e8 100644 --- a/scumm/script_v8.cpp +++ b/scumm/script_v8.cpp @@ -1461,14 +1461,14 @@ void ScummEngine_v8::o8_kernelGetFunctions() { push(a->talkStartFrame); } break; - case 0xDD: // getMasterSFXVol - push(ConfMan.getInt("sfx_volume") / 2); + case 0xDD: // getGroupSfxVol + push(_imuseDigital->getGroupSfxVolume()); break; - case 0xDE: // getMasterVoiceVol - push(ConfMan.getInt("sfx_volume") / 2); + case 0xDE: // getGroupVoiceVol + push(_imuseDigital->getGroupVoiceVolume()); break; - case 0xDF: // getMasterMusicVol - push(ConfMan.getInt("music_volume") / 2); + case 0xDF: // getGroupMusicVol + push(_imuseDigital->getGroupMusicVolume()); break; case 0xE0: // readRegistryValue { diff --git a/scumm/scumm.cpp b/scumm/scumm.cpp index b8f69454a2..780282ed6a 100644 --- a/scumm/scumm.cpp +++ b/scumm/scumm.cpp @@ -711,6 +711,10 @@ ScummEngine::ScummEngine(GameDetector *detector, OSystem *syst, const ScummGameS // Init iMuse if (_features & GF_DIGI_IMUSE) { _musicEngine = _imuseDigital = new IMuseDigital(this); + _mixer->setVolume(ConfMan.getInt("master_volume")); + _imuseDigital->setGroupMusicVolume(ConfMan.getInt("music_volume") / 2); + _imuseDigital->setGroupSfxVolume(ConfMan.getInt("sfx_volume") / 2); + _imuseDigital->setGroupVoiceVolume(ConfMan.getInt("voice_volume") / 2); } else if ((_features & GF_AMIGA) && (_version == 2)) { _musicEngine = new Player_V2A(this); } else if ((_features & GF_AMIGA) && (_version == 3)) { |