Page 1 of 1

OPL3 Music Emulation in KotC

PostPosted: Sat Aug 10, 2019 7:36 am
by Saikou
Hey all! This is perhaps kind of a weird question, and almost certainly a long shot, but here goes. I was checking out the demo of KotC1 and really enjoying it, but the MSGS MIDI sound really started to wear on me after a while. I figured I really wanted to capture the feeling of the old computer-RPGs like Dark Sun the game claims to follow after, so with the help of some friends, I figured out how to set up OPL3 emulation (an FM-synthesis sound card common in the mid-to-late 90s) in Windows 10. And, as expected, when I play MIDIs out of the demo's included MIDI folder, it sounds just like those old games. However, when I boot up KotC to actually play the game, the music is the same old general-MIDI as ever.
In short, I'm wondering if this is anything I have any control over or if it's just not possible without the developer explicitly coding in support for non-default MIDI devices. It would really enhance the experience to be able to pair the old-timey sprite graphics with some period-appropriate OPL synth sounds, but as of yet my only option to do so is to keep the soundtrack folder open and swap the songs out manually with the actual game audio muted, which not only is a bit of a pain in general but also breaks the immersion pretty hard. Any help, advice, or stories of anyone doing a similar thing would be much appreciated.

Re: OPL3 Music Emulation in KotC

PostPosted: Tue Aug 13, 2019 5:30 pm
by BlueSalamander
Hello and welcome Saikou, thank you for your post. I'm afraid I don't have enough knowledge of non-default MIDI devices to be able to answer properly. Sorry about that!

Re: OPL3 Music Emulation in KotC

PostPosted: Fri Sep 13, 2019 2:38 am
by galneon
I'm an enthusiast of this sort of thing and use VirtualMidiSynth set as the default MIDI device. Unfortunately, KOTC either has a built-in MIDI player, or it's coded to throw not to the default MIDI device, but specifically to MSGS. If it's the latter, the game just needs to instead default to the default system MIDI device rather than MSGS.

This actually has nothing to do with the consistently downgraded and, as of Windows 10, now non-existent Windows MIDI device selector--3rd party programs allow you to specify a default device like before MS gutted this core OS functionality. Setting VirtualMidiSynth as the default using the related 3rd party MIDIMapper program results in the expected functionality in DOSBox and all Windows programs--except KOTC.

This is actually preventing me from doing a replay... I've been spoiled in recent years by using better soundfonts with old DOS games, and KOTC's instruments sound inferior to all of them. It's too hard to go back. :/

Pierre, if only it were picking the default device (device #0) we'd be happy. Please see if you've perhaps hardcoded Microsoft GS Wavetable Synth and could instead have the game select the default MIDI device? None of the Windows 8/10 changes are relevant for your purposes: Windows 8/10 no longer allows the user to choose a default (without an application like MIDIMapper), but enumeration is randomized and inconsistent, and whatever gets labeled device #0 is effectively the default which is selected when an application doesn't specify a destination for MIDI output.

All this means the bulk of your users who don't care much about sound won't be affected one way or the other, but those of us who do care will get proper softsynth playback.

If I've been less than clear about any of this, I'm happy to clarify. I care more about audio than graphics, and this should be a rather simple tweak (unless the game is indeed using an integrated player).

Re: OPL3 Music Emulation in KotC

PostPosted: Wed Sep 18, 2019 6:47 pm
by BlueSalamander
To be honest I know nothing about all this. I didn't write any of the MIDI playback code. I just used the old DirectX component called DirectMusic. The code to initialise DirectMusic is just the following:

IDirectMusicPerformance8* m_pDMPerformance;
IDirectMusicLoader8* m_pDMLoader;
CoCreateInstance(CLSID_DirectMusicLoader, NULL, CLSCTX_INPROC, IID_IDirectMusicLoader8, (void**)&m_pDMLoader);
CoCreateInstance(CLSID_DirectMusicPerformance, NULL, CLSCTX_INPROC, IID_IDirectMusicPerformance8, (void**)&m_pDMPerformance);
m_pDMPerformance->InitAudio(NULL, NULL, m_hWnd, DMUS_APATH_SHARED_STEREOPLUSREVERB, 128, DMUS_AUDIOF_ALL, NULL);

The relevant pages are the following:
https://docs.microsoft.com/en-us/previous-versions/ms809711(v%3Dmsdn.10)
https://docs.microsoft.com/en-us/windows-hardware/drivers/audio/midi-and-directmusic-filters
https://docs.microsoft.com/en-us/windows-hardware/drivers/audio/midi-and-directmusic-components

So if you know what needs to be changed, okay, I can try that. Otherwise we're stuck. :|

Re: OPL3 Music Emulation in KotC

PostPosted: Wed Sep 18, 2019 10:47 pm
by galneon
Thanks so much for the response and info! I'm going to dig around a bit.

Re: OPL3 Music Emulation in KotC

PostPosted: Thu Sep 19, 2019 3:45 pm
by BlueSalamander
Okey dokey, thank you :-)