Skip to content

Commit

Permalink
AGOS: Accolade MT32: General MIDI mapping
Browse files Browse the repository at this point in the history
- renamed _MT32 to _nativeMT32
this name doesn't really make sense, because MUNT isn't a native
MT32, but the name is common to the other engines
- implement MT32 -> General MIDI mapping in case no MT32 is
available
- implement dialog screen, so that user is told about General MIDI
mapping and that it may sound awful
  • Loading branch information
Martin Kiewitz committed Jun 21, 2015
1 parent 3f9c44c commit 5f77bcc
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 10 deletions.
18 changes: 13 additions & 5 deletions engines/agos/drivers/accolade/mt32.cpp
Expand Up @@ -23,6 +23,8 @@
#include "agos/agos.h"
#include "agos/drivers/accolade/mididriver.h"

#include "audio/mididrv.h"

#include "common/config-manager.h"
#include "common/file.h"
#include "common/mutex.h"
Expand Down Expand Up @@ -69,7 +71,7 @@ class MidiDriver_Accolade_MT32 : public MidiDriver {
protected:
Common::Mutex _mutex;
MidiDriver *_driver;
bool _MT32;
bool _nativeMT32; // native MT32, may also be our MUNT, or MUNT over MIDI

bool _isOpen;
int _baseFreq;
Expand All @@ -87,7 +89,7 @@ class MidiDriver_Accolade_MT32 : public MidiDriver {
MidiDriver_Accolade_MT32::MidiDriver_Accolade_MT32() {
_driver = NULL;
_isOpen = false;
_MT32 = false;
_nativeMT32 = false;
_baseFreq = 250;

memset(_channelMapping, 0, sizeof(_channelMapping));
Expand All @@ -113,13 +115,14 @@ int MidiDriver_Accolade_MT32::open() {
MidiDriver::DeviceHandle dev = MidiDriver::detectDevice(MDT_MIDI | MDT_PREFER_MT32);
MusicType musicType = MidiDriver::getMusicType(dev);

// check, if we got a real MT32 (or MUNT, or MUNT over MIDI)
switch (musicType) {
case MT_MT32:
_MT32 = true;
_nativeMT32 = true;
break;
case MT_GM:
if (ConfMan.getBool("native_mt32")) {
_MT32 = true;
_nativeMT32 = true;
}
break;
default:
Expand All @@ -134,7 +137,7 @@ int MidiDriver_Accolade_MT32::open() {
if (ret)
return ret;

if (_MT32)
if (_nativeMT32)
_driver->sendMT32Reset();
else
_driver->sendGMReset();
Expand Down Expand Up @@ -170,6 +173,11 @@ void MidiDriver_Accolade_MT32::send(uint32 b) {
// Figure out the requested instrument
byte midiInstrument = (b >> 8) & 0xFF;
byte mappedInstrument = _instrumentMapping[midiInstrument];

// If there is no actual MT32 (or MUNT), we make a second mapping to General MIDI instruments
if (!_nativeMT32) {
mappedInstrument = (MidiDriver::_mt32ToGm[mappedInstrument]);
}
// And replace it
b = (b & 0xFFFF00FF) | (mappedInstrument << 8);
}
Expand Down
17 changes: 12 additions & 5 deletions engines/agos/midi.cpp
Expand Up @@ -29,6 +29,8 @@

#include "agos/drivers/accolade/mididriver.h"

#include "gui/message.h"

namespace AGOS {


Expand Down Expand Up @@ -114,12 +116,17 @@ int MidiPlayer::open(int gameType, bool isDemo) {
case MT_MT32:
break;
case MT_GM:
if (ConfMan.getBool("native_mt32")) {
// Real MT32
accoladeMusicType = MT_MT32;
} else {
_accoladeMode = false;
if (!ConfMan.getBool("native_mt32")) {
// Not a real MT32 / no MUNT
::GUI::MessageDialog dialog(("You appear to be using a General MIDI device,\n"
"but your game only supports Roland MT32 MIDI.\n"
"We try to map the Roland MT32 instruments to\n"
"General MIDI ones. It is still possible that\n"
"some tracks sound incorrect."));
dialog.runModal();
}
// Switch to MT32 driver in any case
accoladeMusicType = MT_MT32;
break;
default:
_accoladeMode = false;
Expand Down

0 comments on commit 5f77bcc

Please sign in to comment.