schellingb / dosbox-pure

DOSBox Pure is a new fork of DOSBox built for RetroArch/Libretro aiming for simplicity and ease of use.
GNU General Public License v2.0
731 stars 61 forks source link

Wrong MIDI instruments with the Frontend MIDI option #473

Open uzernaem opened 4 months ago

uzernaem commented 4 months ago

Frontend MIDI option is broken at this time, some MIDI channels default to piano instrument, regardless of what MIDI synth is configured and used on front. Tested with VirtualMIDI with different soundfonts and with standard Microsoft GS Wavetable synth on RetroArch 1.17.0 Windows 64bit build and DOSBox Pure 0.9.9

PoloniumRain commented 4 months ago

Can you list any games with this problem? Preferably popular games because i know how they sound. I've not noticed any incorrect sounds with any of my SoundFonts though.

uzernaem commented 4 months ago

Hi,

I've made a quick demonstration with Doom II. Please bear in mind that the issue concerns the frontend MIDI option. In the clip I switch from frontend MIDI to internal DOSBox Pure MIDI at 0:27 and it starts sounding fine https://www.youtube.com/watch?v=iadPOywavvI

My MIDI output in RetroArch is standard Microsoft GS Wavetable Synth during this recording, but I am also getting the same result with VirtualMIDI synth.

Tasosgemah commented 4 months ago

Can you list any games with this problem? Preferably popular games because i know how they sound. I've not noticed any incorrect sounds with any of my SoundFonts though.

This isn't a soundfont issue, if you pick a soundfont in the core audio options it sounds as the soundfont should. This issue only appears if you select "frontend MIDI" in the core audio options. And i can also confirm it happens to me too on DOOM II.

However, i also tested Duke Nukem 3D and that sounds correct even with frontend midi selected. So i don't know what's going on. I tried both "General Midi" and "Sound Canvas" in DOOM II and they both have the wrong instruments issue but Duke Nukem 3D seems fine.

PoloniumRain commented 4 months ago

I've finally managed to reproduce this issue and found a temporary fix. Hopefully @schellingb can also reproduce it.

I'll use the Doom II eXoDOS version as an example:

  1. Select Frontend MIDI in the Core Options and run the included Doom II RUN.BAT. Choose Sound Canvas.
  2. You should immediately hear the incorrect piano sounds when the game starts.
  3. Hit F1 and hold down the Shift key while selecting Restart.
  4. Highlight the DOOM2.EXE and press the right arrow key to set it to skip 100 frames. Hit Enter to start the game.
  5. Again you'll hear the incorrect sounds. But...
  6. Restart the game and it should now sound correct.
  7. Close the game and run it again and it should still sound correct.

Maybe DOSBox Pure isn't saving the games sound settings properly?

uzernaem commented 4 months ago

I've noticed an interesting thing after I have set my midi output to a VSC VSTi plugin with config window always on top so I could see what instruments are being used. When launching Doom 2, correct instruments are set for a split second, right when the startup text screen fades into the main title screen (screenshot 1, it fades very quick) but when the title screen appears, the instruments are reset to piano (screenshot 2). So apparently the game attempts to run with correct instruments but some event resets them. 1 2

PoloniumRain commented 4 months ago

Maybe that explains why the correct instruments play for me when i set the Auto Start to skip the first 100 frames when launching Doom II. It's as if it skips past whatever is triggering the incorrect instruments to play. This could also be a RetroArch issue but i've not tried any other cores with the frontend MIDI...

Tasosgemah commented 4 months ago

I wonder what DOOM II does differently that others don't. I haven't tested a ton of games though.

PoloniumRain commented 4 months ago

Tried some more games:

Doom/Ultimate Doom are missing some sounds on the launch screen. Heretic has the same type of incorrect piano sounds Hexen also has the piano

So far every game i try that's based on the same id Software engine (AKA the "Doom engine") has this issue. But i haven't found any games with this problem that are not based on this engine.

I never normally use the frontend MIDI though. It drives me mad when i press F1 and whatever instrument is currently playing will just carry on for infinity or take ages to stop playing. Sometimes the game needs to be closed to get rid of it. That's always been a problem (probably should have posted an issue about it!).

Typically i use the SC55_zzdenis soundfont which i've found to be very accurate to real hardware. Definitely better than the standard SC_55 soundfont, but the volume is a little lower (easily fixed though).

Tasosgemah commented 4 months ago

Typically i use the SC55_zzdenis soundfont which i've found to be very accurate to real hardware. Definitely better than the standard SC_55 soundfont, but the volume is a little lower (easily fixed though).

A bit off topic but i never understood what "accurate to the real hardware" means whenever the soundfont topic comes up. I have tried a lot of different SC55 fonts that are supposed to be accurate but they all sound different with each other or the original soundtracks of various games (i mostly test DOOM and Duke Nukem).

The one you posted also sounds completely different from the original soundtrack. Completely different instruments and all, there's also a video preview on the same page so it's not just me. Edit: I'm wrong, it sounds good.

Personally, i only care about the original sound and instruments, which i assume is what the official OSTs sound like. And with that in mind, the soundfont that comes the closest to that (from the ones i have used so far) is this:

https://www.vogonsdrivers.com/getfile.php?fileid=500&menustate=0

PoloniumRain commented 4 months ago

Lol did you watch the YouTube video on that page and not try the soundfont or read the posts? ... The video you mentioned is a remix of a Doom track by another guy. It's his own music creation, but he's playing it with the soundfont i linked.

So that's not how the zzdenis soundfont sounds when actually playing Doom. The soundfont itself is recorded with a Roland RA90 and SC-55mk2 at a high sample rate. It's accurate to real hardware because it was literally recorded using real hardware.

uzernaem commented 4 months ago

I am not sure if we may say "original soundtrack" with regards to MIDI music. There are several aspects to that. First of all, there is a synth that was used by Bobby Prince himself to compose Doom music - SC-55mkII. Is it intended synth for Doom music though? The thing was very expensive in 1993 and no game developer expected all players to actually own one. You were lucky if you owned a General MIDI synth at all because they weren't even made for gaming, they were made for music producers (SC-55 was an amateur level device but still). Some people owned cheaper Yamaha synths or even some more obscure devices. Neither of these sounded like SC-55. Then, there were much more popular PC gaming specific soundcards with on-board synths, like Ultrasound or AWE32. These were the regular "gaming" products that gamers were expected to use. They sound even less like SC-55. In worst case you were stuck with OPL music. Even if you have a genuine SC-55 synth, there is a slight sound variation between the revisions like the og SC-55, mkII and ISA board variant SCC1. So there is no "original soundtrack" really. Speaking of SF2 soundfonts, there is one literally made from decoded SC-55 ROM samples, as opposed to recorded ones, which is the closest to the real thing but even that one has differences from the actual SC-55 because SF2 softsynyhs don't emulate real filters and effects correctly. A specific SC-55 emulator, like MUNT project is needed here.

Tasosgemah commented 4 months ago

The video you mentioned is a remix of a Doom track by another guy. It's his own music creation, but he's playing it with the soundfont i linked.

I usually try the soundfonts myself before i judge them and they always sound like a custom soundtrack and this time i thought that poster did a preview of it themselves. My bad, the font sounds good indeed.

I am not sure if we may say "original soundtrack" with regards to MIDI music.

Some publishers have released OST CDs so i'm using those as the source. Which is pretty much the same instrumentation i get when using the "frontend MIDI" option in DosBOX Pure (when it works as it supposed to), or when using the default settings in various DOOM source ports like GZDoom, Woof, DSDA, etc. These all sound the same and are consistent with the official OSTs (only difference being the reverb in some cases) so i can assume it's what the composers intended as the best way to listen to these midis.

uzernaem commented 4 months ago

Hey guys. I have found a possible lead. Apparently vanilla Doom sends SysEx reset command to the MIDI device at startup: https://forum.zdoom.org/viewtopic.php?t=58013 In short, SysEx reset is what resets every instrument and setting to default values on the synth device. After that, the game is supposed to set correct instruments. What if, DOSBox-Pure adds some kind of lag to SysEx reset command and it arrives to the MIDI device after the instruments are set? I have no idea how MIDI commands pipeline works but in this case it looks like they are executed in a wrong order. This explains the behaviour on my screenshots above: the game sets correct instruments for a split second and right after that they are reset to default ones (piano).

biffrapper commented 2 months ago

This exact same issue is present in the Sharp X68000 core for Retroarch, PX68k. Also, so folks know, this issue is NOT present in the dosbox-core core build.

Tasosgemah commented 2 months ago

Is it only a few certain games on X68000 that are affected? Or all games?

biffrapper commented 2 months ago

I have only tried a few, such as Dracula X and Gradius and both were affected. My SC-55 would simply pump out piano noises instead of the proper instruments. When I ran the same games through XM6, a non libretro/retroarch emulator, I have no such problems and everything sounds perfect.

Tasosgemah commented 2 months ago

That sounds like a RetroArch problem though, a bit weird if two different cores are having the same exact sound issue.