Control the Yamaha YM2612 and PSG chips of the SEGA Mega Drive via MIDI.
- Built-in FM presets for General MIDI compatibility
- Built-in PSG envelopes based on the EEF format
- Supports MIDI 1.0 CCs & events (e.g. panning, volume, pitch bending)
- Polythonic support via FM channel pooling
- Connectivity via:
- Mega Everdrive's X7 USB port
- Custom-built USB cable connected to a controller port.
- Fine-grained control of YM2612 registers via GenMDM-style CCs
- Optionally outputs FM parameter values to the screen for a specific MIDI channel (see CC 83)
- SEGA Mega Drive/Genesis Console (Model 1 or 2, NTSC or PAL)
- Mega EverDrive X7 cart
- USB cable for connecting your PC to the EverDrive X7.
- Generic flash cart for loading the ROM
- USB serial cable for connectivity into Controller Port 2, based on these specifications
Whilst connectivity via the controller port might be fine for simple use cases, the controller port's relatively slow speed makes it unsuitable for playback of busy MIDI sequences. EverDrive X7 USB connectivity is the recommended option for these cases.
- MIDI to serial port virtual device, e.g. Hairless MIDI<->Serial Bridge
- Optional: MIDI loop device (so software running on the same PC as the USB connection can use the MIDI interface). In macOS this is possible via the use of a "IAC Device Bus" creatable from the Audio MIDI Setup utility.
You can download pre-built ROMs from releases.
Build & Test
Unit & system tests are compiled and ran as x86 binaries using CMocka. Mega Drive interfaces are mocked.
cmake & gendev):
Sending a MIDI program change (0xC) message will select a pre-defined FM preset.
The full list of presets available are defined in
presets.h. They are based on Wohlstand's XG bank from libOPNMIDI. The interface defaults all FM channels to instrument 0 (Grand Piano) on start-up.
If MIDI channel 10 is mapped to an FM channel, the interface will make use of a separate bank of percussion instruments. An an example, to map MIDI channel 10 to FM channel 6, use the SysEx sequence
00 22 77 00 09 05. Note that by default MIDI channel 10 is set to the PSG noise channel.
Dynamic Mapping Mode
When dynamic mapping mode is enabled (SysEx
00 22 77 03 01), MIDI channel note-on/off events are dynamically routed to free FM and PSG channels. That is, MIDI channels no-longer map directly onto device channels but are virtualised and note-on/off events and MIDI program data is set on the next available channel. This mode is best suited for playback of General MIDI files and makes full use of available YM2612/PSG capacity.
The following rules are used to determine which device channel receives the MIDI event:
- FM channels 1 - 6 and PSG channels 1 - 3 (device channels) are included in the pool of available channels. The first available channel is assigned the first MIDI note on event. Future events are sent to this channel.
- On subsequent events, if the note is already playing on that channel, the next available device channel is used.
- The following MIDI parameters are automatically set on any mapped device channels:
Show FM Channel Parameters on UI
You can use CC 83 to show the current FM parameters for the specific channel:
When polyphonic mode is enabled (CC 80), dynamic mapping mode is enabled and MIDI channel 1 is mapped to FM channels 1-6. This allows for polyphony within a single MIDI channel. In addition, any FM parameter change made will be sent to all FM channels. If all channels are busy, the note on event is dropped.
MIDI Message Reference
By default, MIDI channels are assigned in a static, one-to-one arrangement to FM or PSG channels as follows:
|1 - 6||YM2612 FM Channels 1 - 6|
|7 - 9||PSG Square Wave Tones 1 - 3|
|10||PSG Noise Channel|
You can also re-configure the MIDI mappings via SysEx
- Note On/Off
- Pitch Bend
- Program Change (selects FM preset or PSG envelope)
- Universal SysEx Messages
Common MIDI CCs
These are supported across FM and PSG channels:
|7||Channel Volume||Output Operator Total Level (FM),
|0 - 127: Logarithmic|
|10||Panning||Stereo||0 - 31: Left
32 - 95: Centre
96 - 127: Right
|120||All Sounds Off||Same as CC 123||Any|
|121||Reset All Controllers||Reset MIDI parameters and dynamic channel mappings (dynamic mode only)||Any|
|123||All Notes Off||Key Off (FM),
Max. Attenuation (PSG)
These only apply to channels mapped to FM channels:
Range determines how the possible 128 MIDI values are divided to give the respective YM2612 register value, using the formula
_midiValue / (128 / range) = registerValue (e.g. MIDI value of 32, with a range of 8 translates into to a YM2612 register value of 2)
|Frequency Modulation Level (FMS)||75||8|
|Amplitude Modulation Level (AMS)||76||4|
|Show Parameters on UI||83||2|
Per Channel & Operator
|Total Level (TL)||16||17||18||19||128|
|Rate Scaling (RS)||39||40||41||42||4|
|Attack Rate (AR)||43||44||45||46||32|
|First Decay Rate (D1R)||47||48||49||50||32|
|Second Decay Rate (D2R)||51||52||53||54||16|
|Secondary Amplitude (D1L/SL)||55||56||57||58||16|
|Release Rate (RR)||59||60||61||62||16|
|Amplitude Modulation (AM)||70||71||72||73||2|
Configuration & Advanced Operations
The interface is configurable by sending specific System Exclusive messages to the Mega Drive. There are also a number of advanced operations which have a specific effect when received. A list of all possible SysEx messages are given below:
|General MIDI Reset||
||Force all notes off on all channels and resets all MIDI channel mappings.|
|Remap MIDI Channel||
||Remap MIDI channel xx to device channel yy
xx = MIDI channel (0-15), unassigned (127)
yy = FM (0-5), PSG (6-9), unassigned (127)
||Interface responds with a pong SysEx reply (
|Dynamic Channelling Mode||
||Dynamically assigns MIDI channels to idle FM/PSG channels to allow for maximum polyphony and variation in instrumentation.
xx = Enable (01) / Disable (00)
|Non-General MIDI CCs||
||Respond to non-General MIDI CCs.
xx = Enable (01) / Disable (00)
|Polyphony Sticks to Device Type||
||MIDI channel polyphony will stick to originally assigned device type (FM or PSG). Enable for consistent voicing, but disable to allow for maximum polyphony.
xx = Enable (01) / Disable (00)
|Load User Defined PSG Envelope||
||Loads a custom PSG envelope|
Releases are tested for performance using the Mega MIDI Ping Pong tool which makes use of the "Ping" SysEx message to measure round-trip time.
- Support for loading & playback of PCM samples.
- Support for loading & saving of FM/PSG presets via SD card or SysEx.
Pull requests are welcome, as are donations!