GENMIDI.OP2 OPL2 sound bank: GraphViz block diagram (.dot) source

GENMIDI.OP2 is a sound bank file used by players based on DMX sound library to play MIDI files with General MIDI instruments using OPL2 sound chip (which was commonly installed on popular AdLib and Sound Blaster sound cards).

Major users of DMX sound library include:

  • Original Doom game engine (and games based on it: Heretic, Hexen, Strife, Chex Quest)
  • Raptor: Call of the Shadows

File extension

op2

KS implementation details

License: CC0-1.0

This page hosts a formal specification of GENMIDI.OP2 OPL2 sound bank using Kaitai Struct. This specification can be automatically translated into a variety of programming languages to get a parsing library.

GraphViz block diagram source

genmidi_op2.dot

digraph {
	rankdir=LR;
	node [shape=plaintext];
	subgraph cluster__genmidi_op2 {
		label="GenmidiOp2";
		graph[style=dotted];

		genmidi_op2__seq [label=<<TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0">
			<TR><TD BGCOLOR="#E0FFE0">pos</TD><TD BGCOLOR="#E0FFE0">size</TD><TD BGCOLOR="#E0FFE0">type</TD><TD BGCOLOR="#E0FFE0">id</TD></TR>
			<TR><TD PORT="magic_pos">0</TD><TD PORT="magic_size">8</TD><TD>23 4F 50 4C 5F 49 49 23</TD><TD PORT="magic_type">magic</TD></TR>
			<TR><TD PORT="instruments_pos">8</TD><TD PORT="instruments_size">36</TD><TD>InstrumentEntry</TD><TD PORT="instruments_type">instruments</TD></TR>
			<TR><TD COLSPAN="4" PORT="instruments__repeat">repeat 175 times</TD></TR>
			<TR><TD PORT="instrument_names_pos">6308</TD><TD PORT="instrument_names_size">32</TD><TD>str(ASCII)</TD><TD PORT="instrument_names_type">instrument_names</TD></TR>
			<TR><TD COLSPAN="4" PORT="instrument_names__repeat">repeat 175 times</TD></TR>
		</TABLE>>];
		subgraph cluster__instrument_entry {
			label="GenmidiOp2::InstrumentEntry";
			graph[style=dotted];

			instrument_entry__seq [label=<<TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0">
				<TR><TD BGCOLOR="#E0FFE0">pos</TD><TD BGCOLOR="#E0FFE0">size</TD><TD BGCOLOR="#E0FFE0">type</TD><TD BGCOLOR="#E0FFE0">id</TD></TR>
				<TR><TD PORT="flags_pos">0</TD><TD PORT="flags_size">2</TD><TD>u2le</TD><TD PORT="flags_type">flags</TD></TR>
				<TR><TD PORT="finetune_pos">2</TD><TD PORT="finetune_size">1</TD><TD>u1</TD><TD PORT="finetune_type">finetune</TD></TR>
				<TR><TD PORT="note_pos">3</TD><TD PORT="note_size">1</TD><TD>u1</TD><TD PORT="note_type">note</TD></TR>
				<TR><TD PORT="instruments_pos">4</TD><TD PORT="instruments_size">16</TD><TD>Instrument</TD><TD PORT="instruments_type">instruments</TD></TR>
				<TR><TD COLSPAN="4" PORT="instruments__repeat">repeat 2 times</TD></TR>
			</TABLE>>];
		}
		subgraph cluster__instrument {
			label="GenmidiOp2::Instrument";
			graph[style=dotted];

			instrument__seq [label=<<TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0">
				<TR><TD BGCOLOR="#E0FFE0">pos</TD><TD BGCOLOR="#E0FFE0">size</TD><TD BGCOLOR="#E0FFE0">type</TD><TD BGCOLOR="#E0FFE0">id</TD></TR>
				<TR><TD PORT="op1_pos">0</TD><TD PORT="op1_size">6</TD><TD>OpSettings</TD><TD PORT="op1_type">op1</TD></TR>
				<TR><TD PORT="feedback_pos">6</TD><TD PORT="feedback_size">1</TD><TD>u1</TD><TD PORT="feedback_type">feedback</TD></TR>
				<TR><TD PORT="op2_pos">7</TD><TD PORT="op2_size">6</TD><TD>OpSettings</TD><TD PORT="op2_type">op2</TD></TR>
				<TR><TD PORT="unused_pos">13</TD><TD PORT="unused_size">1</TD><TD>u1</TD><TD PORT="unused_type">unused</TD></TR>
				<TR><TD PORT="base_note_pos">14</TD><TD PORT="base_note_size">2</TD><TD>s2le</TD><TD PORT="base_note_type">base_note</TD></TR>
			</TABLE>>];
		}
		subgraph cluster__op_settings {
			label="GenmidiOp2::OpSettings";
			graph[style=dotted];

			op_settings__seq [label=<<TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0">
				<TR><TD BGCOLOR="#E0FFE0">pos</TD><TD BGCOLOR="#E0FFE0">size</TD><TD BGCOLOR="#E0FFE0">type</TD><TD BGCOLOR="#E0FFE0">id</TD></TR>
				<TR><TD PORT="trem_vibr_pos">0</TD><TD PORT="trem_vibr_size">1</TD><TD>u1</TD><TD PORT="trem_vibr_type">trem_vibr</TD></TR>
				<TR><TD PORT="att_dec_pos">1</TD><TD PORT="att_dec_size">1</TD><TD>u1</TD><TD PORT="att_dec_type">att_dec</TD></TR>
				<TR><TD PORT="sust_rel_pos">2</TD><TD PORT="sust_rel_size">1</TD><TD>u1</TD><TD PORT="sust_rel_type">sust_rel</TD></TR>
				<TR><TD PORT="wave_pos">3</TD><TD PORT="wave_size">1</TD><TD>u1</TD><TD PORT="wave_type">wave</TD></TR>
				<TR><TD PORT="scale_pos">4</TD><TD PORT="scale_size">1</TD><TD>u1</TD><TD PORT="scale_type">scale</TD></TR>
				<TR><TD PORT="level_pos">5</TD><TD PORT="level_size">1</TD><TD>u1</TD><TD PORT="level_type">level</TD></TR>
			</TABLE>>];
		}
	}
	genmidi_op2__seq:instruments_type -> instrument_entry__seq [style=bold];
	instrument_entry__seq:instruments_type -> instrument__seq [style=bold];
	instrument__seq:op1_type -> op_settings__seq [style=bold];
	instrument__seq:op2_type -> op_settings__seq [style=bold];
}