aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Horn2004-12-27 01:32:40 +0000
committerMax Horn2004-12-27 01:32:40 +0000
commitf15f517bb45c9ddb06178b4127f08d04204275b0 (patch)
tree3bf784ad0ee3b2c8f9b54d1ebaa916da9d234b09
parent67b311713d8f4cfcd460a9649e0075f24278a048 (diff)
downloadscummvm-rg350-f15f517bb45c9ddb06178b4127f08d04204275b0.tar.gz
scummvm-rg350-f15f517bb45c9ddb06178b4127f08d04204275b0.tar.bz2
scummvm-rg350-f15f517bb45c9ddb06178b4127f08d04204275b0.zip
Add 'speech' sound type to mixer; make use of that in iMuse Digital
svn-id: r16331
-rw-r--r--scumm/imuse_digi/dimuse.cpp43
-rw-r--r--scumm/imuse_digi/dimuse.h13
-rw-r--r--scumm/imuse_digi/dimuse_track.cpp20
-rw-r--r--scumm/saveload.h2
-rw-r--r--scumm/script_v8.cpp6
-rw-r--r--scumm/scumm.cpp8
-rw-r--r--sound/mixer.h4
7 files changed, 39 insertions, 57 deletions
diff --git a/scumm/imuse_digi/dimuse.cpp b/scumm/imuse_digi/dimuse.cpp
index 6d2df1d53e..546bcf6409 100644
--- a/scumm/imuse_digi/dimuse.cpp
+++ b/scumm/imuse_digi/dimuse.cpp
@@ -46,9 +46,6 @@ IMuseDigital::IMuseDigital(ScummEngine *scumm, int fps)
_mutex = g_system->createMutex();
_pause = false;
_sound = new ImuseDigiSndMgr(_vm);
- _volVoice = 0;
- _volSfx = 0;
- _volMusic = 0;
_callbackFps = fps;
resetState();
for (int l = 0; l < MAX_DIGITAL_TRACKS + MAX_DIGITAL_FADETRACKS; l++) {
@@ -81,9 +78,9 @@ void IMuseDigital::saveOrLoad(Serializer *ser) {
Common::StackLock lock(_mutex, "IMuseDigital::saveOrLoad()");
const SaveLoadEntry mainEntries[] = {
- MKLINE(IMuseDigital, _volVoice, sleInt32, VER(31)),
- MKLINE(IMuseDigital, _volSfx, sleInt32, VER(31)),
- MKLINE(IMuseDigital, _volMusic, sleInt32, VER(31)),
+ MK_OBSOLETE(IMuseDigital, _volVoice, sleInt32, VER(31), VER(42)),
+ MK_OBSOLETE(IMuseDigital, _volSfx, sleInt32, VER(31), VER(42)),
+ MK_OBSOLETE(IMuseDigital, _volMusic, sleInt32, VER(31), VER(42)),
MKLINE(IMuseDigital, _curMusicState, sleInt32, VER(31)),
MKLINE(IMuseDigital, _curMusicSeq, sleInt32, VER(31)),
MKLINE(IMuseDigital, _curMusicCue, sleInt32, VER(31)),
@@ -116,8 +113,8 @@ void IMuseDigital::saveOrLoad(Serializer *ser) {
MKLINE(Track, iteration, sleInt32, VER(31)),
MKLINE(Track, mod, sleInt32, VER(31)),
MKLINE(Track, mixerFlags, sleInt32, VER(31)),
- MKLINE(Track, mixerVol, sleInt32, VER(31)),
- MKLINE(Track, mixerPan, sleInt32, VER(31)),
+ MK_OBSOLETE(Track, mixerVol, sleInt32, VER(31), VER(42)),
+ MK_OBSOLETE(Track, mixerPan, sleInt32, VER(31), VER(42)),
MKEND()
};
@@ -149,7 +146,19 @@ void IMuseDigital::saveOrLoad(Serializer *ser) {
int freq = _sound->getFreq(track->soundHandle);
track->stream2 = NULL;
track->stream = makeAppendableAudioStream(freq, track->mixerFlags, streamBufferSize);
- _vm->_mixer->playInputStream(SoundMixer::kSFXAudioDataType, &track->handle, track->stream, -1, track->mixerVol, track->mixerPan, false);
+
+ const int pan = (track->pan != 64) ? 2 * track->pan - 127 : 0;
+ const int vol = track->vol / 1000;
+ SoundMixer::SoundType type = SoundMixer::kPlainAudioDataType;
+
+ if (track->volGroupId == 1)
+ type = SoundMixer::kSpeechAudioDataType;
+ if (track->volGroupId == 2)
+ type = SoundMixer::kSFXAudioDataType;
+ if (track->volGroupId == 3)
+ type = SoundMixer::kMusicAudioDataType;
+
+ _vm->_mixer->playInputStream(type, &track->handle, track->stream, -1, vol, pan, false);
}
}
}
@@ -192,18 +201,16 @@ void IMuseDigital::callback() {
debug(5, "Fade: sound(%d), Vol(%d)", track->soundId, track->vol / 1000);
}
- int pan = (track->pan != 64) ? 2 * track->pan - 127 : 0;
- int vol = track->vol / 1000;
+ const int pan = (track->pan != 64) ? 2 * track->pan - 127 : 0;
+ const int vol = track->vol / 1000;
+ SoundMixer::SoundType type = SoundMixer::kPlainAudioDataType;
if (track->volGroupId == 1)
- vol = (vol * _volVoice) / 128;
+ type = SoundMixer::kSpeechAudioDataType;
if (track->volGroupId == 2)
- vol = (vol * _volSfx) / 128;
+ type = SoundMixer::kSFXAudioDataType;
if (track->volGroupId == 3)
- vol = (vol * _volMusic) / 128;
-
- track->mixerVol = vol;
- track->mixerPan = pan;
+ type = SoundMixer::kMusicAudioDataType;
if (track->stream) {
byte *data = NULL;
@@ -289,7 +296,7 @@ void IMuseDigital::callback() {
if (_vm->_mixer->isReady()) {
if (!track->started) {
track->started = true;
- _vm->_mixer->playInputStream(SoundMixer::kSFXAudioDataType, &track->handle, track->stream2, -1, vol, pan, false);
+ _vm->_mixer->playInputStream(type, &track->handle, track->stream2, -1, vol, pan, false);
} else {
_vm->_mixer->setChannelVolume(track->handle, vol);
_vm->_mixer->setChannelBalance(track->handle, pan);
diff --git a/scumm/imuse_digi/dimuse.h b/scumm/imuse_digi/dimuse.h
index b744718df6..66a7b450af 100644
--- a/scumm/imuse_digi/dimuse.h
+++ b/scumm/imuse_digi/dimuse.h
@@ -72,8 +72,6 @@ private:
int32 iteration;
int32 mod;
int32 mixerFlags;
- int32 mixerVol;
- int32 mixerPan;
ImuseDigiSndMgr::soundStruct *soundHandle;
PlayingSoundHandle handle;
@@ -89,10 +87,6 @@ private:
ScummEngine *_vm;
ImuseDigiSndMgr *_sound;
- int32 _volVoice;
- int32 _volSfx;
- int32 _volMusic;
-
bool _pause;
int32 _attributes[188];
@@ -143,13 +137,6 @@ public:
void saveOrLoad(Serializer *ser);
void resetState();
- void setGroupVoiceVolume(int volume) { _volVoice = volume; }
- void setGroupSfxVolume(int volume) { _volSfx = volume; }
- void setGroupMusicVolume(int volume) { _volMusic = 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);
diff --git a/scumm/imuse_digi/dimuse_track.cpp b/scumm/imuse_digi/dimuse_track.cpp
index 28a7aa7fd9..df25dc629b 100644
--- a/scumm/imuse_digi/dimuse_track.cpp
+++ b/scumm/imuse_digi/dimuse_track.cpp
@@ -101,8 +101,6 @@ void IMuseDigital::startSound(int soundId, const char *soundName, int soundType,
track->regionOffset = 0;
track->mod = 0;
track->mixerFlags = 0;
- track->mixerPan = 0;
- track->mixerVol = volume;
track->toBeRemoved = false;
track->readyToRemove = false;
track->soundType = soundType;
@@ -156,24 +154,22 @@ void IMuseDigital::startSound(int soundId, const char *soundName, int soundType,
track->stream = NULL;
track->started = false;
} else {
- int pan = (track->pan != 64) ? 2 * track->pan - 127 : 0;
- int vol = track->vol / 1000;
+ const int pan = (track->pan != 64) ? 2 * track->pan - 127 : 0;
+ const int vol = track->vol / 1000;
+ SoundMixer::SoundType type = SoundMixer::kPlainAudioDataType;
if (track->volGroupId == 1)
- vol = (vol * _volVoice) / 128;
+ type = SoundMixer::kSpeechAudioDataType;
if (track->volGroupId == 2)
- vol = (vol * _volSfx) / 128;
+ type = SoundMixer::kSFXAudioDataType;
if (track->volGroupId == 3)
- vol = (vol * _volMusic) / 128;
-
- track->mixerPan = pan;
- track->mixerVol = vol;
+ type = SoundMixer::kMusicAudioDataType;
// setup 1 second stream wrapped buffer
int32 streamBufferSize = track->iteration;
track->stream2 = NULL;
track->stream = makeAppendableAudioStream(freq, track->mixerFlags, streamBufferSize);
- _vm->_mixer->playInputStream(SoundMixer::kSFXAudioDataType, &track->handle, track->stream, -1, track->mixerVol, track->mixerPan, false);
+ _vm->_mixer->playInputStream(type, &track->handle, track->stream, -1, vol, pan, false);
track->started = true;
}
@@ -283,8 +279,6 @@ IMuseDigital::Track *IMuseDigital::cloneToFadeOutTrack(Track *track, int fadeDel
fadeTrack->curHookId = track->curHookId;
fadeTrack->iteration = track->iteration;
fadeTrack->mixerFlags = track->mixerFlags;
- fadeTrack->mixerVol = track->mixerVol;
- fadeTrack->mixerPan = track->mixerPan;
fadeTrack->mod = track->mod;
fadeTrack->toBeRemoved = track->toBeRemoved;
fadeTrack->readyToRemove = track->readyToRemove;
diff --git a/scumm/saveload.h b/scumm/saveload.h
index eb4acab072..6e643c5ae9 100644
--- a/scumm/saveload.h
+++ b/scumm/saveload.h
@@ -32,7 +32,7 @@ namespace Scumm {
// Can be useful for other ports too :)
#define VER(x) x
-#define CURRENT_VER 42
+#define CURRENT_VER 43
// To work around a warning in GCC 3.2 (and 3.1 ?) regarding non-POD types,
// we use a small trick: instead of 0 we use 42. Why? Well, it seems newer GCC
diff --git a/scumm/script_v8.cpp b/scumm/script_v8.cpp
index 024c661411..1e02f8e0c8 100644
--- a/scumm/script_v8.cpp
+++ b/scumm/script_v8.cpp
@@ -1383,13 +1383,13 @@ void ScummEngine_v8::o8_kernelGetFunctions() {
}
break;
case 0xDD: // getGroupSfxVol
- push(_imuseDigital->getGroupSfxVolume());
+ push(_mixer->getVolumeForSoundType(SoundMixer::kSFXAudioDataType) / 2);
break;
case 0xDE: // getGroupVoiceVol
- push(_imuseDigital->getGroupVoiceVolume());
+ push(_mixer->getVolumeForSoundType(SoundMixer::kSpeechAudioDataType) / 2);
break;
case 0xDF: // getGroupMusicVol
- push(_imuseDigital->getGroupMusicVolume());
+ push(_mixer->getVolumeForSoundType(SoundMixer::kMusicAudioDataType) / 2);
break;
case 0xE0: // readRegistryValue
{
diff --git a/scumm/scumm.cpp b/scumm/scumm.cpp
index efb8e3fe87..21f5cbe1ba 100644
--- a/scumm/scumm.cpp
+++ b/scumm/scumm.cpp
@@ -1390,13 +1390,7 @@ void ScummEngine::setupVolumes() {
_mixer->setVolumeForSoundType(SoundMixer::kSFXAudioDataType, soundVolumeSfx);
_mixer->setVolumeForSoundType(SoundMixer::kMusicAudioDataType, soundVolumeMusic);
-
- if (_imuseDigital) {
- _mixer->setVolumeForSoundType(SoundMixer::kSFXAudioDataType, 255);
- _imuseDigital->setGroupMusicVolume(soundVolumeMusic / 2);
- _imuseDigital->setGroupSfxVolume(soundVolumeSfx / 2);
- _imuseDigital->setGroupVoiceVolume(soundVolumeSpeech / 2);
- }
+ _mixer->setVolumeForSoundType(SoundMixer::kSpeechAudioDataType, soundVolumeSpeech);
}
diff --git a/sound/mixer.h b/sound/mixer.h
index 268e66296f..f282825205 100644
--- a/sound/mixer.h
+++ b/sound/mixer.h
@@ -73,8 +73,8 @@ public:
kPlainAudioDataType = 0,
kMusicAudioDataType = 1,
- kSFXAudioDataType = 2
- // kSpeechAudioDataType = 3 TODO: Add this type later...
+ kSFXAudioDataType = 2,
+ kSpeechAudioDataType = 3
};
private: