Overview
It’s been a while since I’ve posted anything about electronics projects. I have not been idle, however. My current project is finally starting to come together enough to be able to show it off a little. It’s a MIDI synthesizer powered by the Yamaha YMF-262 (a.k.a. OPL3) FM synth chip, the successor to the YM3812 (a.k.a OPL2) I’ve talked about previously, and the Microchip (née Atmel) ATmega1284, a bigger brother of the ATmega328P used in the Arduino Uno. I’m calling the project “ApOPL3xy”, because I think apoplexy is a cool word, and it lets me put the OPL3 string in the middle. 🙂
Demo
I just got the patch editor working yesterday, so I’m excited to be able to show it off. It’s a bit rough around the edges, but it’s the first time the ApOPL3xy has felt like a real(ish) synth. Note that I don’t have 4-operator patches working yet, and there are a lot of menu items that you’ll see that don’t actually do anything. But 2-operator patches work.
I downloaded a 2-op patch set for the OPL3 authored by The Fat Man and used by the ADLMIDI project. I also used OPL3BankEditor to extract the parameters I needed to enter into the ApOPL3xy. The following videos show me entering in a few of these patches and demoing them with a MIDI controller keyboard.
Here’s an example of pitch bend working. This was a lot more difficult than I expected, and the details deserve their own post, but it seems to work pretty well now.
I also implemented a VGM player. VGM (Video Game Music) is a file format that stores commands to send to various synth chips. People have captured songs from lots of retro video games and uploaded them to vgmrips.net. I downloaded several, uncompressed them, and put them on the SD card for the ApOPL3xy to read. Here are a few examples:
Features and Limitations
There’s a lot of work left to be done, but the core is working. Current features include:
- MIDI Input
- Currently limited to MIDI channel 1
- Currently, the only messages supported are Note On, Note Off, and Pitch Bend
- Velocity is not yet supported
- 2-channel audio output
- The final product will have 4 output channels, but the breadboard version only has 2
- 18-voice polyphony when using 2-operator mode
- 10-segment LED VU meters per output channel
- Gain control potentiometer knob per output channel
- Menu-driven user interface
- 20×4 LCD character display
- 2 rotary encoders and 10 push buttons
- Micro SD card reader
- VGM player
- Both OPL2 and OPL3 VGM files are supported
- VGM file must be uncompressed. VGZ files are not supported.
There are several things I plan on adding in the future:
- 4-operator patch support
- Patch bank – currently the system only knows about one patch at a time
- Persistent patch/bank storage on EEPROM
- Import/export of patches and banks to SD card
- User interface improvements
- Support more MIDI messages
- Support MIDI velocity
- MIDI through output
- MIDI omni mode
- MIDI file playback
- VGM / MIDI file playlist support
- Printed circuit board
- Split into two boards: the OPL3 board and the MIDI board. They’ll be connected with an IDC ribbon cable I think. This will allow the OPL3 board to be connected to other things in the future, like my homebrew 6502 computer, or a Commodore 64, etc.
- ISP and JTAG headers for programming/debugging and headers for SPI, I2C and unused GPIO pins. This project was intended from the start to be hackable and upgradable.
Development Environment
I started out using the Arduino IDE to write the code for the firmware. That’s fine for small projects, but this quickly outgrew it. I recently switched to PlatformIO, and that’s been much more pleasant. It’s an extension for Visual Studio Code, and it supports a large number of microcontrollers and libraries. I’m using the AVR-ISP mkII programmer to upload the compiled firmware to the microcontroller. To access the micro SD card, I’m using the excellent SdFat library.
Closing Thoughts
This project has been a much larger undertaking than I initially envisioned. I’m excited that it’s starting to come together. I may post other articles about various technical details of the design and implementation another time, if there’s interest. When I get the PCB’s made, I plan to make the CAD files for the boards and the source code for the firmware available so people will be able to build one and mess with it if they want to.
Leave a Reply