VOGONS


First post, by galneon

User metadata
Rank Newbie
Rank
Newbie

I've recently gone back to the excellent Knights of the Chalice and have found I cannot output MIDI to VirtualMidiSynth (or any other device) no matter what I do. It's always MS GS Wavetable + reverb. I found out it's because of how the game handles MIDI. The MIDI tracks are standard and playback is just fine, with the device of my choice, when I load the .mid files in a proper player--this tells me they probably weren't authored with the old DirectMusic Producer program which could (from what I can tell) generate nonstandard MIDI specifically for playback via DirectMusic's integrated solution.

This is the code KotC uses to playback MIDI:

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);

It seems like the proper solution, to output raw MIDI to the default/#0 device, would be far simpler. Does anyone have any ideas for achieving this via code?

Origin of the plight: http://www.heroicfantasygames.com/Forums/view … f=2&t=792#p5360

This is one of the best classic D&D games I've ever played (it's OGL 3.5, and the sequel is on the way), and I have a hard time playing Dark Sun with high-quality soundfonts, only to play a much newer game influenced by it which only supports MS GS Wavetable Synth via the ancient built-in player.

There are probably a handful of games from the late '90s/early '00s which have this problem. KotC is more recent, but nonetheless, we won't always have the original source code to modify (that is, if anyone knows how to convert KotC). I wonder how practical it is to intercept the raw MIDI in those situations?

(Note this isn't in any way related to the lack of a MIDI device selector from Win8 onward--I use 10 with CoolSoft's MIDIMapper and have no issues elsewhere. Damn these games stuck between modernity and DOS. 😜)

Reply 1 of 4, by DosFreak

User metadata
Rank l33t++
Rank
l33t++

Does this work?
https://greatemerald.eu/blog/solving-the-unre … i-intro-problem

DOSBox Compilation Guides
DosBox Feature Request Thread
PC Game Compatibility List
How To Ask Questions The Smart Way
Running DRM games offline

Reply 2 of 4, by galneon

User metadata
Rank Newbie
Rank
Newbie
DosFreak wrote:

No. All the DirectMusic functionality required for the 'built-in' MIDI playback is still present in Windows 10, and KotC is, as a result, working just like it's supposed to work, sadly, locked to the MS GS Wavetable synth. It requires some other workaround, or the code to be changed in-game, to allow users to use real hardware or softsynth devices. The developer is willing to change the code to make it work like most normal applications which, even if they don't allow you to pick a specific MIDI device within the application, will at least output raw MIDI to the default/#0 device, but he doesn't know how.

Reply 3 of 4, by Falcosoft

User metadata
Rank Oldbie
Rank
Oldbie

Hi,
In the DirectX 7 era I experimented with Directmusic but somehow I suspected that contrary to MS suggestions this was not the MIDI API of future on Windows (and continued using the classic Win32 WinMM MIDI functions that still work flawlessly even nowadays). I used earlier interfaces than in the above code (IDirectMusicPerformance vs. IDirectMusicPerformance8) so I cannot help with direct code snippets but according to specification:
1. With the help of IDirectMusic::EnumPort(dwIndex, pPortCaps) you can get the CLSID of Microsoft Midi Mapper [Emulated] if you set dwIndex to zero(0). You can find the CLSID after the call in pPortCaps.guidPort.
2. You can use IDirectMusicPerformance8::InitAudio with this CLSID instead of default one (always MS GM/GS Softsynth) if you set in the last parameter of InitAudio (pParams) the clsidDefaultSynth member.
If you use the CLSID of Port 0 (MS Midi Mapper) then Directmusic will always use the default device that you set on OS level. It works even with Win10 if you use Coolsoft Midi Mapper.
More Info:
http://idlebeaver.ninja/dx7/devdoc/live/direc … /dmref_59ur.htm
http://doc.51windows.net/Directx9_SDK/htm/idi … e8initaudio.htm
https://docs.microsoft.com/en-us/previo ... 3Dmsdn.10)

Here's my old test application. You can check how different port indexes work by changing the 'Port Num' value:

Filename
DirectMusic_Test.zip
File size
214.68 KiB
Downloads
7 downloads
File license
Fair use/fair dealing exception

Website, Facebook, Youtube
Falcosoft Midi Player + Munt VSTi + BassMidi VSTi topic

Reply 4 of 4, by galneon

User metadata
Rank Newbie
Rank
Newbie
Falcosoft wrote:
Hi, In the DirectX 7 era I experimented with Directmusic but somehow I suspected that contrary to MS suggestions this was not th […]
Show full quote

Hi,
In the DirectX 7 era I experimented with Directmusic but somehow I suspected that contrary to MS suggestions this was not the MIDI API of future on Windows (and continued using the classic Win32 WinMM MIDI functions that still work flawlessly even nowadays). I used earlier interfaces than in the above code (IDirectMusicPerformance vs. IDirectMusicPerformance8) so I cannot help with direct code snippets but according to specification:
1. With the help of IDirectMusic::EnumPort(dwIndex, pPortCaps) you can get the CLSID of Microsoft Midi Mapper [Emulated] if you set dwIndex to zero(0). You can find the CLSID after the call in pPortCaps.guidPort.
2. You can use IDirectMusicPerformance8::InitAudio with this CLSID instead of default one (always MS GM/GS Softsynth) if you set in the last parameter of InitAudio (pParams) the clsidDefaultSynth member.
If you use the CLSID of Port 0 (MS Midi Mapper) then Directmusic will always use the default device that you set on OS level. It works even with Win10 if you use Coolsoft Midi Mapper.
More Info:
http://idlebeaver.ninja/dx7/devdoc/live/direc … /dmref_59ur.htm
http://doc.51windows.net/Directx9_SDK/htm/idi … e8initaudio.htm
https://docs.microsoft.com/en-us/previo ... 3Dmsdn.10)

Here's my old test application. You can check how different port indexes work by changing the 'Port Num' value:

DirectMusic_Test.zip

Thanks so much for this, and my apologies for not responding sooner... To be honest, I've been trying to figure out what I can do with this information, but I have nigh-zero experience. I was hoping it would be simpler, e.g. a drop-in replacement snippet, or maybe some wrapper that's already out there. I will nonetheless point the developer this way. I know he could figure it out, but I don't know if he'd be willing to spend time changing over to the standard method of outputting MIDI to the mapper default.

Do you think this is a legacy concern for the few decent games that rely on DirectMusic for MIDI playback? Can you see MS possibly patching out that support in the future? It's already a quality problem as many of us are spoiled with our own soundfont preferences, and MS GS is among the worst (the worst take on the SC I have heard, at least)... Bleh. Like I said before, it's hard to swallow when most DOS games I play have superior music sound quality to a modern take on those classics, and but for a few lines of code that would not be the case.

DosFreak, sorry about the curt reply before. Anyone who has visited VOGONS more than a few times has probably been helped by you, either directly or by coming across your past posts. Thank you.