diff options
-rw-r--r-- | engines/agi/sound_midi.cpp | 14 | ||||
-rw-r--r-- | engines/agos/agos.cpp | 6 | ||||
-rw-r--r-- | engines/agos/midi.cpp | 8 | ||||
-rw-r--r-- | engines/agos/midi.h | 2 | ||||
-rw-r--r-- | engines/draci/draci.cpp | 1 | ||||
-rw-r--r-- | engines/draci/music.cpp | 14 | ||||
-rw-r--r-- | engines/groovie/music.cpp | 4 | ||||
-rw-r--r-- | engines/lure/sound.cpp | 6 | ||||
-rw-r--r-- | engines/made/made.cpp | 1 | ||||
-rw-r--r-- | engines/made/music.cpp | 6 | ||||
-rw-r--r-- | engines/queen/music.cpp | 5 | ||||
-rw-r--r-- | engines/saga/music.cpp | 13 | ||||
-rw-r--r-- | engines/saga/music.h | 2 | ||||
-rw-r--r-- | engines/sky/music/gmmusic.cpp | 1 | ||||
-rw-r--r-- | engines/sky/music/mt32music.cpp | 1 | ||||
-rw-r--r-- | engines/tinsel/tinsel.cpp | 5 | ||||
-rw-r--r-- | engines/touche/midi.cpp | 5 | ||||
-rw-r--r-- | sound/mididrv.cpp | 13 | ||||
-rw-r--r-- | sound/mididrv.h | 10 |
19 files changed, 97 insertions, 20 deletions
diff --git a/engines/agi/sound_midi.cpp b/engines/agi/sound_midi.cpp index d2636727ee..dcdaac53a7 100644 --- a/engines/agi/sound_midi.cpp +++ b/engines/agi/sound_midi.cpp @@ -74,8 +74,12 @@ SoundGenMIDI::SoundGenMIDI(AgiEngine *vm, Audio::Mixer *pMixer) : SoundGen(vm, p DeviceHandle dev = MidiDriver::detectDevice(MDT_MIDI | MDT_ADLIB); _driver = MidiDriver::createMidi(dev); - if (ConfMan.getBool("native_mt32")) + if (ConfMan.getBool("native_mt32") || MidiDriver::getMusicType(dev) == MT_MT32) { + _nativeMT32 = true; _driver->property(MidiDriver::PROP_CHANNEL_MASK, 0x03FE); + } else { + _nativeMT32 = false; + } memset(_channel, 0, sizeof(_channel)); memset(_channelVolume, 255, sizeof(_channelVolume)); @@ -125,10 +129,10 @@ int SoundGenMIDI::open() { _driver->setTimerCallback(this, &onTimer); - // General MIDI System On message - // Resets all GM devices to default settings - _driver->sysEx((const byte *)"\x7E\x7F\x09\x01", 4); - g_system->delayMillis(20); + if (_nativeMT32) + _driver->sendMT32Reset(); + else + _driver->sendGMReset(); return 0; } diff --git a/engines/agos/agos.cpp b/engines/agos/agos.cpp index 670c701198..bbfce5f1a9 100644 --- a/engines/agos/agos.cpp +++ b/engines/agos/agos.cpp @@ -562,11 +562,11 @@ Common::Error AGOSEngine::init() { _driver = MidiDriver::createMidi(dev); - if (_nativeMT32) { + if (_nativeMT32) _driver->property(MidiDriver::PROP_CHANNEL_MASK, 0x03FE); - } - _midi.mapMT32toGM (getGameType() != GType_SIMON2 && !_nativeMT32); + _midi.setNativeMT32(_nativeMT32); + _midi.mapMT32toGM(getGameType() != GType_SIMON2 && !_nativeMT32); _midi.setDriver(_driver); diff --git a/engines/agos/midi.cpp b/engines/agos/midi.cpp index ab5bfc4c94..858307685c 100644 --- a/engines/agos/midi.cpp +++ b/engines/agos/midi.cpp @@ -77,10 +77,10 @@ int MidiPlayer::open() { return ret; _driver->setTimerCallback(this, &onTimer); - // General MIDI System On message - // Resets all GM devices to default settings - _driver->sysEx((const byte *)"\x7E\x7F\x09\x01", 4); - g_system->delayMillis(20); + if (_nativeMT32) + _driver->sendMT32Reset(); + else + _driver->sendGMReset(); return 0; } diff --git a/engines/agos/midi.h b/engines/agos/midi.h index d4c09118f6..d76997737a 100644 --- a/engines/agos/midi.h +++ b/engines/agos/midi.h @@ -61,6 +61,7 @@ protected: MidiDriver *_driver; bool _map_mt32_to_gm; bool _passThrough; + bool _nativeMT32; MusicInfo _music; MusicInfo _sfx; @@ -97,6 +98,7 @@ public: void loadS1D(Common::File *in, bool sfx = false); void mapMT32toGM(bool map); + void setNativeMT32(bool nativeMT32) { _nativeMT32 = nativeMT32; } void setLoop(bool loop); void startTrack(int track); void queueTrack(int track, bool loop); diff --git a/engines/draci/draci.cpp b/engines/draci/draci.cpp index cd3920b30d..814159dbbb 100644 --- a/engines/draci/draci.cpp +++ b/engines/draci/draci.cpp @@ -170,6 +170,7 @@ int DraciEngine::init() { _music = new MusicPlayer(_midiDriver, musicPathMask); _music->setNativeMT32(native_mt32); + _music->open(); //_music->setAdLib(adlib); // Load the game's fonts diff --git a/engines/draci/music.cpp b/engines/draci/music.cpp index 8186d36068..509bf90121 100644 --- a/engines/draci/music.cpp +++ b/engines/draci/music.cpp @@ -40,13 +40,8 @@ MusicPlayer::MusicPlayer(MidiDriver *driver, const char *pathMask) : _parser(0), memset(_channel, 0, sizeof(_channel)); memset(_channelVolume, 255, sizeof(_channelVolume)); _masterVolume = 0; - this->open(); _smfParser = MidiParser::createParser_SMF(); _midiMusicData = NULL; - - // TODO: Load cmf.ins with the instrument table. It seems that an - // interface for such an operation is supported for AdLib. Maybe for - // this card, setting instruments is necessary. } MusicPlayer::~MusicPlayer() { @@ -89,6 +84,15 @@ int MusicPlayer::open() { if (ret) return ret; + if (_nativeMT32) + _driver->sendMT32Reset(); + else + _driver->sendGMReset(); + + // TODO: Load cmf.ins with the instrument table. It seems that an + // interface for such an operation is supported for AdLib. Maybe for + // this card, setting instruments is necessary. + _driver->setTimerCallback(this, &onTimer); return 0; } diff --git a/engines/groovie/music.cpp b/engines/groovie/music.cpp index 6959a6a6f1..6ccc68c498 100644 --- a/engines/groovie/music.cpp +++ b/engines/groovie/music.cpp @@ -427,10 +427,14 @@ MusicPlayerXMI::MusicPlayerXMI(GroovieEngine *vm, const Common::String >lName) setTimbreAD(9, _timbres[i]); } } else if ((MidiDriver::getMusicType(dev) == MT_MT32) || ConfMan.getBool("native_mt32")) { + _driver->sendMT32Reset(); + // MT-32 _musicType = MT_MT32; loadTimbres(gtlName + ".mt"); } else { + _driver->sendGMReset(); + // GM _musicType = 0; } diff --git a/engines/lure/sound.cpp b/engines/lure/sound.cpp index a75545c330..ca15ad8287 100644 --- a/engines/lure/sound.cpp +++ b/engines/lure/sound.cpp @@ -63,8 +63,12 @@ SoundManager::SoundManager() { _driver = NULL; } else { - if (_nativeMT32) + if (_nativeMT32) { _driver->property(MidiDriver::PROP_CHANNEL_MASK, 0x03FE); + _driver->sendMT32Reset(); + } else { + _driver->sendGMReset(); + } for (index = 0; index < NUM_CHANNELS; ++index) { _channelsInner[index].midiChannel = _driver->allocateChannel(); diff --git a/engines/made/made.cpp b/engines/made/made.cpp index 94926014d3..51cdd83b2a 100644 --- a/engines/made/made.cpp +++ b/engines/made/made.cpp @@ -107,6 +107,7 @@ MadeEngine::MadeEngine(OSystem *syst, const MadeGameDescription *gameDesc) : Eng _music = new MusicPlayer(driver); _music->setNativeMT32(native_mt32); + _music->open(); //_music->setAdLib(adlib); // Set default sound frequency diff --git a/engines/made/music.cpp b/engines/made/music.cpp index bb45367805..4e2789e5fa 100644 --- a/engines/made/music.cpp +++ b/engines/made/music.cpp @@ -40,7 +40,6 @@ namespace Made { MusicPlayer::MusicPlayer(MidiDriver *driver) : _parser(0), _driver(driver), _looping(false), _isPlaying(false), _passThrough(false), _isGM(false) { memset(_channel, 0, sizeof(_channel)); _masterVolume = 0; - this->open(); _xmidiParser = MidiParser::createParser_XMIDI(); _smfParser = MidiParser::createParser_SMF(); } @@ -81,6 +80,11 @@ int MusicPlayer::open() { if (ret) return ret; + if (_nativeMT32) + _driver->sendMT32Reset(); + else + _driver->sendGMReset(); + _driver->setTimerCallback(this, &onTimer); return 0; } diff --git a/engines/queen/music.cpp b/engines/queen/music.cpp index 3d859c8335..be6b0dc773 100644 --- a/engines/queen/music.cpp +++ b/engines/queen/music.cpp @@ -82,6 +82,11 @@ MidiMusic::MidiMusic(QueenEngine *vm) _driver->open(); _driver->setTimerCallback(this, &timerCallback); + if (_nativeMT32) + _driver->sendMT32Reset(); + else + _driver->sendGMReset(); + _parser = MidiParser::createParser_SMF(); _parser->setMidiDriver(this); _parser->setTimerRate(_driver->getBaseTempo()); diff --git a/engines/saga/music.cpp b/engines/saga/music.cpp index e4a16e27da..eb79132495 100644 --- a/engines/saga/music.cpp +++ b/engines/saga/music.cpp @@ -60,6 +60,19 @@ MusicDriver::~MusicDriver() { delete _driver; } +int MusicDriver::open() { + int retValue = _driver->open(); + if (retValue) + return retValue; + + if (_nativeMT32) + _driver->sendMT32Reset(); + else + _driver->sendGMReset(); + + return 0; +} + void MusicDriver::setVolume(int volume) { volume = CLIP(volume, 0, 255); diff --git a/engines/saga/music.h b/engines/saga/music.h index 5cce3d4c04..e3d5723145 100644 --- a/engines/saga/music.h +++ b/engines/saga/music.h @@ -57,7 +57,7 @@ public: void setGM(bool isGM) { _isGM = isGM; } //MidiDriver interface implementation - int open() { return _driver->open(); } + int open(); void close() { _driver->close(); } void send(uint32 b); diff --git a/engines/sky/music/gmmusic.cpp b/engines/sky/music/gmmusic.cpp index f2abb3f277..e7b3a24170 100644 --- a/engines/sky/music/gmmusic.cpp +++ b/engines/sky/music/gmmusic.cpp @@ -44,6 +44,7 @@ GmMusic::GmMusic(MidiDriver *pMidiDrv, Disk *pDisk) : MusicBase(pDisk) { error("Can't open midi device. Errorcode: %d", midiRes); _timerCount = 0; _midiDrv->setTimerCallback(this, passTimerFunc); + _midiDrv->sendGMReset(); } GmMusic::~GmMusic() { diff --git a/engines/sky/music/mt32music.cpp b/engines/sky/music/mt32music.cpp index ce2a29dad8..bdefa66709 100644 --- a/engines/sky/music/mt32music.cpp +++ b/engines/sky/music/mt32music.cpp @@ -44,6 +44,7 @@ MT32Music::MT32Music(MidiDriver *pMidiDrv, Disk *pDisk) : MusicBase(pDisk) { error("Can't open midi device. Errorcode: %d",midiRes); _timerCount = 0; _midiDrv->setTimerCallback(this, passTimerFunc); + _midiDrv->sendMT32Reset(); } MT32Music::~MT32Music() { diff --git a/engines/tinsel/tinsel.cpp b/engines/tinsel/tinsel.cpp index 888a47648f..bb6ed99138 100644 --- a/engines/tinsel/tinsel.cpp +++ b/engines/tinsel/tinsel.cpp @@ -867,6 +867,11 @@ TinselEngine::TinselEngine(OSystem *syst, const TinselGameDescription *gameDesc) //_midiMusic->setNativeMT32(native_mt32); //_midiMusic->setAdLib(adlib); + if (native_mt32) + _driver->sendMT32Reset(); + else + _driver->sendGMReset(); + _musicVolume = ConfMan.getInt("music_volume"); _sound = new SoundManager(this); diff --git a/engines/touche/midi.cpp b/engines/touche/midi.cpp index 439d3b9ac2..ee7602abf7 100644 --- a/engines/touche/midi.cpp +++ b/engines/touche/midi.cpp @@ -101,6 +101,11 @@ int MidiPlayer::open() { _parser->setMidiDriver(this); _parser->setTimerRate(_driver->getBaseTempo()); _driver->setTimerCallback(this, &timerCallback); + + if (_nativeMT32) + _driver->sendMT32Reset(); + else + _driver->sendGMReset(); } return ret; } diff --git a/sound/mididrv.cpp b/sound/mididrv.cpp index eb8bafee01..b93df19558 100644 --- a/sound/mididrv.cpp +++ b/sound/mididrv.cpp @@ -306,3 +306,16 @@ MidiDriver::DeviceHandle MidiDriver::getDeviceHandle(const Common::String &ident return 0; } + +void MidiDriver::sendMT32Reset() { + static const byte resetSysEx[] = { 0x41, 0x10, 0x16, 0x12, 0x7F, 0x00, 0x00, 0x01, 0x00 }; + sysEx(resetSysEx, sizeof(resetSysEx)); + g_system->delayMillis(100); +} + +void MidiDriver::sendGMReset() { + static const byte resetSysEx[] = { 0x7E, 0x7F, 0x09, 0x01 }; + sysEx(resetSysEx, sizeof(resetSysEx)); + g_system->delayMillis(100); +} + diff --git a/sound/mididrv.h b/sound/mididrv.h index 7ba1fe19f7..9e649cba3d 100644 --- a/sound/mididrv.h +++ b/sound/mididrv.h @@ -216,6 +216,16 @@ public: } /** + * Send a Roland MT-32 reset sysEx to the midi device. + */ + void sendMT32Reset(); + + /** + * Send a General MIDI reset sysEx to the midi device. + */ + void sendGMReset(); + + /** * Transmit a sysEx to the midi device. * * The given msg MUST NOT contain the usual SysEx frame, i.e. |