mirror of
https://github.com/libretro/scummvm.git
synced 2025-04-02 23:01:42 +00:00
Add 'speech' sound type to mixer; make use of that in iMuse Digital
svn-id: r16331
This commit is contained in:
parent
67b311713d
commit
f15f517bb4
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
@ -73,8 +73,8 @@ public:
|
||||
kPlainAudioDataType = 0,
|
||||
|
||||
kMusicAudioDataType = 1,
|
||||
kSFXAudioDataType = 2
|
||||
// kSpeechAudioDataType = 3 TODO: Add this type later...
|
||||
kSFXAudioDataType = 2,
|
||||
kSpeechAudioDataType = 3
|
||||
};
|
||||
|
||||
private:
|
||||
|
Loading…
x
Reference in New Issue
Block a user