Authentic Sega Genesis / Mega Drive sound on real hardware.
The Genesis Engine is a sound board and library that brings the iconic sound of the Sega Genesis to your projects. Featuring the YM2612 FM synthesizer and SN76489 PSG chips on a board easily controlled by Teensy/Arduino/ESP32
Play VGM music files, stream audio directly from an emulator, or use it as a standalone synthesizer.
Schematics, KiCad, & Gerbers are in the hardware folder, but if you just want to grab one: https://www.tindie.com/products/40905/
- Stereo output — Full left/right channel separation
- Accurate clocks — Crystal oscillators tuned for correct pitch
- FM and PSG in tune — Both chips share a proper clock relationship
- Upgraded Op-amp — Designed for low noise
- Real Chips — YM2612 FM synthesis and SN76489 PSG, not emulation
- VGM Playback — Play music from Genesis, Mega Drive, Game Gear, and Master System
- Multiple Playback Modes
- Flash memory (PROGMEM) for standalone operation
- SD card for large music libraries
- Serial streaming from PC
- Real-time streaming from emulators (BlastEm)
- Synthesis Utilities — Direct chip control for custom sounds, MIDI synths, and sound effects
- Cross-Platform — Teensy 4.x, ESP32, Arduino Mega/Uno, and more
- VGZ Support — Native decompression on Teensy/ESP32
- PCM/DAC Support — Sampled drums and vocals on YM2612 channel 6
- Smart Memory Management — Automatically adapts to your board's capabilities
| System | FM Chip | PSG Chip | Support |
|---|---|---|---|
| Sega Genesis / Mega Drive | YM2612 | SN76489 | Full |
| Sega Master System | — | SN76489 | PSG only |
| Sega Game Gear | — | SN76489 | PSG only |
| ColecoVision | — | SN76489 | PSG only |
| IBM PCjr | — | SN76489 | PSG only |
| Tandy 1000 PCs | — | SN76489 | PSG only |
Connect the Genesis Engine board to your microcontroller.
| Board Pin | Function | Arduino/Teensy | ESP32 | Configurable? |
|---|---|---|---|---|
| WR_P | PSG write strobe (active low) | 2 | 16 | Yes |
| WR_Y | YM2612 write strobe (active low) | 3 | 17 | Yes |
| IC_Y | YM2612 reset (active low) | 4 | 25 | Yes |
| A0_Y | YM2612 address/data select | 5 | 26 | Yes |
| A1_Y | YM2612 port select | 6 | 27 | Yes |
| SCK | Shift register clock | SPI | SPI | See below |
| SDI | Shift register data (MOSI) | SPI | SPI | See below |
| VCC | 5V power | — | — | — |
| GND | Ground | — | — | — |
ESP32 Note: GPIO 0-3 (boot/serial), 6-11 (flash), and 12/15 (boot strapping) must be avoided. The defaults above are safe for ESP32-WROOM-32 dev boards.
SPI Pins — By default, the library uses hardware SPI for fast data transfer. These pins are fixed per board:
| Board | SCK | SDI (MOSI) |
|---|---|---|
| Teensy 4.x | 13 | 11 |
| ESP32 | 18 | 23 |
| Uno | 13 | 11 |
| Mega | 52 | 51 |
If you need different pins for SCK/SDI, set USE_HARDWARE_SPI to 0 in GenesisBoard.cpp to enable software SPI on any GPIO.
#include <GenesisEngine.h>
#include "music.h" // Your VGM converted to a header file
// Pin connections (directly configurable)
const uint8_t WR_P = 2, WR_Y = 3, IC_Y = 4, A0_Y = 5, A1_Y = 6;
// SCK/SDI ignored when using hardware SPI (default)
GenesisBoard board(WR_P, WR_Y, IC_Y, A0_Y, A1_Y, 0, 0);
GenesisEngine player(board);
void setup() {
board.begin();
player.play(music_data, music_length);
player.setLooping(true);
}
void loop() {
player.update(); // Call frequently for proper timing
}#include <GenesisEngine.h>
#include <SD.h>
const uint8_t WR_P = 2, WR_Y = 3, IC_Y = 4, A0_Y = 5, A1_Y = 6;
GenesisBoard board(WR_P, WR_Y, IC_Y, A0_Y, A1_Y, 0, 0);
GenesisEngine player(board);
void setup() {
SD.begin(BUILTIN_SDCARD); // Teensy 4.1 built-in SD
board.begin();
player.playFile("/music/greenhill.vgm");
}
void loop() {
player.update();
}Store music directly in your microcontroller's flash. Convert VGM files with the included tool:
python examples/BasicPlayback/vgm2header.py song.vgmPlay VGM and VGZ files directly from SD. The SDCardPlayer example includes an interactive serial menu for browsing and playback control. Works best on Teensy or ESP32. Mega has limited support (see Platform Notes). Not supported on Arduino Uno due to RAM limits.
Stream VGM files from your PC in real-time:
python examples/SerialStreaming/stream_vgm.py song.vgmStream audio directly from BlastEm or other Genesis emulators to hear games on real hardware as you play.
| Feature | Teensy 4.x | ESP32 | Mega | Uno |
|---|---|---|---|---|
| PROGMEM playback | Yes | Yes | Yes | Yes |
| Serial streaming | Yes | Yes | Yes | Yes |
| SD card | Built-in | Yes | Limited* | No |
| VGZ decompression | Native | Native | Via tools | Via tools |
| PCM buffer size | 8KB+ | 4KB | 512 bytes | 256 bytes |
Teensy 4.x is recommended, especially for SD card playback. It offers fast GPIO, large memory, and built-in SD on the 4.1.
Arduino Uno/Mega Limitation: Due to AVR's 16-bit PROGMEM addressing, flash playback is limited to ~16KB (Uno) or ~60KB (Mega). Use --strip-dac when converting to fit more music. Uno does not support SD card (insufficient RAM). See the BasicPlayback example README for details.
*Mega SD support requires software SPI for the shift register due to pin conflicts. Results may vary—some VGM files with heavy DAC usage may have timing issues.
ESP32 SD Note: When using SD cards on ESP32, the shift register must use different pins (GPIO 4/13) than other examples (GPIO 18/23) because the SD card needs the hardware SPI bus. See the SDCardPlayer README for full wiring details.
- BasicPlayback — VGM playback from flash memory
- SDCardPlayer — SD card player with serial menu
- SerialStreaming — Stream music from PC over USB
- EmulatorBridge — Real-time audio from Genesis emulators
- SimpleSynth — Direct chip control demo using synthesis utilities
- MIDISynth — Full MIDI synthesizer with voice allocation and patch management
Each example includes relevant Python tools:
| Tool | Location | Description |
|---|---|---|
vgm2header.py |
examples/BasicPlayback/ | Convert VGM/VGZ to C header files |
vgm_prep.py |
examples/SDCardPlayer/ | Prepare VGM for SD (decompress, strip DAC) |
stream_vgm.py |
examples/SerialStreaming/ | Stream VGM from PC to board |
For direct chip control without VGM playback, the library includes synthesis utilities in synth/:
#include <GenesisBoard.h>
#include <synth/FMPatch.h>
#include <synth/FMFrequency.h>
#include <synth/PSGFrequency.h>
#include <synth/DefaultPatches.h>
GenesisBoard board(2, 3, 4, 5, 6, 13, 11);
FMPatch patch;
void setup() {
board.begin();
// Load a built-in FM patch
memcpy_P(&patch, &defaultFMPatches[0], sizeof(FMPatch));
FMPatchUtils::loadToChannel(board, 0, patch);
}
void playNote(uint8_t note) {
FMFrequency::writeToChannel(board, 0, note);
FMFrequency::keyOn(board, 0);
}
void stopNote() {
FMFrequency::keyOff(board, 0);
}| Header | Description |
|---|---|
synth/FMFrequency.h |
MIDI note to YM2612 frequency conversion, key on/off |
synth/PSGFrequency.h |
MIDI note to PSG tone values, volume control |
synth/FMPatch.h |
FM patch structure and loading utilities |
synth/PSGEnvelope.h |
Software envelope generator for PSG |
synth/DefaultPatches.h |
8 built-in FM patches and 4 PSG envelopes |
See the SimpleSynth example for a complete demo, or MIDISynth for a full synthesizer implementation.
LGPL-2.1 — See LICENSE for details.
Genesis Engine is not affiliated with or endorsed by Sega. Sega Genesis and Mega Drive are trademarks of Sega Corporation.