VOGONS


First post, by Wohlstand

User metadata
Rank Newbie
Rank
Newbie

Hello!

It's my reorganizing of ADLMIDI's code into the library to use it with my game engine (which I developing).
Library is designed like other music decoding libraries: you are opening a MIDI-file with this library, setting some settings by library functions and then fetching 16-bit PCM audio data which you can send to audio output interface or just store into WAV or into encoder of OGG, FLAC or MP3 (but MP3 I disliking myself, because audio is damaging hard and I hear that)

Source code of this library:
https://github.com/Wohlstand/libADLMIDI

SDL Mixer X - my fork of SDL Mixer v 2.0 library which I extended with additional decoders include ADLMIDI and GME, and where I fixed some internal bugs of the re-sampling, and as small addon I added support of loop-points for OGG files based on vorbis comments LOOPSTART and LOOPEND (also supported LOOPLENGTH to be compatible with RPG-Maker's OGGs where that also supported):
https://github.com/WohlSoft/SDL-Mixer-X
(Note: Building of this library is designed to building under CMake)

PGE MusPlay - GUI-application that uses this library:
http://wohlsoft.ru/docs/_laboratory/_Builds/w … y-dev-win32.zip
Just drop any MIDI-file into this application and choice any available bank (but toggling of deep tremolo/vibrato/adlib drums mode/scalable modulation flags requires you to press "Stop" then "Play" to take changes. I think to fix that to allow hot-toggling of those flags while playing without forcing you to restart music playing). This application made for my same game engine project as too to preview musics "like in game" to check are loops are added into music files correctly

Last edited by Wohlstand on 2019-09-10, 15:03. Edited 2 times in total.

Reply 1 of 10, by DracoNihil

User metadata
Rank Oldbie
Rank
Oldbie

Somebody should contact the DXX-Rebirth team and see if they can incorporate your library into the source port so it can play the HMI's that have specific FM instruments.

“I am the dragon without a name…”
― Κυνικός Δράκων

Reply 2 of 10, by Wohlstand

User metadata
Rank Newbie
Rank
Newbie

Bump. Some news:
Now this library uses Nuked OPL emulator which is more accurate (but kept an ability to use DosBox's emulator, because most of the devices like phones are not able to run Nuked OPL emulator without lag). (just define macro "ADLMIDI_USE_DOSBOX_OPL" to build with the DosBox emulator usage. Later is planned ability to build with dual support of both emulators with ability switch one of them in runtime).

Reply 3 of 10, by realnc

User metadata
Rank Oldbie
Rank
Oldbie

Thanks for this library! I'm adding it as a MIDI renderer option in some of my applications.

I noticed that when it comes to CPU load, it doesn't matter whether I choose Nuked OPL or DBOPL. Both have the same CPU usage (around 30% on a single core, 4 OPL chips enabled in both cases.) Is this normal? I thought DBOPL was less CPU heavy than Nuked.

(Using current Git master branch.)

Reply 4 of 10, by Wohlstand

User metadata
Rank Newbie
Rank
Newbie
realnc wrote:

Thanks for this library! I'm adding it as a MIDI renderer option in some of my applications.

I glad you like it :3

realnc wrote:

I noticed that when it comes to CPU load, it doesn't matter whether I choose Nuked OPL or DBOPL. Both have the same CPU usage (around 30% on a single core, 4 OPL chips enabled in both cases.) Is this normal? I thought DBOPL was less CPU heavy than Nuked.

How you did switch the emulator? I guess you mistook and Nuked is still working. DBOPL is much softer emulator than Nuked, I even have the benchmark implemented in my OPL3 Bank Editor which tests the performance of each emulator and showing how fast it passed the same test. Note that you need to set up the library's settings after `adl_init()` with using the same instance.

Reply 5 of 10, by realnc

User metadata
Rank Oldbie
Rank
Oldbie
Wohlstand wrote:

How you did switch the emulator? I guess you mistook and Nuked is still working. DBOPL is much softer emulator than Nuked, I even have the benchmark implemented in my OPL3 Bank Editor which tests the performance of each emulator and showing how fast it passed the same test. Note that you need to set up the library's settings after `adl_init()` with using the same instance.

I'm setting the emulator right after creating a player instance. Simplified example with 16 chips:

auto* adl_player = adl_init(49716);
adl_switchEmulator(adl_player, ADLMIDI_EMU_DOSBOX);
adl_setBank(adl_player, 65);
adl_setNumChips(adl_player, 16);

std::cerr << "Emuname: " << adl_chipEmulatorName(adl_player)
<< "\nNumChips: " << adl_getNumChips(adl_player)
<< "\nChipsObtained: " << adl_getNumChipsObtained(adl_player);

Output:

Emuname: DOSBox 0.74-r4111 OPL3
NumChips: 16
ChipsObtained: 16

Running the above for each ADLMIDI_EMU_* choice will result in these CPU loads:

JAVA: 20%
OPAL: 41%
DOSBOX: 80%
NUKED: 80%

Last edited by realnc on 2019-03-13, 10:54. Edited 1 time in total.

Reply 6 of 10, by Wohlstand

User metadata
Rank Newbie
Rank
Newbie
realnc wrote:
Running the above for each ADLMIDI_EMU_* choice will result in these CPU loads: […]
Show full quote

Running the above for each ADLMIDI_EMU_* choice will result in these CPU loads:

JAVA: 20%
OPAL: 41%
DOSBOX: 80%
NUKED: 80%

I did the test of DosBox and Nuked, and I have found next: the bank 65 does use of rhythm-mode percussions. I have found that when DosBox emulator will use rhythm-mode percussions, it will be loaded almost same as Nuked. Even playing music has no percussions to use. Try to use another bank, for example, 68'th and tell me how much DosBox loads?

As you know, recently I have implemented complete support for rhythm-mode drums to be able to import and use old banks like IBKs made with SBTimbre where are supports rhythm-mode only percussions.

Reply 7 of 10, by realnc

User metadata
Rank Oldbie
Rank
Oldbie
Wohlstand wrote:

Try to use another bank, for example, 68'th and tell me how much DosBox loads?

You are correct. With 16 chips, the DOSBOX emulator goes from 80% CPU load to 15% when using bank 68.

As you know, recently I have implemented complete support for rhythm-mode drums to be able to import and use old banks like IBKs made with SBTimbre where are supports rhythm-mode only percussions.

I'm not familiar with any of that 🤣

What I was trying to do was choose a bank that sounds good when playing GM or GS MIDI files. Bank 65 sounded really good. Is there a bank you'd recommend for MIDIs?

Reply 8 of 10, by Wohlstand

User metadata
Rank Newbie
Rank
Newbie
realnc wrote:

What I was trying to do was choose a bank that sounds good when playing GM or GS MIDI files. Bank 65 sounded really good. Is there a bank you'd recommend for MIDIs?

That bank I made long time ago in childhood: I have experimented with SBTimbre by modding of Fatman bank and using Jammie O'Connel's driver for Win3x/9x, and later I have imported it into libADLMIDI, but drums are was wrong (I have used different) until I have implemented rhythm-mode support. The 68'th bank is my better bank which I based on 4op instruments and some instruments by Sneakernets. Also, I recommending you to checkout Sneakernets' bank you can find here: https://github.com/sneakernets/DMXOPL, it's an attempt to make sounding similar to Roland SC and folks 😀 (in libADLMIDI it's also exists, but GM only form, the WOPL file supports complete GS and XG sets which is impossible with embedded banks yet, but I have to improve this in nearest future...)

realnc wrote:

I'm not familiar with any of that 🤣

Rhythm-mode is the special mode of OPLx chips which turns off 3 melodic voices and turns on 5 percussion channels: bass drum that does use of two operators, snare, tom-tom, cymbal, and hihat, are using one operator only. Here you can read more detailed: http://www.shikadi.net/moddingwiki/OPL_chip#Percussion_Mode ;3

Reply 9 of 10, by realnc

User metadata
Rank Oldbie
Rank
Oldbie

Thanks for your explanation. It seems GENMIDI(GS).wopl is a nice bank. But I don't know what the implications are when it comes to polyphony. For normal GM and GS MIDI files, would I need to use a large amount of emulated chips? Not sure how to tell how many I need. (The 16 I used in the example code above was just for testing.)

I know that GS specifies 16 channels and 24 voices. Different FM banks that use different parameters (2-op vs 4-op) will alter the amount of voices each emulated chip can output. So for GENMIDI(GS).wopl, how many chips would be needed in order to get 24 voices?

Reply 10 of 10, by Wohlstand

User metadata
Rank Newbie
Rank
Newbie
realnc wrote:

Thanks for your explanation. It seems GENMIDI(GS).wopl is a nice bank. But I don't know what the implications are when it comes to polyphony. For normal GM and GS MIDI files, would I need to use a large amount of emulated chips? Not sure how to tell how many I need. (The 16 I used in the example code above was just for testing.)

I know that GS specifies 16 channels and 24 voices. Different FM banks that use different parameters (2-op vs 4-op) will alter the amount of voices each emulated chip can output. So for GENMIDI(GS).wopl, how many chips would be needed in order to get 24 voices?

This bank uses a lot of pseudo-4op instruments. Means, one single instrument will use two 2-op voices. OPL3 chip gives 18 2op voices. When you have to use real 4-op voices, then, you'll have 6 4op voices per chip. Count of 4-op voices can be switched. One 4-op voice replaces two 2-op voices. So, you have 18 single-voice 2-op channels, 9 pseudo-4op channels, and 6 4-op channels for everything per chip. Here in libADLMIDI is an automatical arpeggio that is turning on when a count of free channels was been exited.