aboutsummaryrefslogtreecommitdiff
path: root/engines/sci/sfx
diff options
context:
space:
mode:
authorFilippos Karapetis2009-12-22 12:34:27 +0000
committerFilippos Karapetis2009-12-22 12:34:27 +0000
commitb8aa17b6fbb3946e28033fd4bf731ba12e4dc250 (patch)
treeaa8019a37c3e0757a02a539661d063381f15fae0 /engines/sci/sfx
parent899d5769765a165eb8fc326dba330b28b6596435 (diff)
downloadscummvm-rg350-b8aa17b6fbb3946e28033fd4bf731ba12e4dc250.tar.gz
scummvm-rg350-b8aa17b6fbb3946e28033fd4bf731ba12e4dc250.tar.bz2
scummvm-rg350-b8aa17b6fbb3946e28033fd4bf731ba12e4dc250.zip
Started implementing SCI1.1 digital sound effect playing in the new music code
svn-id: r46479
Diffstat (limited to 'engines/sci/sfx')
-rw-r--r--engines/sci/sfx/audio.h3
-rw-r--r--engines/sci/sfx/music.cpp41
2 files changed, 36 insertions, 8 deletions
diff --git a/engines/sci/sfx/audio.h b/engines/sci/sfx/audio.h
index 82b5896499..febe77cefc 100644
--- a/engines/sci/sfx/audio.h
+++ b/engines/sci/sfx/audio.h
@@ -63,6 +63,7 @@ public:
void setAudioRate(uint16 rate) { _audioRate = rate; }
Audio::SoundHandle* getAudioHandle() { return &_audioHandle; }
+ Audio::AudioStream* getAudioStream(uint32 number, uint32 volume, int *sampleLen);
int getAudioPosition();
int startAudio(uint16 module, uint32 tuple);
void stopAudio();
@@ -88,8 +89,6 @@ private:
Resource *_syncResource; /**< Used by kDoSync for speech syncing in CD talkie games */
uint _syncOffset;
uint32 _audioCdStart;
-
- Audio::AudioStream* getAudioStream(uint32 number, uint32 volume, int *sampleLen);
};
} // End of namespace Sci
diff --git a/engines/sci/sfx/music.cpp b/engines/sci/sfx/music.cpp
index 60c4436cd1..f919fc8fdc 100644
--- a/engines/sci/sfx/music.cpp
+++ b/engines/sci/sfx/music.cpp
@@ -321,13 +321,42 @@ void SciMusic::soundInitSnd(MusicEntry *pSnd) {
pSnd->pStreamAud = Audio::makeLinearInputStream(pdata + 8, size, rate,
Audio::Mixer::FLAG_UNSIGNED, 0, 0);
pSnd->hCurrentAud = Audio::SoundHandle();
- } else {// play MIDI track
- if (pSnd->pMidiParser == NULL) {
- pSnd->pMidiParser = new MidiParser_SCI();
- pSnd->pMidiParser->setMidiDriver(_pMidiDrv);
- pSnd->pMidiParser->setTimerRate(_dwTempo);
+ } else {
+ // In SCI1.1 games, sound effects are started from here. If we can find
+ // a relevant audio resource, play it, otherwise switch to synthesized
+ // effects. If the resource exists, play it using map 65535 (sound
+ // effects map)
+ int16 songNumber = GET_SEL32V(_segMan, pSnd->soundObj, number);
+ EngineState *s = ((SciEngine *)g_engine)->getEngineState(); // HACK
+ AudioPlayer *audio = s->_audio;
+ ResourceManager* resMan = s->resMan;
+
+ if (resMan->testResource(ResourceId(kResourceTypeAudio, songNumber)) &&
+ getSciVersion() >= SCI_VERSION_1_1) {
+ // Found a relevant audio resource, play it
+ audio->stopAudio();
+
+ if (pSnd->pStreamAud)
+ delete pSnd->pStreamAud;
+ int sampleLen;
+ pSnd->pStreamAud = audio->getAudioStream(songNumber, 65535, &sampleLen);
+ pSnd->hCurrentAud = Audio::SoundHandle();
+
+ PUT_SEL32V(_segMan, pSnd->soundObj, signal, 0);
+
+ // FIXME: the scripts are signalled that the sound has stopped before it has
+ // actually stopped, observable in the ship flight sequence in the first scene
+ // of SQ4CD, right after the intro
+ soundPlay(pSnd);
+ } else {
+ // play MIDI track
+ if (pSnd->pMidiParser == NULL) {
+ pSnd->pMidiParser = new MidiParser_SCI();
+ pSnd->pMidiParser->setMidiDriver(_pMidiDrv);
+ pSnd->pMidiParser->setTimerRate(_dwTempo);
+ }
+ pSnd->pMidiParser->loadMusic(pTrack, pSnd);
}
- pSnd->pMidiParser->loadMusic(pTrack, pSnd);
}
}