Player icon indicating copy to clipboard operation
Player copied to clipboard

Support for better FM MIDI synthesizers

Open Wohlstand opened this issue 6 years ago • 10 comments

I have found, you are using MIDI synths are requiring to use external bank files to work, otherwise, the music will be silent. It's a big con of SF2-based and WT synthesizers. I have a suggestion, why not to add some alternative MIDI synthesizer(s) for optional use are... using FM Synth emulation?

Myself I have two of them:

libADLMIDI (some info about)

It's the MIDI synthesizer library that does use of OPL3 synth emulation. This synthesizer can reproduce epoch of Windows 9x (bank-58 "The FatMan" is well-known GM bank used in Windows drivers for OPL2/3 chip) and various DOS games.

  • It's totally not needs for any external files to work, it's completely standalone and works already in a box
  • Optional support of custom banks in WOPL format which gives ability to support GS or XG wide banks (more than well-known GM 128:128 set).
  • Built-in 74 various banks taken from various DOS games or made by various people
  • Has 4 different emulators are can be toggled in runtime (Nuked OPL3 is most accurate, but heavy, DosBox is less-accurate, but it's fastest)
  • To extend voice channels polyphony limit, there are multiple chip emulators are running.

libOPNMIDI

It's my alternative MIDI synthesizer which does use of OPN2 or OPNA synth emulation. This synthesizer can provide the good sounding like Sega Megadrive or Janapese NEC PC98 computers.

  • Unlike libADLMIDI, it doesn't contains embedded banks, however, you can use the .h-compiled default bank to pass it into the library to get it working without using of external bank files. Custom bank files are in WOPN format. In my collection I have some banks are made by me and by other people.
  • Has different emulators are can be toggled in runtime (MAME YM2612, Nuked OPN2 is most accurate, but VERY heavy, GENS 2.10 which is fastest but inaccurate, Neko Project II Kai OPNA, MAME YM2608, and two experimental emulators: Genesis Plus GX OPN2 and PMDWin).
  • To extend 6-channels polyphony limit, there are multiple chip emulators are running.
  • For now, the FM-only part is supported yet. I working on a support for PSG, OPNA-Rhythm, and the DAC.

Both libraries

  • Has Real-Time MIDI API that allows you to use any own MIDI sequencer to stream MIDI events to play them by library
  • Has built-in MIDI sequencer that can play MIDI, RMI, MUS, XMI, IMF in Wolfenstein 700 hz rate (ADLMIDI only), CMF (ADLMIDI only), and GMF. Supports multiple loop tag formats: FFVII (loopStart/loopEnd tags), RPG Maker (CC111 as "loop start"), and FFVII extended (has support for nested loops and ability to limit count of loops until pass the next part)
  • Their API is similar with exception of settings are specific to OPL or OPN chips
  • Libraries are flexible and configurable, having many options to work
  • Some easier way to get usage of them, they are a part of my SDL Mixer fork called as SDL Mixer X
  • Those libraries are used in GZDoom

Here you can check out my demos of sounding: https://www.youtube.com/playlist?list=PLrUcHGBNRjJMJ_s71k2DtSscsQtqgmWut

Wohlstand avatar Mar 23 '19 14:03 Wohlstand

Hello,

we already bundle one FM Midi Synthesizer, it is simply called "Fmmidi" and is based on this: http://unhaut.x10host.com/fmmidi/

It is used as a fallback when no bank files are provided.

Thanks for listing alternative synthesizers, we will consider to integrate them as external dependencies someday.

Ghabry avatar Mar 23 '19 14:03 Ghabry

I see, also I have just now tried it, and yeah, I wanna to convert it's program.h into WOPN to try use it with libOPNMIDI, thanks! :fox_face: :+1:

Anyway yeah, the OPNA emulator that is used here is not so accurate (I may guess, it's some sort of PMDWin, I have found very familiar decay envelope trouble hearing), but will compare the result... libOPNMIDI is more complex library which is intended for good sounding and better MIDI support include GS and XG.

You can use pkgconfig to detect libADLMIDI or libOPNMIDI which are provided for use :wink:

Wohlstand avatar Mar 23 '19 15:03 Wohlstand

Just now I have reminded that I have left this suggestion. Gonna make in the evening something myself...

Wohlstand avatar Oct 11 '19 13:10 Wohlstand

This doesn't really have any priority for me but when the linked libraries support external sequencers they can be now easily added.

Maybe we should readd the "Good first issue" label to indicate stuff that is nice to have. 🤔

Ghabry avatar Jun 15 '20 00:06 Ghabry

These libraries are support external sequencers by the Real-Time API. You need to simply pass your sequencer's events into rt_* calls for each type of event and use adl/opn_generateFormat() to retrieve output. Every library has an example of use in a form of VLC plugin where are RT calls used. The real-time api is very similar to that FluidSynth has. My libraries also having the SysEx support that tweaks GS and XG features like extra drum channels and bank change formats.

Wohlstand avatar Jun 15 '20 03:06 Wohlstand

(Every library has the 'utils/vlc_plugin' folder with a C file. Also, keep in a mind that if output sound will look too silent, multiple every sample in a buffer with a gain factor to get sounding be louder)

Wohlstand avatar Jun 15 '20 03:06 Wohlstand

Just now I remembered this request, I could make a shot to implement a thing and send PR with that. (However, I got weird result when I opened EasyRPG's project in Qt Creator, it spammed me with profiles, and nobody builds properly, but I need that to just work).

Wohlstand avatar Jun 30 '25 20:06 Wohlstand

lol, I also though an hour ago when I checked your profile: ADLMIDI and OPNMIDI sound familiar.


The preset that uses the system libraries is the one without any prefix: debug, relwithdebinfo etc. (linux-debug is for building against the libraries from our buildscripts repo at https://github.com/EasyRPG/buildscripts).

When you dislike the presets you can delete the CMakePresets.json file.


All the MIDI stuff is now more advanced, take a look at decoder_fluidsynth.cpp or decoder_fmmidi.cpp for an example. To register a new MIDI handler look in audio_midi.cpp.

Ghabry avatar Jun 30 '25 20:06 Ghabry

I don't have objections to presets, but seems they are broken with Qt Creator (because Qt Creator attempts to import these presets, and result gets just faulty, I guess it's experimental feature unfortunately). So, I'll try to rename it locally to fix the build.

Wohlstand avatar Jun 30 '25 20:06 Wohlstand

By the way. I probably already said, I imported bank of fmmidi thing that uses glitchy code and very inaccurate OPNA emulator, and I used it with libOPNMIDI where I use the robust MIDI synthesizer and variety of chip emulators starting with very accurate and ending with low-quality but easy for CPU one. Anyway, according to my tests on o3DS, any synthesized MIDI plays just choppy because of too weak CPU... On Vita it at least can play but conditionally, and also causes some lags.

Wohlstand avatar Jun 30 '25 20:06 Wohlstand