diff options
author | Henry Bush | 2010-12-22 09:22:14 +0000 |
---|---|---|
committer | Henry Bush | 2010-12-22 09:22:14 +0000 |
commit | ada3c01cc1568ad3a1d39496dc65e25e40aed6ac (patch) | |
tree | 592581cc41caf69fd556eae7563ab9da7740a232 | |
parent | e20c9028128670f18cc741abbc2788175edf2058 (diff) | |
download | scummvm-rg350-ada3c01cc1568ad3a1d39496dc65e25e40aed6ac.tar.gz scummvm-rg350-ada3c01cc1568ad3a1d39496dc65e25e40aed6ac.tar.bz2 scummvm-rg350-ada3c01cc1568ad3a1d39496dc65e25e40aed6ac.zip |
HUGO: Set some volume levels to get the MAME adlib emul working
svn-id: r55000
-rw-r--r-- | engines/hugo/sound.cpp | 20 | ||||
-rw-r--r-- | engines/hugo/sound.h | 2 |
2 files changed, 22 insertions, 0 deletions
diff --git a/engines/hugo/sound.cpp b/engines/hugo/sound.cpp index a0cb0082d9..136e0feb9e 100644 --- a/engines/hugo/sound.cpp +++ b/engines/hugo/sound.cpp @@ -33,6 +33,7 @@ /* sound.c - sound effects and music support */ #include "common/system.h" +#include "common/config-manager.h" #include "sound/decoders/raw.h" #include "sound/audiostream.h" @@ -68,6 +69,7 @@ void MidiPlayer::play(uint8 *stream, uint16 size) { if (_midiData) { memcpy(_midiData, stream, size); _mutex.lock(); + syncVolume(); _parser->loadMusic(_midiData, size); _parser->setTrack(0); _isLooping = true; @@ -115,6 +117,15 @@ void MidiPlayer::adjustVolume(int diff) { setVolume(_masterVolume + diff); } +void MidiPlayer::syncVolume() { + int volume = ConfMan.getInt("music_volume"); + if (ConfMan.getBool("mute")) { + volume = -1; + } + debugC(2, kDebugMusic, "Syncing music volume to %d", volume); + setVolume(volume); +} + void MidiPlayer::setVolume(int volume) { debugC(3, kDebugMusic, "MidiPlayer::setVolume"); _masterVolume = CLIP(volume, 0, 255); @@ -127,6 +138,13 @@ void MidiPlayer::setVolume(int volume) { _mutex.unlock(); } +void MidiPlayer::setChannelVolume(int channel) { + int newVolume = _channelsVolume[channel] * _masterVolume / 255; + debugC(3, kDebugMusic, "Music channel %d: volume %d->%d", + channel, _channelsVolume[channel], newVolume); + _channelsTable[channel]->volume(newVolume); +} + int MidiPlayer::open() { if (!_driver) return 255; @@ -179,6 +197,8 @@ void MidiPlayer::send(uint32 b) { if (!_channelsTable[ch]) { _channelsTable[ch] = (ch == 9) ? _driver->getPercussionChannel() : _driver->allocateChannel(); + if (_channelsTable[ch]) + setChannelVolume(ch); } if (_channelsTable[ch]) { _channelsTable[ch]->send(b); diff --git a/engines/hugo/sound.h b/engines/hugo/sound.h index ab26e749a0..1e654e0587 100644 --- a/engines/hugo/sound.h +++ b/engines/hugo/sound.h @@ -54,7 +54,9 @@ public: void pause(bool p); void updateTimer(); void adjustVolume(int diff); + void setChannelVolume(int channel); void setVolume(int volume); + void syncVolume(); int getVolume() const { return _masterVolume; } void setLooping(bool loop) { _isLooping = loop; } |