mirror of
https://github.com/scummvm/scummvm.git
synced 2026-06-20 05:45:29 +00:00
- 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
This commit is contained in:
+13
-1
@@ -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");
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user