diff options
author | Max Horn | 2004-12-27 23:43:40 +0000 |
---|---|---|
committer | Max Horn | 2004-12-27 23:43:40 +0000 |
commit | f9b1e4118c5b3350528087f982c2fa9d34a365de (patch) | |
tree | 2e923fd483cddb46392874f45bf557052bf1b489 /sword2/driver | |
parent | bc882a1af4df93feeaff82e69a4609367e373e20 (diff) | |
download | scummvm-rg350-f9b1e4118c5b3350528087f982c2fa9d34a365de.tar.gz scummvm-rg350-f9b1e4118c5b3350528087f982c2fa9d34a365de.tar.bz2 scummvm-rg350-f9b1e4118c5b3350528087f982c2fa9d34a365de.zip |
Use the mixer to handle sound volumes
svn-id: r16349
Diffstat (limited to 'sword2/driver')
-rw-r--r-- | sword2/driver/d_sound.cpp | 100 | ||||
-rw-r--r-- | sword2/driver/d_sound.h | 9 |
2 files changed, 13 insertions, 96 deletions
diff --git a/sword2/driver/d_sound.cpp b/sword2/driver/d_sound.cpp index 83b49ad5fb..881a5aa732 100644 --- a/sword2/driver/d_sound.cpp +++ b/sword2/driver/d_sound.cpp @@ -469,13 +469,10 @@ Sound::Sound(Sword2Engine *vm) { _speechPaused = false; _speechMuted = false; - _speechVol = 255; _fxPaused = false; _fxMuted = false; - _fxVol = 255; - _musicVol = 255; _musicPaused = false; _musicMuted = false; @@ -485,7 +482,7 @@ Sound::Sound(Sword2Engine *vm) { for (int i = 0; i < MAXMUS; i++) _music[i] = NULL; - _vm->_mixer->setupPremix(this); + _vm->_mixer->setupPremix(this, SoundMixer::kMusicAudioDataType); } Sound::~Sound() { @@ -545,7 +542,7 @@ int Sound::readBuffer(int16 *buffer, const int numSamples) { if (!_musicMuted) { for (int j = 0; j < len; j++) { - clampedAdd(buffer[j], (_musicVol * _mixBuffer[j]) / 255); + clampedAdd(buffer[j], _mixBuffer[j]); } } } @@ -604,26 +601,6 @@ bool Sound::isMusicMute(void) { } /** - * Set the volume of any future as well as playing music. - * @param volume volume, from 0 (silent) to 16 (max) - */ - -void Sound::setMusicVolume(uint volume) { - if (volume > 255) - volume = 255; - - _musicVol = volume; -} - -/** - * @return the volume setting for music - */ - -uint8 Sound::getMusicVolume(void) { - return _musicVol; -} - -/** * Stops the music dead in its tracks. Any music that is currently being * streamed is paused. */ @@ -776,7 +753,7 @@ void Sound::muteSpeech(bool mute) { _speechMuted = mute; if (_soundHandleSpeech.isActive()) { - byte volume = mute ? 0 : _speechVol; + uint volume = mute ? 0 : SoundMixer::kMaxChannelVolume; _vm->_mixer->setChannelVolume(_soundHandleSpeech, volume); } @@ -791,30 +768,6 @@ bool Sound::isSpeechMute(void) { } /** - * Set the volume of any future as well as playing speech samples. - * @param volume volume, from 0 (silent) to 14 (max) - */ - -void Sound::setSpeechVolume(uint volume) { - if (volume > 255) - volume = 255; - - _speechVol = volume; - - if (_soundHandleSpeech.isActive() && !_speechMuted && _soundHandleSpeech.isActive()) { - _vm->_mixer->setChannelVolume(_soundHandleSpeech, _speechVol); - } -} - -/** - * @return the volume setting for speech - */ - -uint8 Sound::getSpeechVolume(void) { - return _speechVol; -} - -/** * Stops the speech dead in its tracks. */ @@ -928,11 +881,11 @@ int32 Sound::playCompSpeech(uint32 speechid, uint8 vol, int8 pan) { // Modify the volume according to the master volume - byte volume = _speechMuted ? 0 : vol * _speechVol / 16; + byte volume = _speechMuted ? 0 : vol * SoundMixer::kMaxChannelVolume / 16; int8 p = _panTable[pan + 16]; // Start the speech playing - _vm->_mixer->playInputStream(SoundMixer::kSFXAudioDataType, &_soundHandleSpeech, input, -1, volume, p); + _vm->_mixer->playInputStream(SoundMixer::kSpeechAudioDataType, &_soundHandleSpeech, input, -1, volume, p); return RD_OK; } @@ -1014,7 +967,7 @@ void Sound::muteFx(bool mute) { // Now update the volume of any fxs playing for (int i = 0; i < MAXFX; i++) { if (_fx[i]._id) { - byte volume = mute ? 0 : _fx[i]._volume * _fxVol / 16; + byte volume = mute ? 0 : _fx[i]._volume * SoundMixer::kMaxChannelVolume / 16; _vm->_mixer->setChannelVolume(_fx[i]._handle, volume); } @@ -1030,35 +983,6 @@ bool Sound::isFxMute(void) { } /** - * @return the master volume setting for sound effects - */ - -uint8 Sound::getFxVolume(void) { - return _fxVol; -} - -/** - * Set the master volume of all sound effects. The effects still have their - * own volume setting as well as the master volume. - * @param volume volume, from 0 (silent) to 14 (max) - */ - -void Sound::setFxVolume(uint volume) { - if (volume > 255) - volume = 255; - - _fxVol = volume; - - if (_fxMuted) - return; - - // Now update the volume of any fxs playing - for (int i = 0; i < MAXFX; i++) - if (_fx[i]._id) - _vm->_mixer->setChannelVolume(_fx[i]._handle, _fx[i]._volume * _fxVol / 16); -} - -/** * Sets the volume and pan of the sample which is currently playing * @param id the id of the sample * @param vol volume @@ -1077,7 +1001,7 @@ int32 Sound::setFxIdVolumePan(int32 id, uint8 vol, int8 pan) { _fx[i]._volume = vol; if (!_fxMuted) { - _vm->_mixer->setChannelVolume(_fx[i]._handle, _fx[i]._volume * _fxVol / 16); + _vm->_mixer->setChannelVolume(_fx[i]._handle, _fx[i]._volume * SoundMixer::kMaxChannelVolume / 16); _vm->_mixer->setChannelBalance(_fx[i]._handle, _panTable[pan + 16]); } @@ -1093,7 +1017,7 @@ int32 Sound::setFxIdVolume(int32 id, uint8 vol) { _fx[i]._volume = vol; if (!_fxMuted) - _vm->_mixer->setChannelVolume(_fx[i]._handle, vol * _fxVol / 16); + _vm->_mixer->setChannelVolume(_fx[i]._handle, vol * SoundMixer::kMaxChannelVolume / 16); return RD_OK; } @@ -1190,14 +1114,16 @@ int32 Sound::playFx(int32 id, byte *data, uint8 vol, int8 pan, uint8 type) { if (!_soundOn) return RD_OK; - byte volume = _fxMuted ? 0 : vol * _fxVol / 16; + byte volume = _fxMuted ? 0 : vol * SoundMixer::kMaxChannelVolume / 16; + SoundMixer::SoundType soundType = SoundMixer::kSFXAudioDataType; // All lead-ins and lead-outs I've heard are music, so we use // the music volume setting for them. if (type == RDSE_FXLEADIN || type == RDSE_FXLEADOUT) { id = (type == RDSE_FXLEADIN) ? -2 : -1; - volume = _musicMuted ? 0 : _musicVol; + volume = _musicMuted ? 0 : SoundMixer::kMaxChannelVolume; + soundType = SoundMixer::kMusicAudioDataType; } WavInfo wavInfo; @@ -1253,7 +1179,7 @@ int32 Sound::playFx(int32 id, byte *data, uint8 vol, int8 pan, uint8 type) { int8 p = _panTable[pan + 16]; - _vm->_mixer->playRaw(&_fx[fxi]._handle, wavInfo.data, wavInfo.samples, wavInfo.rate, flags, -1, volume, p); + _vm->_mixer->playRaw(&_fx[fxi]._handle, wavInfo.data, wavInfo.samples, wavInfo.rate, flags, -1, volume, p, 0, 0, soundType); return RD_OK; } diff --git a/sword2/driver/d_sound.h b/sword2/driver/d_sound.h index 3a885a89b8..37d7a52111 100644 --- a/sword2/driver/d_sound.h +++ b/sword2/driver/d_sound.h @@ -70,17 +70,14 @@ private: bool _musicPaused; bool _musicMuted; - int _musicVol; PlayingSoundHandle _soundHandleSpeech; bool _speechPaused; bool _speechMuted; - int _speechVol; FxHandle _fx[MAXFX]; bool _fxPaused; bool _fxMuted; - int _fxVol; int32 getFxIndex(int32 id); void stopFxHandle(int i); @@ -104,8 +101,6 @@ public: void muteMusic(bool mute); bool isMusicMute(void); - void setMusicVolume(uint vol); - uint8 getMusicVolume(void); void pauseMusic(void); void unpauseMusic(void); void stopMusic(void); @@ -115,8 +110,6 @@ public: void muteSpeech(bool mute); bool isSpeechMute(void); - void setSpeechVolume(uint vol); - uint8 getSpeechVolume(void); void pauseSpeech(void); void unpauseSpeech(void); int32 stopSpeech(void); @@ -127,8 +120,6 @@ public: void muteFx(bool mute); bool isFxMute(void); - uint8 getFxVolume(void); - void setFxVolume(uint vol); int32 setFxIdVolumePan(int32 id, uint8 vol, int8 pan); int32 setFxIdVolume(int32 id, uint8 vol); void pauseFx(void); |