mirror of
https://github.com/libretro/scummvm.git
synced 2025-04-02 14:51:40 +00:00
Seperate SFX and Speech.
this fixes the 'pauses' in the car-chase scene and other scene which use speech and sfx simultaneously. svn-id: r12599
This commit is contained in:
parent
b106eb1e43
commit
0d974b9daa
@ -1330,7 +1330,7 @@ void Cutaway::handleText(
|
||||
char voiceFileName[MAX_STRING_SIZE];
|
||||
findCdCut(_basename, index, voiceFileName);
|
||||
strcat(voiceFileName, "1");
|
||||
_vm->sound()->playSfx(voiceFileName);
|
||||
_vm->sound()->playSfx(voiceFileName, true);
|
||||
}
|
||||
|
||||
if (OBJECT_TYPE_TEXT_SPEAK == type && _vm->sound()->speechOn() && !_vm->subtitles())
|
||||
|
@ -328,7 +328,7 @@ void Graphics::sortBobs() {
|
||||
if (pbs->animating) {
|
||||
pbs->animOneStep();
|
||||
if (pbs->frameNum > 500) { // SFX frame
|
||||
_vm->sound()->playSfx(_vm->logic()->currentRoomSfx());
|
||||
_vm->sound()->playSfx(_vm->logic()->currentRoomSfx(), false);
|
||||
pbs->frameNum -= 500;
|
||||
}
|
||||
}
|
||||
@ -1087,7 +1087,7 @@ void BamScene::playSfx() {
|
||||
// this problem since their playSfx() function returns immediately
|
||||
// if a sound is already being played.
|
||||
if (_lastSoundIndex == 0 || _index - _lastSoundIndex >= SFX_SKIP) {
|
||||
_vm->sound()->playSfx(_vm->logic()->currentRoomSfx());
|
||||
_vm->sound()->playSfx(_vm->logic()->currentRoomSfx(), false);
|
||||
_lastSoundIndex = _index;
|
||||
}
|
||||
}
|
||||
|
@ -1722,7 +1722,7 @@ void Logic::asmMakeLightningHitPlane() {
|
||||
lightningBob->y = 0;
|
||||
|
||||
// 23/2/95 - Play lightning SFX
|
||||
_vm->sound()->playSfx(currentRoomSfx());
|
||||
_vm->sound()->playSfx(currentRoomSfx(), false);
|
||||
|
||||
_vm->bankMan()->unpack(18, lightningBob->frameNum, 15);
|
||||
_vm->bankMan()->unpack(4, planeBob ->frameNum, 15);
|
||||
|
@ -67,21 +67,26 @@ Sound *Sound::giveSound(SoundMixer *mixer, QueenEngine *vm, uint8 compression) {
|
||||
}
|
||||
}
|
||||
|
||||
void Sound::waitSfxFinished() {
|
||||
while(_sfxHandle.isActive())
|
||||
_vm->input()->delay(10);
|
||||
void Sound::waitFinished(bool isSpeech) {
|
||||
if (isSpeech)
|
||||
while(_speechHandle.isActive())
|
||||
_vm->input()->delay(10);
|
||||
else
|
||||
while(_sfxHandle.isActive())
|
||||
_vm->input()->delay(10);
|
||||
}
|
||||
|
||||
void Sound::playSfx(uint16 sfx) {
|
||||
void Sound::playSfx(uint16 sfx, bool isSpeech) {
|
||||
if (sfx != 0) {
|
||||
char name[13];
|
||||
strcpy(name, _sfxName[sfx - 1]);
|
||||
strcat(name, ".SB");
|
||||
sfxPlay(name);
|
||||
waitFinished(isSpeech);
|
||||
sfxPlay(name, isSpeech);
|
||||
}
|
||||
}
|
||||
|
||||
void Sound::playSfx(const char *base) {
|
||||
void Sound::playSfx(const char *base, bool isSpeech) {
|
||||
char name[13];
|
||||
strcpy(name, base);
|
||||
// alter filename to add zeros and append ".SB"
|
||||
@ -90,7 +95,8 @@ void Sound::playSfx(const char *base) {
|
||||
name[i] = '0';
|
||||
}
|
||||
strcat(name, ".SB");
|
||||
sfxPlay(name);
|
||||
waitFinished(isSpeech);
|
||||
sfxPlay(name, isSpeech);
|
||||
}
|
||||
|
||||
void Sound::playSong(int16 songNum) {
|
||||
@ -112,7 +118,7 @@ void Sound::playSong(int16 songNum) {
|
||||
|
||||
if (_tune[newTune].sfx[0]) {
|
||||
if (sfxOn())
|
||||
playSfx(_tune[newTune].sfx[0]);
|
||||
playSfx(_tune[newTune].sfx[0], false);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -148,30 +154,27 @@ void Sound::loadState(uint32 ver, byte *&ptr) {
|
||||
}
|
||||
|
||||
|
||||
void SBSound::playSound(byte *sound, uint32 size) {
|
||||
void SBSound::playSound(byte *sound, uint32 size, bool isSpeech) {
|
||||
byte flags = SoundMixer::FLAG_UNSIGNED | SoundMixer::FLAG_AUTOFREE;
|
||||
_mixer->playRaw(&_sfxHandle, sound, size, 11025, flags);
|
||||
_mixer->playRaw(isSpeech ? &_speechHandle : &_sfxHandle, sound, size, 11025, flags);
|
||||
}
|
||||
|
||||
void SBSound::sfxPlay(const char *name) {
|
||||
waitSfxFinished();
|
||||
void SBSound::sfxPlay(const char *name, bool isSpeech) {
|
||||
if (_vm->resource()->fileExists(name))
|
||||
playSound(_vm->resource()->loadFileMalloc(name, SB_HEADER_SIZE), _vm->resource()->fileSize(name) - SB_HEADER_SIZE);
|
||||
playSound(_vm->resource()->loadFileMalloc(name, SB_HEADER_SIZE), _vm->resource()->fileSize(name) - SB_HEADER_SIZE, isSpeech);
|
||||
}
|
||||
|
||||
#ifdef USE_MAD
|
||||
void MP3Sound::sfxPlay(const char *name) {
|
||||
waitSfxFinished();
|
||||
void MP3Sound::sfxPlay(const char *name, bool isSpeech) {
|
||||
if (_vm->resource()->fileExists(name))
|
||||
_mixer->playMP3(&_sfxHandle, _vm->resource()->giveCompressedSound(name), _vm->resource()->fileSize(name));
|
||||
_mixer->playMP3(isSpeech ? &_speechHandle : &_sfxHandle, _vm->resource()->giveCompressedSound(name), _vm->resource()->fileSize(name));
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef USE_VORBIS
|
||||
void OGGSound::sfxPlay(const char *name) {
|
||||
waitSfxFinished();
|
||||
void OGGSound::sfxPlay(const char *name, bool isSpeech) {
|
||||
if (_vm->resource()->fileExists(name))
|
||||
_mixer->playVorbis(&_sfxHandle, _vm->resource()->giveCompressedSound(name), _vm->resource()->fileSize(name));
|
||||
_mixer->playVorbis(isSpeech ? &_speechHandle : &_sfxHandle, _vm->resource()->giveCompressedSound(name), _vm->resource()->fileSize(name));
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -53,13 +53,12 @@ class Sound {
|
||||
public:
|
||||
Sound(SoundMixer *mixer, QueenEngine *vm);
|
||||
virtual ~Sound();
|
||||
virtual void sfxPlay(const char *name) = 0;
|
||||
virtual void sfxPlay(const char *name, bool isSpeech) = 0;
|
||||
static Sound *giveSound(SoundMixer *mixer, QueenEngine *vm, uint8 compression);
|
||||
void waitSfxFinished();
|
||||
void playSfx(uint16 sfx);
|
||||
void playSfx(const char *base);
|
||||
void playSfx(uint16 sfx, bool isSpeech);
|
||||
void playSfx(const char *base, bool isSpeech);
|
||||
void playSong(int16 songNum);
|
||||
void stopSfx() { _mixer->stopHandle(_sfxHandle); }
|
||||
void stopSpeech() { _mixer->stopHandle(_speechHandle); }
|
||||
|
||||
bool sfxOn() { return _sfxToggle; }
|
||||
void sfxToggle(bool val) { _sfxToggle = val; }
|
||||
@ -86,6 +85,8 @@ public:
|
||||
static const int16 _jungleList[];
|
||||
|
||||
protected:
|
||||
void waitFinished(bool isSpeech);
|
||||
|
||||
SoundMixer *_mixer;
|
||||
QueenEngine *_vm;
|
||||
|
||||
@ -100,27 +101,28 @@ protected:
|
||||
int16 _previousSong;
|
||||
int16 _previousSongNum;
|
||||
PlayingSoundHandle _sfxHandle;
|
||||
PlayingSoundHandle _speechHandle;
|
||||
};
|
||||
|
||||
class SilentSound : public Sound {
|
||||
public:
|
||||
SilentSound(SoundMixer *mixer, QueenEngine *vm) : Sound(mixer, vm) {};
|
||||
void sfxPlay(const char *name) { }
|
||||
void sfxPlay(const char *name, bool isSpeech) { }
|
||||
};
|
||||
|
||||
class SBSound : public Sound {
|
||||
public:
|
||||
SBSound(SoundMixer *mixer, QueenEngine *vm) : Sound(mixer, vm) {};
|
||||
void sfxPlay(const char *name);
|
||||
void sfxPlay(const char *name, bool isSpeech);
|
||||
protected:
|
||||
void playSound(byte *sound, uint32 size);
|
||||
void playSound(byte *sound, uint32 size, bool isSpeech);
|
||||
};
|
||||
|
||||
#ifdef USE_MAD
|
||||
class MP3Sound : public Sound {
|
||||
public:
|
||||
MP3Sound(SoundMixer *mixer, QueenEngine *vm) : Sound(mixer, vm) {};
|
||||
void sfxPlay(const char *name);
|
||||
void sfxPlay(const char *name, bool isSpeech);
|
||||
};
|
||||
#endif
|
||||
|
||||
|
@ -780,7 +780,7 @@ void Talk::stringAnimation(const SpeechParameters *parameters, int startFrame, i
|
||||
|
||||
if (frame > 500) {
|
||||
frame -= 500;
|
||||
_vm->sound()->playSfx(_vm->logic()->currentRoomSfx());
|
||||
_vm->sound()->playSfx(_vm->logic()->currentRoomSfx(), false);
|
||||
}
|
||||
|
||||
if (torso) {
|
||||
@ -902,7 +902,7 @@ void Talk::defaultAnimation(
|
||||
// Skip through text more quickly
|
||||
if (_vm->input()->keyVerb() == VERB_SKIP_TEXT) {
|
||||
_vm->input()->clearKeyVerb();
|
||||
_vm->sound()->stopSfx();
|
||||
_vm->sound()->stopSpeech();
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -940,7 +940,7 @@ void Talk::speakSegment(
|
||||
// play it. This voice was used in room 30 (N8) when talking to Klunk.
|
||||
if (!(_vm->resource()->getLanguage() == FRENCH && !strcmp(voiceFileName, "c30e_102"))
|
||||
&& _vm->sound()->speechOn())
|
||||
_vm->sound()->playSfx(voiceFileName);
|
||||
_vm->sound()->playSfx(voiceFileName, true);
|
||||
|
||||
int faceDirectionCommand = 0;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user