ADLMIDI support

Moderator: GZDoom Developers

User avatar
Csonicgo
Posts: 1193
Joined: Thu Apr 15, 2004 3:28 pm
Location: Leeds

ADLMIDI support

Post by Csonicgo »

https://github.com/Wohlstand/libADLMIDI

This is a pie in the sky idea, but folks, DMX is becoming a pain in the tuchus to support. I've ran into bugs with it in the original DMX implementation, the DMX OPL code is unforgiving to MIDI files that dare to go outside of the MUS parameters, and it doesn't support a lot of features like modulation and loop points. ADLMIDI supports pretty much every MIDI command ever made + custom ones like Duke3D and Square loop point support. It also sounds much better as it handles note cuts much more competently than simple "voice channel priority".

There is even support for multiple drumkits and GS/XG instruments, which I will be working on in my project next year for version 3 of DMXOPL. I've asked for this in GZDoom previously using a config file, but that shouldn't even be GZDoom's job.

Custom banks are loadable, in a format called WOPL. All FM banks can be converted to WOPL with a tool, which means that Doom/Doom2 GENMIDI will work, as well as any custom patches - as long as they're in WOPL format.

The limitations right now:
  • Only one OPL3 core can be selected at compile time: DOSBOX or Nuked. the former is much faster but can be distorted at times, and Nuked is more accurate but slower. Much slower.
  • Since OPL3 output is pure on this library, there is no highpass filter to fix the terrible offsets, resulting in clipping and other issues. Only a problem on a few MIDI files.
  • It's constantly under development, although this really isn't a limitation, it's more of an inconvenience on having to update the code.
  • The options can be a bit confusing if you don't know what you're doing.
Eternity Engine plans to add support for this soon. Perhaps ZDoom can join in!
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49066
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: ADLMIDI support

Post by Graf Zahl »

This looks like it very poorly integrates with ZDoom's MIDI code because it cannot use the main event dispatcher but instead wants to do everything on its own.
Find me someone who can make this work within the existing MIDI framework and we should be good to go. But don't expect me to invest much time here, my interest in OPL playback is precisely zero, what I did for the existing player was merely to ensure that some basic capabilities still exist - if I had to decide I'd ditch most of the existing MIDI players anyway, except FluidSynth and Timidity++.
User avatar
Csonicgo
Posts: 1193
Joined: Thu Apr 15, 2004 3:28 pm
Location: Leeds

Re: ADLMIDI support

Post by Csonicgo »

Wohlstand may be able to get that resolved, or so I hope. I'll run it by him.
User avatar
Wohlstand
Posts: 73
Joined: Sun Dec 17, 2017 3:22 am
Graphics Processor: nVidia with Vulkan support
Location: Moscow, Russia
Contact:

Re: ADLMIDI support

Post by Wohlstand »

Hello!
Yesterday I have been implemented RT API like on FluidSynth which allows you to manually pass events and generate the sound output (Stereo PCM S16 (system endianness)). As an example, I have made a VLC plugin where you will see that API in action. So, no more need to give the entire MIDI file to library.

How to use the library:
- use adl_init to create an instance
- setup any properties as you want (embedded bank, custom bank, volume model, deep tremolo/vibrato, count of emulated chips and custom count of 4-op channels between all chips, etc.) you may change them in runtime, but highly recommended to use adl_panic() and adl_reset() when you changing some properties. Tremolo/vibrato/volume model doesn't require you to use those functions.
- use adl_rt_* functions to pass MIDI events to library
- use adl_generate in delays between of event rows to generate output sound.
- use adl_close() to destroy instance.

I hope this stuff will be useful for you. ;-)
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49066
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: ADLMIDI support

Post by Graf Zahl »

Sorry for waiting so long, but I had been busy with other stuff. That definitely sounds interesting and since the OPL player in GZDoom has its problems and nobody seems to be able to fix it, being able to replace it with something better supported is definitely appreciated.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49066
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: ADLMIDI support

Post by Graf Zahl »

I just did a first rough implementation. Something must be wrong with it, it sounds awful, but I cannot see my error. If someone has an idea, please drop me a line.
User avatar
Csonicgo
Posts: 1193
Joined: Thu Apr 15, 2004 3:28 pm
Location: Leeds

Re: ADLMIDI support

Post by Csonicgo »

Graf Zahl wrote:I just did a first rough implementation. Something must be wrong with it, it sounds awful, but I cannot see my error. If someone has an idea, please drop me a line.
I'll let Wohlstand know ASAP - IIRC Zeem ran into a similar problem in Eternity.

EDIT: https://github.com/Wohlstand/libADLMIDI ... -352199752 He went into detail about it here.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49066
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: ADLMIDI support

Post by Graf Zahl »

That was the info I went by.

But there's one interesting thing. He notes that
One con: the drum length fixer will NOT work since it's a MIDI player feature which must be re-implemented on side of GZDoom's MIDI sequencer, not on libADLMIDI side.
I'd really like to know what this is about, because I got two songs that definitely have some problems with the drums, and that's across all synths.
Best to leave this note here in case he responds.
User avatar
Csonicgo
Posts: 1193
Joined: Thu Apr 15, 2004 3:28 pm
Location: Leeds

Re: ADLMIDI support

Post by Csonicgo »

Graf Zahl wrote:That was the info I went by.

But there's one interesting thing. He notes that
One con: the drum length fixer will NOT work since it's a MIDI player feature which must be re-implemented on side of GZDoom's MIDI sequencer, not on libADLMIDI side.
I'd really like to know what this is about, because I got two songs that definitely have some problems with the drums, and that's across all synths.
Best to leave this note here in case he responds.
FM ADSR and midi events with percussion do not mix well. I found this out the hard way when snare drums , cymbals, and other things with anything less than 15 Attack (the fastest possible) and a bad Release value could sometimes fail to play, because the drum "notes" in the midi simply isn't long enough. The solution? force the note events to be longer so it plays correctly. that's literally all it is.

Sample-based synths don't really have a concept of ADSR in this sense, and there would be no problems here.

I know Bobby Prince was aware of this, as was Lee Jackson. however, ROTT's Apogee Intro was before Lee Jackson knew of this issue, so the snares are totally broken in most FM sound banks.
User avatar
Wohlstand
Posts: 73
Joined: Sun Dec 17, 2017 3:22 am
Graphics Processor: nVidia with Vulkan support
Location: Moscow, Russia
Contact:

Re: ADLMIDI support

Post by Wohlstand »

Hello!
Just now I reviewed your code and you did a mistake:
when you called adl_generate() you have requested half of the data than needed: the length is a count of samples, not a count of frames! That means, one frame of the stereo stream has two samples. I even wrote a simple example how you must to deal with `adl_generate()` call :wink:
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49066
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: ADLMIDI support

Post by Graf Zahl »

I just updated the branch. Before merging it to master I'd like to hear a few more opinions about the new device.
The main reason is that Csonicgo made it sound like this could replace the OPL emulation, but this sounds so different that it may only be acceptable as an additional device.

Note that I had to boost the volume by a factor of 5 to get it up to the same level as the other synths. Is it supposed to be this quiet?
_mental_
 
 
Posts: 3812
Joined: Sun Aug 07, 2011 4:32 am

Re: ADLMIDI support

Post by _mental_ »

Some changes are already pushed to master. adlMIDI branch builds on Windows only because of duplicate symbols. There are nukedopl3.c and nukedopl3.cpp files.
User avatar
Csonicgo
Posts: 1193
Joined: Thu Apr 15, 2004 3:28 pm
Location: Leeds

Re: ADLMIDI support

Post by Csonicgo »

Graf Zahl wrote:I just updated the branch. Before merging it to master I'd like to hear a few more opinions about the new device.
The main reason is that Csonicgo made it sound like this could replace the OPL emulation, but this sounds so different that it may only be acceptable as an additional device.

Note that I had to boost the volume by a factor of 5 to get it up to the same level as the other synths. Is it supposed to be this quiet?

Not to answer for Wohlstand, but I think it was to prevent splatter when multiple chips are emulated. It gives a bit of headroom when Abs-sines kick in. The abs-sine issues can be fixed in post with a real-time filter that blocks 0-5Hz. IIRC, Randi discovered this independently and added it to the existing code. I could be wrong though, but I distinctly remember seeing comments about abs-sines causing offsets in the audio, contributing to premature distortion due to the offset being so godawful.
Gez
 
 
Posts: 17835
Joined: Fri Jul 06, 2007 3:22 pm

Re: ADLMIDI support

Post by Gez »

Graf Zahl wrote:this sounds so different that it may only be acceptable as an additional device.
Probably the best option in any case. Music preferences are an extremely subjective topic.


For the drum length fixer, the AdlMIDI code is there.
Last edited by Gez on Wed Mar 07, 2018 2:57 pm, edited 1 time in total.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49066
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: ADLMIDI support

Post by Graf Zahl »

_mental_ wrote:Some changes are already pushed to master. adlMIDI branch builds on Windows only because of duplicate symbols. There are nukedopl3.c and nukedopl3.cpp files.
What parts are in master? If that happened it was by accident. Regarding the duplicate symbols, one of the OPL cores needs to be put into a separate namespace. Their contents are too different so I didn't feel comfortable to let both use the same one.
Post Reply

Return to “Closed Feature Suggestions [GZDoom]”