havOPL v0.1.0 Released

November 08, 2026 · · 2 min read

Today I'm releasing the first version of havOPL, a C++20 library that emulates the Yamaha OPL2 and OPL3 FM synthesis chips found on the AdLib and Sound Blaster cards of the DOS era.

The library is register-driven. You write the same register values a DOS game or music driver would have sent to the real chip, and havOPL renders the resulting audio as interleaved 16-bit stereo samples. This makes it suitable for playing back register-log music formats such as IMF or DRO, for running original OPL drivers in an emulated environment, or simply as an FM synthesizer in its own right. The library produces samples only, so you can pass them to any audio API or write them to a WAV file.

havOPL was written from Yamaha's own hardware documentation and doesn't use code or ROM tables from other emulators. It models the chip's documented musical behavior, such as envelopes, waveforms, modulation and output routing, rather than its individual clock cycles. The modulation depth was calibrated against DOSBox recordings, and the envelope timing against Yamaha's published tables.

Features
  • OPL2 (YM3812) and OPL3 (YMF262) synthesis with 9 or 18 channels, four-operator pairs and rhythm mode
  • All envelope, pitch, level, feedback, tremolo/vibrato and waveform controls, plus OPL3 output routing
  • Any output rate from 8,000 to 192,000 Hz with exact timing across arbitrary buffer sizes
  • The two timers and the status register for drivers that detect the chip by polling them
  • A small API: write registers, render samples and read the status register
  • CMake presets for Visual Studio 2022, MinGW and Linux, with tests included

havOPL is released under the MIT license. Its source code and documentation are available on GitHub.