Skip to content

FM OPL Midi Player

like the old Windows OPL MIDI driver, but better (plus CMF+LAA support)

Technical discussion which is not directly related to VGM files. Talk about Hardware and Software.

Moderator: Staff

  • User avatar
  • ValleyBell Offline
  • Posts: 4768
  • Joined: 2011-12-01, 20:20:07
  • Location: Germany

FM OPL Midi Player

Post by ValleyBell »

When MaliceX mentioned my MIDI Player recently, I noticed that it never had an offical release.
There is a link to it in a post dealing with fixed Sonic & Knuckles PC MIDIs, but else I only posted it in IRC.

So, this is the offical release of MidiPlay, my FM OPL MIDI Player.
You can download the Win32 Binary and you can also get the source code (includes VC6 project files)
The archive with the binary contains various instrument sets and a few .txt files related to the research I did.

The MIDI player focuses on support for usual MID files, but CMF and LAA (Lucas Arts songs, v1+v2) also work.
Controls are similar to VGMPlay (because it's based on it), i.e. cursor keys for seeking, ESC quits, Space pauses, 'F' fades out and 'R' restarts the song.
You can enable WAV and VGM logging by editing the .ini file. (VGM logging locks the sample rate to 44100 Hz, btw.)
If you have an OPL sound card, you can play the MIDIs on it directly, too. (for Windows NT/2000/XP you need to install PortTalk)

MIDI support
The initial implementation was based on observations from the Windows OPL driver, but there are various improvements:
  • Modulation Wheel and Expression
  • pan law volume compensation (makes hard-panned channels slightly louder to make up for the missing speaker)
  • RPNs for Pitch Bend Range and Fine/Coarse Detune
  • Sustain Pedal (was half-broken in WinFM driver) and Sostenuto
  • multiple drum channels via SysEx events (GS mode) and Bank MSB (XG mode)
  • SysEx messages for GM Master Volume and XG Master Volume/Detune/Transpose
The improvements can be disabled by editing the .ini file. (e.g. for playing back the S&K PC MIDIs)
The drum pitch table is currently hardcoded and based on SB16.VXD from Creative's Win95 driver. I know that Windows 2000/XP uses a different table (actually none, it just uses the drum note ID as drum frequency). The one used in Windows 3 is different as well.

CMF support
All common controllers are supported, polyphony is possible. A few things behave differrently from the official SBFMDRV.COM though. Especially the volume calculation is off.

LAA support
LAA v1: sounds accurate, but lacks software vibrato
LAA v2: I'm pretty sure that the instruments are off. The volume calculation (although ported from ScummVM) seems questionable and there's no software vibrato. Pressing 'S' executes the next conditional jump.

I haven't worked on it since January 2013, so there are still a few bugs in it. IIRC it can crash sometimes when seeking through MIDIs that make heavy use of the sustain pedal or don't terminate notes properly.

Anyway, enjoy listening to MIDIs as they sounded back in Windows 95!
  • User avatar
  • MaliceX Offline
  • Posts: 226
  • Joined: 2012-09-29, 11:45:48
  • Location: Australia
  • Contact:

Post by MaliceX »

Nice to see this finally being released. ;)
-dj.tuBIG/MaliceX
  • andre Offline
  • Posts: 1
  • Joined: 2015-06-06, 23:44:58

Post by andre »

Thanks a lot ValleyBell and MaliceX. I've been looking for something like this since my PIII died in 2010 :(
Both emulators sounds almost exactly as I remember.

malice, if you're reading this: where can we get the latest binary for the user mode driver?
  • User avatar
  • MaliceX Offline
  • Posts: 226
  • Joined: 2012-09-29, 11:45:48
  • Location: Australia
  • Contact:

Post by MaliceX »

andre wrote:Thanks a lot ValleyBell and MaliceX. I've been looking for something like this since my PIII died in 2010 :(
Both emulators sounds almost exactly as I remember.

malice, if you're reading this: where can we get the latest binary for the user mode driver?
There's a separate thread for it here (although yes it is lacking in updates): http://vgmrips.net/forum/viewtopic.php?f=15&t=1167

It needs to go through a rewrite. I've come across some serious issues with strange memory corruption issues and such with my fork of khokh2001's user mode driver. Difficult to debug.
-dj.tuBIG/MaliceX
  • User avatar
  • kyusawamura Offline
  • Posts: 33
  • Joined: 2015-06-08, 20:42:22
  • Location: Argentina
  • Contact:

Custom bank support! Plus a few things. :B

Post by kyusawamura »

Hello, ValleyBell. I am very pleased with your work and I already converted some of my old MIDIs into VGM to play them on my phone! (and save space by ditching unnecessary streaming audio formats :wink:)

Now, I found a few issues with the OPL3 emulation: instruments with certain volumes get lost in the mix, which didn't happen with MaliceX's OPL3 User Mode driver, or at least not that I remember. My most legit reference is a Pentium 1 at 100 MHz with Windows 95 and Sound Blaster 16 CT2230 that I used to have (I still have the sound card with me), and I don't remember having had volume issues with the MIDIs in question. Save for a few polyphony issues (and the fact that my sound card didn't support - or didn't have the drivers to support sustain pedal and volume changes on notes already playing, back in the day), MaliceX's driver seemed to be more accurate to me in terms of volume and, most noticeably to me, the sound of the drums. Both yours and MaliceX's kick drum are perfect, but the toms are different and the ones in the OPL3 User Mode driver seemed more accurate to me.

The point being: is there any way MidiPlay can support other FM based GM/GS/XG banks, or convert banks used by other FM based applications or games with FM sound? I'm particularly interested in being able to use banks included in htsfms, like the one that I used for making this cover of Turbulence from Dune: The Battle For Arrakis.

Thanks a lot for making such an awesome program! Keep it up! :D
  • User avatar
  • MaliceX Offline
  • Posts: 226
  • Joined: 2012-09-29, 11:45:48
  • Location: Australia
  • Contact:

Post by MaliceX »

htsfms is a completely different beast altogether as far as its algos are concerned, and wouldn't be compatible with OPL3 register commands.

I think the only reason mine sounded different is because I was using khokh2001's OPL3 core instead of DOSBOX's. The volume is probably more "accurate" (in terms of resembling the Win95/98 FM stuff in its full cruddy glory) on my one because it was directly taken from Windows' reference code. :P Have you tried enabling the WinFM volume modes on MidiPlay?

I can't remember if there were any differences with the tom patches on the Windows VxD patch set, but I recall it was something like a different pitch or something.
-dj.tuBIG/MaliceX
  • User avatar
  • kyusawamura Offline
  • Posts: 33
  • Joined: 2015-06-08, 20:42:22
  • Location: Argentina
  • Contact:

Post by kyusawamura »

I have the WinFM mode set by default for my MIDIs to sound as authentic SB16 as possible (without newly added controller support). I also tried the VxD reading Win95 (the one I attached in this message) and it sounds really, really weird, like it's not even meant to be used as a GM bank.

Admin edit: Removed fullquote.
Attachments
SB16_VXD_DrumNote_Win95.zip
(370 Bytes) Downloaded 527 times
  • User avatar
  • ValleyBell Offline
  • Posts: 4768
  • Joined: 2011-12-01, 20:20:07
  • Location: Germany

Post by ValleyBell »

You can use other FM banks, if you convert them to the right format. That requires some knowledge about OPL FM instruments though.
Each instrument is 1Ch bytes long. The order of the operator bytes is:
20 40 60 80 E0 23 43 63 83 E3 (for bytes 00h-09h)
Operator C0 is at offset 18h, the other bytes are ignored by MidiPlay.

The volume calculation might be slightly inaccurate, because I'm using an approximation of the original look-up-table. I also ignore the "base volume" of the FM instruments - not sure if the original FM driver does that. Both things might make a few instruments louder than in the WinFM driver. (Now that I think of it - I ommitted the *0.9 factor on the volumes to make everything louder. That might break the volume relation a little, since that factor is applied to the logarithmic volume values.)
The reimplementation is based on observations made by listening to the Windows 2000 FM driver, btw, which has cheap support for the sustain pedal (releasing it stops all notes on the channel) and supports changing the volume of playing notes. I can confirm that, with the SB16 driver, at least the volume changes don't have an immediate effect.

The polyphony issues might come from the fact that I use a more complex algorithm to determine the channel the next note should play on.

The pitch of the drums is an interesting thing, btw. MidiPlay currently uses the pitches I extracted from SB16.VXD, but they are hardcoded into the .exe. (search for 23 23 34 30) It doesn't read them from an external file - SB16_VXD_DrumNote_Win95.bin is provided just for reference.
From what I've observed Windows 2000 uses the drum's note ID has pitch value. (23 24 25 26 etc.) The Windows 3.1 driver seems to use even different pitch values that I haven't researched yet. So far I prefer the Win95 ones, btw.
  • kirishima Offline
  • Posts: 82
  • Joined: 2015-06-18, 22:26:41

Post by kirishima »

I tried this with an xfm file from The Elder Scrolls Arena, and the program couldn't play it. Renaming the extension to mid didn't fix the issue either despite becoming playable in other players like foobar.
Attachments
DUNGEON1.7z
(1.15 KiB) Downloaded 459 times
  • User avatar
  • ValleyBell Offline
  • Posts: 4768
  • Joined: 2011-12-01, 20:20:07
  • Location: Germany

Post by ValleyBell »

That's not an MID file, but an XMI file. The player supports only MID, CMF and LAA and not all those other MIDI variations like XMI, HMI, etc. that the MIDI plugins in Winamp and foobar support.

Post by kode54 »

Feel free to swipe my MIDI processing library if you want to handle more formats. It loads MID, RMI, XMI, MUS, MIDS, HMI, HMP, GMF, and LDS, into a common track/event structure, and can downmix the result into both .MID files and a timestamped event stream, and supports searching for loop markers. I may yet add partial unrolling of loop end/start points, to maintain the timing of note off commands that are past the loop end marker.

https://gitlab.kode54.net/kode54/midi_processing
  • User avatar
  • kyusawamura Offline
  • Posts: 33
  • Joined: 2015-06-08, 20:42:22
  • Location: Argentina
  • Contact:

Got the samples needed for the addressed issue about toms

Post by kyusawamura »

I finally got my hands on just what little software I needed to record all the samples to post here.
Later on I will do the same about the mentioned issue I said I had been experiencing with volume relations, but before I report this "issue" I'll look through it more thoroughly.

So, here are the samples I rendered using two of the provided .bin banks in the player - the one used by default and one of the others of which purpose I still don't know (despite ValleyBell having told me it was for tone reference), and a What-U-Hear recording of MaliceX's original OPL3 User Mode MIDI driver, and the original MIDI just in case it's needed.
Attachments
toms_test.zip
Tom timbre test with the SB16_VXD_InsDrum and SB16_VXD_DrumNote_Win95 banks, and MaliceX's OPL3 User Mode driver.
(261.19 KiB) Downloaded 478 times
  • User avatar
  • Laserhound Offline
  • Posts: 1
  • Joined: 2019-06-12, 6:22:03

Post by Laserhound »

ValleyBell wrote:Anyway, enjoy listening to MIDIs as they sounded back in Windows 95!
I've tried a half-dozen other OPL emulators in the last couple days -- yours is the most faithful to how I recall my SB16 sounding.

Thanks for making this! I have a SW1000XG in my old MIDI box but finding a good FM synth has been the hardest part of the build
  • denjhang Offline
  • Posts: 95
  • Joined: 2021-03-24, 4:44:34
  • Location: hk

Post by denjhang »

Can midiplay use a custom instrument library?
Such as wopl format.
  • pianino Offline
  • Posts: 65
  • Joined: 2014-11-29, 21:36:08
  • Location: quito, ecuador

Post by pianino »

awesome tool!.
but, i have a question, how can i change the banks? so my favorite is the default win 95 patche that is in the program.
My favorite sound chip?, YM-2413!
Post Reply