diff options
author | Joost Peters | 2004-03-09 00:52:07 +0000 |
---|---|---|
committer | Joost Peters | 2004-03-09 00:52:07 +0000 |
commit | 1020f97ceab9f1a606abf0bf6a0160b4136fab46 (patch) | |
tree | 07ac56b5bbe4fa0cf43e973a125079ebe0c8ff2e /queen/music.cpp | |
parent | 8b39133cab44244b6b4e3eeb303e91d0860a09b1 (diff) | |
download | scummvm-rg350-1020f97ceab9f1a606abf0bf6a0160b4136fab46.tar.gz scummvm-rg350-1020f97ceab9f1a606abf0bf6a0160b4136fab46.tar.bz2 scummvm-rg350-1020f97ceab9f1a606abf0bf6a0160b4136fab46.zip |
Enable music volume slider in Journal
svn-id: r13222
Diffstat (limited to 'queen/music.cpp')
-rw-r--r-- | queen/music.cpp | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/queen/music.cpp b/queen/music.cpp index d60c89b6d2..f9512318c3 100644 --- a/queen/music.cpp +++ b/queen/music.cpp @@ -42,7 +42,7 @@ static const byte mt32_to_gm[128] = { 47, 117, 127, 118, 118, 116, 115, 119, 115, 112, 55, 124, 123, 0, 14, 117 // 7x }; - MusicPlayer::MusicPlayer(MidiDriver *driver, byte *data, uint32 size) : _driver(driver), _isPlaying(false), _looping(false), _randomLoop(false), _volume(255), _queuePos(0), _musicData(data), _musicDataSize(size) { + MusicPlayer::MusicPlayer(MidiDriver *driver, byte *data, uint32 size) : _driver(driver), _isPlaying(false), _looping(false), _randomLoop(false), _masterVolume(192), _queuePos(0), _musicData(data), _musicDataSize(size) { memset(_channel, 0, sizeof(_channel)); queueClear(); _lastSong = _currentSong = 0; @@ -61,6 +61,23 @@ static const byte mt32_to_gm[128] = { delete _parser; } + void MusicPlayer::setVolume(int volume) { + if (volume < 0) + volume = 0; + else if (volume > 255) + volume = 255; + + if (_masterVolume == volume) + return; + + _masterVolume = volume; + + for (int i = 0; i < 16; ++i) { + if (_channel[i]) + _channel[i]->volume(_channelVolume[i] * _masterVolume / 255); + } + } + bool MusicPlayer::queueSong(uint16 songNum) { uint8 emptySlots = 0; for (int i = 0; i < MUSIC_QUEUE_SIZE; i++) @@ -111,7 +128,7 @@ static const byte mt32_to_gm[128] = { // Adjust volume changes by master volume byte volume = (byte)((b >> 16) & 0x7F); _channelVolume[channel] = volume; - //volume = volume * _masterVolume / 255; + volume = volume * _masterVolume / 255; b = (b & 0xFF00FFFF) | (volume << 16); } else if ((b & 0xF0) == 0xC0 && !_nativeMT32) { b = (b & 0xFFFF00FF) | mt32_to_gm[(b >> 8) & 0xFF] << 8; |