libADLMIDI - C++ library made from ADLMIDI (MIDI-player with OPL3 Emulation)

Emulation of old PCs, PC hardware, or PC peripherals.

libADLMIDI - C++ library made from ADLMIDI (MIDI-player with OPL3 Emulation)

Postby Wohlstand » 2016-6-12 @ 21:01

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/Wohlhabend-Networks/ ... r_modified
(Note: Building of this library is designed to building under QMake from Qt 5)

PGE MusPlay - GUI-application that uses this library:
http://wohlsoft.ru/docs/_laboratory/_Bu ... -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 2017-5-22 @ 16:57, edited 1 time in total.
User avatar
Wohlstand
Newbie
 
Posts: 36
Joined: 2016-6-12 @ 20:25
Location: Moscow, Russia

Re: libADLMIDI - C++ library made from ADLMIDI (MIDI-player with OPL3 Emulation)

Postby DracoNihil » 2016-6-13 @ 10:19

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.
User avatar
DracoNihil
Oldbie
 
Posts: 1234
Joined: 2011-10-09 @ 14:26
Location: Independence, KS

Re: libADLMIDI - C++ library made from ADLMIDI (MIDI-player with OPL3 Emulation)

Postby Wohlstand » 2016-12-08 @ 21:39

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).
User avatar
Wohlstand
Newbie
 
Posts: 36
Joined: 2016-6-12 @ 20:25
Location: Moscow, Russia

Re: libADLMIDI - C++ library made from ADLMIDI (MIDI-player with OPL3 Emulation)

Postby realnc » 2019-3-11 @ 21:47

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.)
User avatar
realnc
Member
 
Posts: 339
Joined: 2010-10-13 @ 11:02

Re: libADLMIDI - C++ library made from ADLMIDI (MIDI-player with OPL3 Emulation)

Postby Wohlstand » 2019-3-11 @ 22:25

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.
User avatar
Wohlstand
Newbie
 
Posts: 36
Joined: 2016-6-12 @ 20:25
Location: Moscow, Russia

Re: libADLMIDI - C++ library made from ADLMIDI (MIDI-player with OPL3 Emulation)

Postby realnc » 2019-3-12 @ 00:44

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:

Code: Select all
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:

Code: Select all
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-3-13 @ 10:54, edited 1 time in total.
User avatar
realnc
Member
 
Posts: 339
Joined: 2010-10-13 @ 11:02

Re: libADLMIDI - C++ library made from ADLMIDI (MIDI-player with OPL3 Emulation)

Postby Wohlstand » 2019-3-12 @ 17:54

realnc wrote: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.
User avatar
Wohlstand
Newbie
 
Posts: 36
Joined: 2016-6-12 @ 20:25
Location: Moscow, Russia

Re: libADLMIDI - C++ library made from ADLMIDI (MIDI-player with OPL3 Emulation)

Postby realnc » 2019-3-13 @ 08:52

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 :lol:

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?
User avatar
realnc
Member
 
Posts: 339
Joined: 2010-10-13 @ 11:02

Re: libADLMIDI - C++ library made from ADLMIDI (MIDI-player with OPL3 Emulation)

Postby Wohlstand » 2019-3-13 @ 09:07

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 :happy: (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 :lol:

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_ ... ssion_Mode ;3
User avatar
Wohlstand
Newbie
 
Posts: 36
Joined: 2016-6-12 @ 20:25
Location: Moscow, Russia

Re: libADLMIDI - C++ library made from ADLMIDI (MIDI-player with OPL3 Emulation)

Postby realnc » 2019-3-15 @ 11:17

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?
User avatar
realnc
Member
 
Posts: 339
Joined: 2010-10-13 @ 11:02

Re: libADLMIDI - C++ library made from ADLMIDI (MIDI-player with OPL3 Emulation)

Postby Wohlstand » 2019-3-15 @ 12:29

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.
User avatar
Wohlstand
Newbie
 
Posts: 36
Joined: 2016-6-12 @ 20:25
Location: Moscow, Russia


Return to PC Emulation

Who is online

Users browsing this forum: No registered users and 2 guests