A VGM file starts with a 256-byte header (since version 1.50; earlier versions have a
64-byte header). Integers are unsigned and little-endian, and offsets are hexadecimal.
Pointers are relative to the field’s own position, so a VGM data offset of
0C at position 34 means the data starts at 40.
Reserved bytes must be 0. This reference follows the VGM specification as it stands on
the vgmrips wiki (revision 5875, 17 October 2024, “1.72 (beta)”), the 1.71 text of the
specification that ships with VGMPlay, and, for the header fields after E4
that the wiki text does not list yet, libvgm and vgmtools.
Rules for reading the header
- All header sizes are valid for all versions from 1.50 on, as long as the header has
at least 64 bytes. If the VGM data starts at an offset lower than
100, every header byte the data overlaps is handled as if it were zero (VGM specification, the notes under the header table). - The version number says which header values are valid. A file whose version is older than a field it fills in is not wrong to a player that ignores the version, but it is not what the specification describes; the explorer reports it.
- Version 1.01 and earlier: the YM2413 clock field may hold the clock of the YM2151 or
YM2612 (a value above 5,000,000 must be the YM2612 clock), and the YM2612 and YM2151
clock fields do not exist (VGM specification, fields
10,2Cand30). The SN76489 feedback is taken as0009and the shift register width as 16. - The extra header (version 1.70) sits between the header and the VGM data, so a header whose extra header offset is set ends where the extra header begins (this is how libvgm reads it).
Fields
| Offset | Size | Name | Version | Description |
|---|---|---|---|---|
| 00 | 4 | Ident | 1.00 | Vgm , with a trailing space. |
| 04 | 4 | EoF offset | 1.00 | Relative: file length minus 4. |
| 08 | 4 | Version | 1.00 | BCD: 00000171 is 1.71. |
| 0C | 4 | SN76489 clock | 1.00 | 0 when absent, like every chip clock. See clock bits. |
| 10 | 4 | YM2413 clock | 1.00 | Typically 3,579,545. In files of version 1.01 and earlier it may in fact be the YM2151 or YM2612 clock (above 5,000,000 it must be the YM2612). Bit 31 means a VRC7 (1.71 text). |
| 14 | 4 | GD3 offset | 1.00 | Relative offset of the GD3 tag, or 0. |
| 18 | 4 | Total samples | 1.00 | Length at 44,100 samples per second. |
| 1C | 4 | Loop offset | 1.00 | Relative offset of the loop point, or 0. |
| 20 | 4 | Loop samples | 1.00 | |
| 24 | 4 | Rate | 1.01 | The recording rate. |
| 28 | 2 | SN76489 feedback | 1.10 | Below. |
| 2A | 1 | SN76489 shift width | 1.10 | Below. |
| 2B | 1 | SN76489 flags | 1.51 | Below. |
| 2C | 4 | YM2612/YM3438 clock | 1.10 | Typically 7,670,454 or 8,053,975. For 1.01 and earlier the YM2413 clock is used if it is above 5,000,000. Bit 31 means a YM3438 (1.51 and later). |
| 30 | 4 | YM2151/YM2164 clock | 1.10 | Typically 3,579,545 or 4,000,000. For 1.01 and earlier the YM2413 clock is used if it is below 5,000,000. Bit 31 means a YM2164 (1.51 and later). |
| 34 | 4 | VGM data offset | 1.50 | Relative offset of the data. Files before 1.50 start at 40. |
| 38 | 4 | Sega PCM clock | 1.51 | |
| 3C | 4 | Sega PCM interface | 1.51 | |
| 40 | 4 | RF5C68 clock | 1.51 | |
| 44 | 4 | YM2203 clock | 1.51 | |
| 48 | 4 | YM2608 clock | 1.51 | |
| 4C | 4 | YM2610/B clock | 1.51 | |
| 50 | 4 | YM3812 clock | 1.51 | |
| 54 | 4 | YM3526 clock | 1.51 | |
| 58 | 4 | Y8950 clock | 1.51 | |
| 5C | 4 | YMF262 clock | 1.51 | |
| 60 | 4 | YMF278B clock | 1.51 | |
| 64 | 4 | YMF271 clock | 1.51 | |
| 68 | 4 | YMZ280B clock | 1.51 | |
| 6C | 4 | RF5C164 clock | 1.51 | |
| 70 | 4 | PWM clock | 1.51 | |
| 74 | 4 | AY8910 clock | 1.51 | |
| 78 | 1 | AY8910 chip type | 1.51 | Below. |
| 79 | 1 | AY8910 flags | 1.51 | Below. |
| 7A | 1 | YM2203/AY8910 flags | 1.51 | Flags for the AY8910 inside a YM2203. |
| 7B | 1 | YM2608/AY8910 flags | 1.51 | Flags for the AY8910 inside a YM2608. |
| 7C | 1 | Volume modifier | 1.60 | Volume = 2^(value ÷ 20), value −63 to 192; −63 is treated as −64. |
| 7D | 1 | Reserved | 1.60 | |
| 7E | 1 | Loop base | 1.60 | Signed. Loops played = modified loops − loop base. |
| 7F | 1 | Loop modifier | 1.51 | Loops played = program loops × modifier ÷ 10. 0 is treated as 10. |
| 80 | 4 | GameBoy DMG clock | 1.61 | |
| 84 | 4 | NES APU clock | 1.61 | |
| 88 | 4 | MultiPCM clock | 1.61 | |
| 8C | 4 | uPD7759 clock | 1.61 | |
| 90 | 4 | OKIM6258 clock | 1.61 | |
| 94 | 1 | OKIM6258 flags | 1.61 | Below. |
| 95 | 1 | K054539 flags | 1.61 | Below. |
| 96 | 1 | C140 chip type | 1.61 | Below. |
| 97 | 1 | Reserved | 1.61 | |
| 98 | 4 | OKIM6295 clock | 1.61 | |
| 9C | 4 | K051649/K052539 clock | 1.61 | |
| A0 | 4 | K054539 clock | 1.61 | |
| A4 | 4 | HuC6280 clock | 1.61 | |
| A8 | 4 | C140 clock | 1.61 | |
| AC | 4 | K053260 clock | 1.61 | |
| B0 | 4 | Pokey clock | 1.61 | |
| B4 | 4 | QSound clock | 1.61 | |
| B8 | 4 | SCSP clock | 1.71 | |
| BC | 4 | Extra header offset | 1.70 | Relative offset of the extra header, or 0. |
| C0 | 4 | WonderSwan clock | 1.71 | |
| C4 | 4 | Virtual Boy VSU clock | 1.71 | |
| C8 | 4 | SAA1099 clock | 1.71 | |
| CC | 4 | ES5503 clock | 1.71 | |
| D0 | 4 | ES5505/ES5506 clock | 1.71 | |
| D4 | 1 | ES5503 channels | 1.71 | 1 to 8, usually 2. |
| D5 | 1 | ES5505/6 channels | 1.71 | 1 to 4 for ES5505, 1 to 8 for ES5506, usually 1. |
| D6 | 1 | C352 clock divider | 1.71 | Divider = value × 4, 0 to 1,020; usually 288. |
| D7 | 1 | Reserved (MSM5205 flags) | 1.71 (libvgm) | Reserved in the wiki text; libvgm and vgmtools read it as the MSM5205 flags. |
| D8 | 4 | Seta X1-010 clock | 1.71 | |
| DC | 4 | Namco C352 clock | 1.71 | |
| E0 | 4 | Irem GA20 clock | 1.71 | |
| E4 | 4 | Mikey clock | 1.72 | The Atari Lynx sound chip; typically 16,000,000. |
| E8 | 4 | K007232 clock | libvgm | Not in the wiki text; in libvgm and vgmtools. |
| EC | 4 | K005289 clock | libvgm | Not in the wiki text; in libvgm and vgmtools. |
| F0 | 4 | MSM5205 clock | libvgm | Not in the wiki text; in libvgm and vgmtools. (vgmtools calls it OKIM5205.) |
| F4 | 4 | MSM5232 clock | libvgm | Not in the wiki text; in libvgm and vgmtools. (vgmtools calls it OKIM5232.) |
| F8 | 4 | BSMT2000 clock | libvgm | Not in the wiki text; in libvgm and vgmtools. |
| FC | 4 | ICS2115 clock | libvgm | Not in the wiki text; in libvgm and vgmtools. |
From version 1.50 the header can be shorter: anything at or after the data offset at
34 is not header and can be ignored.
Clock bits
Bit 30 (40000000) of a chip clock means two chips of that type are present.
The specification allows it for the PSG, YM2413, YM2612, YM2151, Sega PCM, YM2203,
YM2608, YM2610, YM3812, YM3526, Y8950, YMZ280B, YMF262, YMF278B, YMF271, AY8910,
GameBoy DMG, NES APU, MultiPCM, uPD7759, OKIM6258, OKIM6295, K051649, K054539, HuC6280,
C140, K053260, Pokey, SCSP, WonderSwan, VSU, SAA1099, ES5503, ES5506, X1-010, C352 and
GA20. Bit 31 (80000000) has a meaning of its own for some chips:
| Offset | Chip | Bit 31 set |
|---|---|---|
| 0C | SN76489 | T6W28 (with bit 30) |
| 10 | YM2413 | VRC7 (1.51 and later) |
| 2C | YM2612 | YM3438 (1.51 and later) |
| 30 | YM2151 | YM2164 (1.51 and later) |
| 4C | YM2610 | YM2610B |
| 50 | YM3812 | Pan the first chip left and the second right, with two chips, as on the Sound Blaster Pro 1 and Pro Audio Spectrum |
| 80 | GameBoy DMG | CGB-A model, as libvgm reads it (clear: DMG-B) |
| 84 | NES APU | Enable the FDS sound add-on |
| A4 | HuC6280 | The patch for the pause of “Honey in the Sky” in the Ootake core, as libvgm reads it (clear: no patch) |
| 8C | uPD7759 | Slave (clear: master) |
| 98 | OKIM6295 | The status of pin 7 |
| 9C | K051649 | K052539 |
| D0 | ES5505/ES5506 | ES5506 (clear: ES5505) |
| DC | C352 | Disable the rear channels (clear: enabled) |
SN76489 fields
| Field | Values |
|---|---|
Feedback (28) | The white noise feedback pattern, in MAME’s terms: its feedback taps, which include latency bits and differ from the physical value. Files of version 1.01 and earlier assume 0009; the field may be left at 0 when the PSG is not used. The values the 1.72 text lists:
0009 (Sega), 0003 (Sega Computer 3000H and BBC Micro, the SN76489AN) and 0006 (SN76494, SN76496). |
Shift width (2A) | The width of the noise feedback shift register in bits, again MAME’s feedback mask, which includes latency bits. Files of version 1.01 and earlier assume 16. The 1.72 text lists: 15 for the SN76489 and SN94624; 16 for the Sega Master System 2, Game Gear and Mega Drive (the Sega VDP’s PSG), NCR8496 and PSSJ3; 17 for the SN76489A, SN76494, SN76496 and Y204. (The 1.71 text lists 16 for the Sega VDP and 15 for the Sega Computer 3000H and BBC Micro.) |
Flags bit (2B) | Meaning |
|---|---|
| 0 | Frequency 0 is 400 (should be set for all chips but the Sega PSG). |
| 1 | Output negate flag. |
| 2 | Game Gear stereo on when clear. |
| 3 | ÷8 clock divider on when clear. |
| 4 | XNOR noise mode (NCR8496 and PSSJ-3). |
| 5–7 | Reserved, 0. |
Most of these flags make no audible change and can be ignored by an emulator that lacks the feature. For version 1.51 and earlier files none of the flags should be set. The viewer plays the SN76489 with libvgm’s core, which reads these flags and the two fields above; the YM2612 (clock at 2C, bit 30 for two chips) takes only its clock. The AY8910 reads its clock, its type (78) and its flags (79), and the YM2413 its clock (10) with bit 31 choosing the VRC7 tone set. The YM2151 (clock at 30, bit 30 for two chips) takes only its clock; bit 31, the YM2164, is played as a YM2151, as libvgm’s core plays it. The NES APU (clock at 84, bit 30 for two chips) takes its clock; bit 31 switches on the FDS sound add-on, which the viewer does not play. A clock within 1,000 of 1,662,607 selects the PAL period tables. The Game Boy DMG (clock at 80, bit 30 for two chips) takes its clock; bit 31 selects the CGB-A model instead of the DMG-B.
AY8910 fields
Chip type (78) | Chip |
|---|---|
00 | AY8910 |
01 | AY8912 |
02 | AY8913 |
03 | AY8930 |
04 | AY8914 (1.72 text) |
10 | YM2149 |
11 | YM3439 |
12 | YMZ284 |
13 | YMZ294 |
Flags bit (79; default 01) | Meaning |
|---|---|
| 0 | Legacy output. |
| 1 | Single output. |
| 2 | Discrete output. |
| 3 | RAW output. |
| 4 | YMxxxx pin 26 (clock divider) low; the 1.71 text calls it YM2149 pin 26, an additional ÷2 clock divider. |
| 5–6 | Reserved, 0. |
| 7 | The 1.71 text: ZX-Spectrum-like pan configuration (left, centre, right). The 1.72 text lists bits 5 to 7 as reserved. |
For additional description the specification points to ay8910.h in the MAME source. The flags at 7A (YM2203) and 7B (YM2608) are the same flags for the AY8910 that is part of those chips.
OKIM6258 flags
Bits (default 00) | Meaning |
|---|---|
| 0–1 | Clock divider: 1,024, 768, 512 or 512. |
| 2 | 3-bit or 4-bit ADPCM (default 4-bit; noted as not working). |
| 3 | 10-bit or 12-bit output (default 10-bit). |
| 4–7 | Reserved, 0. |
K054539 flags
Bits (default 01) | Meaning |
|---|---|
| 0 | Reverse stereo. |
| 1 | Disable reverb. |
| 2 | Update at key-on. |
| 3–7 | Reserved, 0. |
C140 chip type
| Value | Chip |
|---|---|
00 | C140, Namco System 2 |
01 | C140, Namco System 21 |
02 | 219 ASIC, Namco NA-1 and NA-2 |
MSM5205 flags
Byte D7 is reserved in the wiki text (it must be 0). libvgm and vgmtools use it as the flags of the MSM5205, which they place with the clock at F0:
| Bits | Meaning |
|---|---|
| 0–1 | The prescaler. |
| 2 | 4-bit ADPCM when set, 3-bit when clear. |
| 3–7 | Not used by libvgm. |
Extra header (1.70)
Placed between the main header and the VGM data, found through the field at
BC.
| Offset | Size | Name | Description |
|---|---|---|---|
| 00 | 4 | Header size | Size of the extra header; 4 or more. |
| 04 | 4 | Chip clock offset | Relative offset of the chip clock list. |
| 08 | 4 | Chip volume offset | Relative offset of the chip volume list. |
| List | Layout |
|---|---|
| Chip clocks | One byte: the number of entries. Each entry is 5 bytes: a chip ID, then the 32-bit clock of the second chip of that type. |
| Chip volumes | One byte: the number of entries. Each entry is 4 bytes: chip ID, flags, a 16-bit volume. |
In a volume entry, bit 7 of the chip ID marks the volume of a paired chip (such as the
AY part of a YM2203), and bit 0 of the flags the second chip. If bit 15 of the volume
is clear, the value is absolute; if set, the chip’s volume is multiplied by
(value & 7FFF) ÷ 100.
Version history
| Version | Added |
|---|---|
| 1.00 | The first version. |
| 1.01 | Rate. |
| 1.10 | PSG feedback and shift register width. |
| 1.50 | Data offset and data blocks. |
| 1.51 | Many chips and commands, SN76489 flags and the loop modifier. |
| 1.60 | PCM RAM writes, DAC stream control, volume modifier and loop base. |
| 1.61 | More chips and data blocks. |
| 1.70 | The extra header. |
| 1.71 | SCSP, WonderSwan, Virtual Boy VSU, SAA1099, ES5503, ES5506, Seta X1-010, Namco C352 and Irem GA20 (with their ROM data blocks); data blocks of type 0x for OKIM6258, HuC6280, SCSP and the NES; the bit 31 variants of the YM2612, YM2151 and K051649; command 31 for AY8910 stereo masks; documented chip flags; the XNOR noise flag. |
| 1.72 (beta) | The Mikey clock (E4) and command 40. The wiki also lists the AY8914 chip type, the changed SN76489 feedback and width tables, and the data block type 08 for Mikey. The fields E8 to FC (K007232, K005289, MSM5205, MSM5232, BSMT2000, ICS2115) and their commands are in libvgm and vgmtools, not in the wiki text. |
Not described
Known, not yet covered
- Reference: the fields
E8toFCand the MSM5205 flags atD7come from libvgm and vgmtools; no specification text names them, so their typical clocks and flag meanings are not given beyond what libvgm reads. - Reference: any later revision of the wiki specification than 5875 (17 October 2024).