Yamaha OPL FM synthesis music
The 90s were the golden age of personal computer music… and if you owned a PC compatible computer, the Sound Blaster card was a must as it was capable of producing both FM synthesis and digital music.
The YM3812 (also known as the “OPL2”) chip was responsible for the FM synthesis music in the Sound Blaster... let’s recreate a YM3812/OPL2 in an FPGA.
OPL2 demo
You will need
- an FPGA board.
- an amplified PC speaker set.
- a PC to stream the music.
We are going to program the FPGA with an RS232 receiver, an OPL2 core named JTOPL and a PWM generator.
Here we use a Pluto-IIx XC3S200A board but any medium size FPGA board should work.
Compile and load the "OPL2_demo" module in your FPGA, then run a VGM file through the VGM2COM player. The FPGA files are available here and the VGM2COM player here.
How does this work? VGM files contain the exact list of commands to send to a sound chip to play a specific tune.
Let's look at a YM3812 VGM file with a hex editor.
Starting at address 0x60, we can see all the YM3812 commands.
0x5A means "write to YM3812" and is followed by the YM3812 address and data bytes... so here we have "write 0x20 to the YM3812 address 0x01", then "write 0x00 at address 0x08", etc... lots of writes. The VGM2COM player reads all the YM3812 address and data bytes from a VGM file and sends them over the RS232 port. There are also delay commands, so VGM2COM simply stalls for whatever delay is specified by the delay command before resuming sending data.
You can find a lot of VGM files on the OPL archive site.
The music files are playable right on the site and are also available for download.
You might get a VGZ file but it is simply a compressed VGM: open the VGZ file in WinRar (or your favorite compression software) to un-compress it to a VGM.
Note that not all the files on OPL archive are targeted at the YM3812... but about half of the files are (they are marked "OPL2"). Another site with a lot of VGM files is VGMRIPS and if you want only the files targeting the YM3812, go here.
More OPL fun
- The Yamaha OPL Wikipedia page.
- Die pictures of OPL chips.
- List of FM Synthesis chips.
- Fake chips? Check this video.
- The VGM specification.
- Many VGM utilities on the VGMtools github page.
- A fun dive into Yamaha’s YM3812 programming with Tyler as your guide.
- A programming guide to the AdLib/Sound Blaster FM Music Chips... or for the OPL3.
- The OPL3BankEditor software to create new OPL instruments. It is compatible with our FPGA OPL2 demo too... use "serial port" in the chip emulator settings and "Arduino OPL2" as protocol.
- The Yamaha YM3812 application manual.
- Build an OPL2 Audio Board or an ISA-OPL2 board with a real YM3812.
- Finally some YouTube music mixes here and here.