[Scummvm-cvs-logs] CVS: scummvm/sword2/driver d_sound.cpp,1.131,1.132 d_sound.h,1.56,1.57
Max Horn
fingolfin at users.sourceforge.net
Mon Dec 27 15:44:06 CET 2004
Update of /cvsroot/scummvm/scummvm/sword2/driver
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31373/driver
Modified Files:
d_sound.cpp d_sound.h
Log Message:
Use the mixer to handle sound volumes
Index: d_sound.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/driver/d_sound.cpp,v
retrieving revision 1.131
retrieving revision 1.132
diff -u -d -r1.131 -r1.132
--- d_sound.cpp 27 Dec 2004 03:00:35 -0000 1.131
+++ d_sound.cpp 27 Dec 2004 23:43:39 -0000 1.132
@@ -469,13 +469,10 @@
_speechPaused = false;
_speechMuted = false;
- _speechVol = 255;
_fxPaused = false;
_fxMuted = false;
- _fxVol = 255;
- _musicVol = 255;
_musicPaused = false;
_musicMuted = false;
@@ -485,7 +482,7 @@
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 @@
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 @@
}
/**
- * 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 @@
_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 @@
}
/**
- * 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 @@
// 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 @@
// 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 @@
}
/**
- * @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 @@
_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 @@
_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 @@
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 @@
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;
}
Index: d_sound.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/driver/d_sound.h,v
retrieving revision 1.56
retrieving revision 1.57
diff -u -d -r1.56 -r1.57
--- d_sound.h 27 Dec 2004 16:23:21 -0000 1.56
+++ d_sound.h 27 Dec 2004 23:43:40 -0000 1.57
@@ -70,17 +70,14 @@
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 @@
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 @@
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 @@
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);
More information about the Scummvm-git-logs
mailing list