aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorJohannes Schickel2006-03-28 15:15:36 +0000
committerJohannes Schickel2006-03-28 15:15:36 +0000
commitc09d1ea52032be21fed34fa1ca17484af202b547 (patch)
treea1577c4b306fb6b18068dd692cd8c391228e6596 /engines
parent46270a5dd7ffd36ba741f54865fa3715e8b5c6e7 (diff)
downloadscummvm-rg350-c09d1ea52032be21fed34fa1ca17484af202b547.tar.gz
scummvm-rg350-c09d1ea52032be21fed34fa1ca17484af202b547.tar.bz2
scummvm-rg350-c09d1ea52032be21fed34fa1ca17484af202b547.zip
- Commits heaviliy modifed patch #1459951 ("KYRA: Combining MIDI music with Adlib sfx") (created a wrapper class for two different sound drivers instead of adding a new variable to the KyraEngine class and chaning stuff there)
- Prevents to play track 0 for non mt-32 midi devices (got ugly sound output with windows midi) svn-id: r21479
Diffstat (limited to 'engines')
-rw-r--r--engines/kyra/kyra.cpp14
-rw-r--r--engines/kyra/sound.cpp9
-rw-r--r--engines/kyra/sound.h24
3 files changed, 42 insertions, 5 deletions
diff --git a/engines/kyra/kyra.cpp b/engines/kyra/kyra.cpp
index ac534c010f..75ade891cd 100644
--- a/engines/kyra/kyra.cpp
+++ b/engines/kyra/kyra.cpp
@@ -330,7 +330,7 @@ int KyraEngine::init(GameDetector &detector) {
_system->initSize(320, 200);
_system->endGFXTransaction();
- // for now we prefer MIDI-to-Adlib conversion over native midi
+ // for now we prefer Adlib over native MIDI
int midiDriver = MidiDriver::detectMusicDriver(MDT_MIDI | MDT_ADLIB/* | MDT_PREFER_MIDI*/);
if (midiDriver == MD_ADLIB) {
@@ -349,6 +349,18 @@ int KyraEngine::init(GameDetector &detector) {
_sound = soundMidiPc;
assert(_sound);
soundMidiPc->hasNativeMT32(native_mt32);
+
+ // Unlike some SCUMM games, it's not that the MIDI sounds are
+ // missing. It's just that at least at the time of writing they
+ // decidedly inferior to the Adlib ones.
+
+ if (ConfMan.getBool("multi_midi")) {
+ SoundAdlibPC *adlib = new SoundAdlibPC(_mixer, this);
+ assert(adlib);
+
+ _sound = new MixedSoundDriver(this, _mixer, soundMidiPc, adlib);
+ assert(_sound);
+ }
}
if (!_sound->init()) {
error("Couldn't init sound");
diff --git a/engines/kyra/sound.cpp b/engines/kyra/sound.cpp
index 1b37c0a768..482ed96e61 100644
--- a/engines/kyra/sound.cpp
+++ b/engines/kyra/sound.cpp
@@ -247,9 +247,9 @@ void SoundMidiPC::playMusic(uint8 *data, uint32 size) {
return;
}
- _parser->setTrack(0);
_parser->setMidiDriver(this);
_parser->setTimerRate(getBaseTempo());
+ _parser->setTempo(0);
_parser->property(MidiParser::mpAutoLoop, true);
}
@@ -282,9 +282,9 @@ void SoundMidiPC::loadSoundEffectFile(uint8 *data, uint32 size) {
return;
}
- _soundEffect->setTrack(0);
_soundEffect->setMidiDriver(this);
_soundEffect->setTimerRate(getBaseTempo());
+ _soundEffect->setTempo(0);
_soundEffect->property(MidiParser::mpAutoLoop, false);
}
@@ -357,7 +357,7 @@ void SoundMidiPC::onTimer(void *refCon) {
}
void SoundMidiPC::playTrack(uint8 track) {
- if (_parser) {
+ if (_parser && (track != 0 || _nativeMT32)) {
_isPlaying = true;
_fadeMusicOut = false;
_fadeStartTime = 0;
@@ -376,7 +376,7 @@ void SoundMidiPC::haltTrack() {
setVolume(255);
_parser->setTrack(0);
_parser->jumpToTick(0);
- _parser->setTempo(1);
+ _parser->setTempo(0);
}
}
@@ -385,6 +385,7 @@ void SoundMidiPC::playSoundEffect(uint8 track) {
_sfxIsPlaying = true;
_soundEffect->setTrack(track);
_soundEffect->jumpToTick(0);
+ _soundEffect->setTempo(1);
_soundEffect->property(MidiParser::mpAutoLoop, false);
}
}
diff --git a/engines/kyra/sound.h b/engines/kyra/sound.h
index 117b0c2cf1..9d0c131c5c 100644
--- a/engines/kyra/sound.h
+++ b/engines/kyra/sound.h
@@ -188,6 +188,30 @@ private:
MidiParser *_soundEffect;
byte *_soundEffectSource;
};
+
+class MixedSoundDriver : public Sound {
+public:
+ MixedSoundDriver(KyraEngine *engine, Audio::Mixer *mixer, Sound *music, Sound *sfx) : Sound(engine, mixer), _music(music), _sfx(sfx) {}
+ ~MixedSoundDriver() { delete _music; delete _sfx; }
+
+ bool init() { return _music->init() | _sfx->init(); }
+ void process() { _music->process(); _sfx->process(); }
+
+ void setVolume(int volume) { _music->setVolume(volume); _sfx->setVolume(volume); }
+ int getVolume() { return _music->getVolume(); }
+
+ void loadMusicFile(const char *file) { _music->loadMusicFile(file); _sfx->loadMusicFile(file); }
+
+ void playTrack(uint8 track) { _music->playTrack(track); }
+ void haltTrack() { _music->haltTrack(); }
+
+ void playSoundEffect(uint8 track) { _sfx->playSoundEffect(track); }
+
+ void beginFadeOut() { _music->beginFadeOut(); }
+private:
+ Sound *_music, *_sfx;
+};
+
} // end of namespace Kyra
#endif