libOPNMIDI - a MIDI-player with OPN2 (YM2612) Emulation (C/C++ library)

Emulation of old consoles and arcades.

libOPNMIDI - a MIDI-player with OPN2 (YM2612) Emulation (C/C++ library)

Postby Wohlstand » 2017-5-22 @ 17:21


I'v got inspired by ADLMIDI program, which a MIDI player over chip emulator, and after creating the libADLMIDI I kept in my mind the idea to create similar library, but over YM2612 chip (a same chip that used in Sega MegaDrive/Genesis game console). Because the sense of any MIDI player to interpreting MIDI commands into native chip registers commands, I found that is very easy to make MIDI players over any other sound generation chip(s). After some works, I have created the bank editor (have reworked OPL3 bank editor with replacing YMF262 emulator and have adapted GUI to YM2612's specifics, and have created own WOPN bank format) and then created the full General Midi bank by collecting instruments from various VGM files, porting from OPL3 banks, and making/remixing any other instruments. ADLMIDI had multiple chips emulation to extend 18-channels (or 6 4-op channels) limitation which is used in libOPNMIDI to extend 6-channels limit and be able play better polyphony than chip allows. DAC for now is not used, but planned in nearest feature to allow passing the PCM samples as anternate percussion mode.

If you want preview library in action, you can try PGE MusPlay simple music player (which is linked below)

Source code of this library:
Hint: Unlike ADLMIDI, library doesn't has hardcoded banks and uses an external bank files. As alternative, you can hardcode your WOPN file and pass it via memory pointer.

A bank editor which us using for creation and editing of WOPN banks (with ability to import instruments from VGM files): (prebuild for Win32 you can download here)

Where this library is used:

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

PGE MusPlay - GUI-application that uses this library, a simple music player, where you can preview library sound in action: ...
Just drop any MIDI-file into this application and choice the "OPN Midi" device. This application made for my game engine project as too to preview musics "like in game" to check are loops are added into music files correctly.
Note: custom bank choosing is not working yet. Library itself supports that, but wasn't implemented on music player side.
EDIT: Now PGE MusPlay supports usage of custom bank files. Custom bank file will be reloaded on re-open or stop/play of a song. If field is empty or refers non-existing file, default bank will be used
Last edited by Wohlstand on 2017-7-17 @ 04:05, edited 3 times in total.
User avatar
Posts: 26
Joined: 2016-6-12 @ 20:25
Location: Moscow, Russia

Re: libOPNMIDI - a MIDI-player with OPN2 (YM2612) Emulation (C/C++ library)

Postby pred » 2017-5-22 @ 20:14

Another Yamaha emu and more, kewl and Thanks!!
User avatar
Posts: 25
Joined: 2006-3-07 @ 01:58

Return to Console & Arcade Emulation

Who is online

Users browsing this forum: No registered users and 1 guest