Midi -> VGM Converter - SN76489
---------------------
by Valley Bell

This small tool converts standard MIDI files (.mid) to Video Game Music files (.vgm).
The vgms will use the PSG chip (SN76489) and its variants.

Supported MIDI Controllers
--------------------------
ID	GM Name			Special Effect
7	Main Volume		-
9	[undefined]		not for public use (adds a data block with some text in the VGM)
10	Pan			-
11	Expression		-
16	General Purpose #1	select Noise Mode
				0-63 - white noise
				64-127 - periodic noise
17	General Purpose #2	PSG 3 frequency Noise Mode
				0-63 - disable
				64-127 - enable (for periodic noise, notes are adjusted to play in tune with normal PSG channels)
111	[undefined]		Loop Controller
				0 - Loop Start
				1+ - Loop End


PSG Types
---------
- simple SN76489: 1x SN76489 with optional GG Stereo (hard pan)
- dual SN76489: like simple SN76489, but 2 of them
- T6W28: The variant used in NeoGeo Pocket. It has a seperated volume control of left and right channel as well as an extra channel for Noise Frequency.

Clocks
------
- SMS: usual NTSC clock as used in consoles such as Sega Master System or MegaDrive
- NGP: clock of NeoGeo Pocket with 3.072 MHz
- Custom: set you own clock in the field below
- Dynamic: calculates the clock that's neccessary to correctly convert your lowest notes
        You set the high limit of your clock.

Be careful, low notes may not be converted correctly due to the chip's lower frequency limit.

Volume Calculation
------------------
- Standard: tries to get volume levels that match the MIDI one exactly
- Linear: linear calculation (MIDI 127 = PSG 15, MIDI 64 = PSG 8, ...), good for vgm2mid2vgm

Channels
--------
The following tables show you how which mode converts MIDI channels to PSG channels.

- Chip-Group
 PSG  | MIDI
------+-------------
 1  I | 1, 9
 2  I | 2, 11
 3  I | 3, 12
 N  I | 4, 10
 1 II | 5, 13
 2 II | 6, 14
 3 II | 7, 15
 N II | 8, 16

- Channel-Group
 PSG  | MIDI
------+-------------
 1  I | 1, 3
 2  I | 5, 7
 3  I | 9, 12
 N  I | 10, 15
 1 II | 2, 4
 2 II | 6, 8
 3 II | 11, 13
 N II | 14, 16

- vgm2mid:
 PSG  | MIDI
------+-------------
 1  I | 11
 2  I | 12
 3  I | 13
 N  I | 10, 14
 1 II | 1
 2 II | 2
 3 II | 3
 N II | 4

As you can see the Drum Channel 10 is always converted to the Noise Channel. (doing it different wouldn't make any sense)
If 2 chips are used, 1/II means that MIDI Channel 1 goes to chip 2. Else all channels go one chip.

[There was a Channel-Map Editor editor planned initially, but I effectively abandoned the project since.]


Notes:
- The MIDI should not have more than one note playing on the same channel at the same time.
- When not in PSG3 frequency mode, the noise channel can only play notes the A3, A4 and A5.
