<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.multimedia.cx/index.php?action=history&amp;feed=atom&amp;title=Origin_MGI</id>
	<title>Origin MGI - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.multimedia.cx/index.php?action=history&amp;feed=atom&amp;title=Origin_MGI"/>
	<link rel="alternate" type="text/html" href="https://wiki.multimedia.cx/index.php?title=Origin_MGI&amp;action=history"/>
	<updated>2026-06-09T23:04:22Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.39.5</generator>
	<entry>
		<id>https://wiki.multimedia.cx/index.php?title=Origin_MGI&amp;diff=7640&amp;oldid=prev</id>
		<title>Multimedia Mike: Reverted edits by SpdC4c (Talk); changed back to last version by Dashcloud</title>
		<link rel="alternate" type="text/html" href="https://wiki.multimedia.cx/index.php?title=Origin_MGI&amp;diff=7640&amp;oldid=prev"/>
		<updated>2007-04-10T22:53:10Z</updated>

		<summary type="html">&lt;p&gt;Reverted edits by &lt;a href=&quot;/index.php/Special:Contributions/SpdC4c&quot; title=&quot;Special:Contributions/SpdC4c&quot;&gt;SpdC4c&lt;/a&gt; (&lt;a href=&quot;/index.php?title=User_talk:SpdC4c&amp;amp;action=edit&amp;amp;redlink=1&quot; class=&quot;new&quot; title=&quot;User talk:SpdC4c (page does not exist)&quot;&gt;Talk&lt;/a&gt;); changed back to last version by &lt;a href=&quot;/index.php/User:Dashcloud&quot; title=&quot;User:Dashcloud&quot;&gt;Dashcloud&lt;/a&gt;&lt;/p&gt;
&lt;a href=&quot;https://wiki.multimedia.cx/index.php?title=Origin_MGI&amp;amp;diff=7640&amp;amp;oldid=7620&quot;&gt;Show changes&lt;/a&gt;</summary>
		<author><name>Multimedia Mike</name></author>
	</entry>
	<entry>
		<id>https://wiki.multimedia.cx/index.php?title=Origin_MGI&amp;diff=7620&amp;oldid=prev</id>
		<title>SpdC4c at 22:19, 10 April 2007</title>
		<link rel="alternate" type="text/html" href="https://wiki.multimedia.cx/index.php?title=Origin_MGI&amp;diff=7620&amp;oldid=prev"/>
		<updated>2007-04-10T22:19:23Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;a href=&quot;https://wiki.multimedia.cx/index.php?title=Origin_MGI&amp;amp;diff=7620&amp;amp;oldid=6944&quot;&gt;Show changes&lt;/a&gt;</summary>
		<author><name>SpdC4c</name></author>
	</entry>
	<entry>
		<id>https://wiki.multimedia.cx/index.php?title=Origin_MGI&amp;diff=6944&amp;oldid=prev</id>
		<title>Dashcloud: Update website address</title>
		<link rel="alternate" type="text/html" href="https://wiki.multimedia.cx/index.php?title=Origin_MGI&amp;diff=6944&amp;oldid=prev"/>
		<updated>2007-02-05T05:08:39Z</updated>

		<summary type="html">&lt;p&gt;Update website address&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 22:08, 4 February 2007&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l3&quot;&gt;Line 3:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 3:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;==Credit==&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;==Credit==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;This document comes from wotsit.org, and originated on GAP's (Game Audio Player) website (now defunct).&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;This document comes from &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;[http://www.wotsit.org &lt;/ins&gt;wotsit.org&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;]&lt;/ins&gt;, and originated on GAP's (Game Audio Player) website (now defunct).&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;By Valery V. Anisimovsky (no valid email address known)&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;By Valery V. Anisimovsky (no valid email address known)&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Dmitry Kirnocenskij (ejt@mail.ru) is credited with working out EA ADPCM decompression algorithm.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Dmitry Kirnocenskij (ejt@mail.ru) is credited with working out EA ADPCM decompression algorithm.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Dashcloud</name></author>
	</entry>
	<entry>
		<id>https://wiki.multimedia.cx/index.php?title=Origin_MGI&amp;diff=5681&amp;oldid=prev</id>
		<title>Dashcloud: Correct formatting on page</title>
		<link rel="alternate" type="text/html" href="https://wiki.multimedia.cx/index.php?title=Origin_MGI&amp;diff=5681&amp;oldid=prev"/>
		<updated>2006-08-14T20:19:06Z</updated>

		<summary type="html">&lt;p&gt;Correct formatting on page&lt;/p&gt;
&lt;a href=&quot;https://wiki.multimedia.cx/index.php?title=Origin_MGI&amp;amp;diff=5681&amp;amp;oldid=5679&quot;&gt;Show changes&lt;/a&gt;</summary>
		<author><name>Dashcloud</name></author>
	</entry>
	<entry>
		<id>https://wiki.multimedia.cx/index.php?title=Origin_MGI&amp;diff=5679&amp;oldid=prev</id>
		<title>Dashcloud: Adding Origin MGI format</title>
		<link rel="alternate" type="text/html" href="https://wiki.multimedia.cx/index.php?title=Origin_MGI&amp;diff=5679&amp;oldid=prev"/>
		<updated>2006-08-14T20:00:14Z</updated>

		<summary type="html">&lt;p&gt;Adding Origin MGI format&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;* Extension: mgi, tre&lt;br /&gt;
* Company: [[Origin Systems]]&lt;br /&gt;
&lt;br /&gt;
==Credit==&lt;br /&gt;
This document comes from wotsit.org, and originated on GAP's (Game Audio Player) website (now defunct).&lt;br /&gt;
By Valery V. Anisimovsky (no valid email address known)&lt;br /&gt;
Dmitry Kirnocenskij (ejt@mail.ru) is credited with working out EA ADPCM decompression algorithm.&lt;br /&gt;
&lt;br /&gt;
==MGI File Header==&lt;br /&gt;
&lt;br /&gt;
The MGI file has the following header:&lt;br /&gt;
&lt;br /&gt;
struct MGIHeader&lt;br /&gt;
{&lt;br /&gt;
  char	szID[4];&lt;br /&gt;
  DWORD dwUnknown1;&lt;br /&gt;
  DWORD dwNumSecIndices;&lt;br /&gt;
  DWORD dwUnknown2;&lt;br /&gt;
  DWORD dwNumIntIndices;&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
szID -- string ID, which is equal to &amp;quot;\x8F\xC2\x35\x3F&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
dwUnknown1, dwUnknown2 -- seem to be always 0.&lt;br /&gt;
&lt;br /&gt;
dwNumSecIndices -- the number of section indices used in section descriptors&lt;br /&gt;
(see below).&lt;br /&gt;
&lt;br /&gt;
dwNumIntIndices -- seems to be the number of indices used in interactive&lt;br /&gt;
playback descriptors (see below).&lt;br /&gt;
&lt;br /&gt;
After the header comes the table of interactive playback descriptors. Each&lt;br /&gt;
descriptor has the following format:&lt;br /&gt;
&lt;br /&gt;
struct MGIIntDesc&lt;br /&gt;
{&lt;br /&gt;
  LONG	lIndex;&lt;br /&gt;
  DWORD dwSection;&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
lIndex -- seems to be the index of interactive sequence. Note that some&lt;br /&gt;
indices are negative values.&lt;br /&gt;
&lt;br /&gt;
dwSection -- the pointer to the section (that is, the index of the section&lt;br /&gt;
descriptor correspondent to the section, NOT the index of section given in&lt;br /&gt;
the descriptor itself!)&lt;br /&gt;
&lt;br /&gt;
The number of descriptors in this table (its size) is very uncertain. I use&lt;br /&gt;
a kind of heuristic approach to get past this table, outlined below.&lt;br /&gt;
&lt;br /&gt;
After the table of interactive playback descriptors comes the (DWORD) number&lt;br /&gt;
of sections in the file (let it be denoted as dwNumSections). After this&lt;br /&gt;
number comes the table of (dwNumSections) section descriptors. Each descriptor&lt;br /&gt;
has the following format:&lt;br /&gt;
&lt;br /&gt;
struct MGISecDesc&lt;br /&gt;
{&lt;br /&gt;
  DWORD dwStart;&lt;br /&gt;
  DWORD dwIndex;&lt;br /&gt;
  DWORD dwOutSize;&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
dwStart -- the starting position of the audio data for the section.&lt;br /&gt;
&lt;br /&gt;
dwIndex -- the index of the section (NOT the index of the correspondent&lt;br /&gt;
descriptor). Several different sections may have the same index. The meaning&lt;br /&gt;
of this index seems to be quite uncertain, though it is not required for&lt;br /&gt;
non-interactive playback of MGI files.&lt;br /&gt;
&lt;br /&gt;
dwOutSize -- the output size of the audio stream stored in the section&lt;br /&gt;
(in bytes). May be used for section length (in seconds) calculation.&lt;br /&gt;
Includes the outsizes for both compressed and non-compressed parts of the&lt;br /&gt;
section, that is, it's the whole outsize of the section.&lt;br /&gt;
&lt;br /&gt;
Now, here's the approach I use to get to the start of section descriptors&lt;br /&gt;
table. First, we should read MGIHeader. Then, we may read the interactive&lt;br /&gt;
playback table -- descriptor by descriptor and for each descriptor we should&lt;br /&gt;
check whether its (dwIndex) is less than header values (dwNumSecIndices)&lt;br /&gt;
and (dwNumIntIndices). If the suspicious descriptor is found (for which&lt;br /&gt;
the index value is out of range -- note that the descriptors with negative&lt;br /&gt;
indices are correct!) we may check whether this descriptors is really the&lt;br /&gt;
beginning of the section descriptors table. This check is simple to perform:&lt;br /&gt;
assume that audio data for the first section starts right after the section&lt;br /&gt;
descriptors table, then we can get the following equation:&lt;br /&gt;
(dwDescPos)+4+(lIndex)*sizeof(MGISecDesc)=(dwSection),&lt;br /&gt;
where (dwDescPos) is the position in MGI file at which starts the suspicious&lt;br /&gt;
descriptor, (lIndex) and (dwSection) are the values from that descriptor.&lt;br /&gt;
When this equation holds we most likely found the beginning of the section&lt;br /&gt;
descriptors table.&lt;br /&gt;
&lt;br /&gt;
After the section descriptors table comes the audio data for the sections.&lt;br /&gt;
&lt;br /&gt;
== MGI Section Audio Data ==&lt;br /&gt;
&lt;br /&gt;
For each section we can get the starting position of the audio data from&lt;br /&gt;
the section's descriptor. Note that the last section seems to be always&lt;br /&gt;
empty (it starts at the end of the MGI file, has zero outsize and zero index).&lt;br /&gt;
Each section consists of two parts: EA ADPCM compressed and non-compressed.&lt;br /&gt;
First comes the compressed part and right after that comes non-compressed&lt;br /&gt;
part. To get the size of non-compressed tail you can use the following formula:&lt;br /&gt;
dwTailSize=(dwSectionSize*0x70-dwOutSize*0x1E)/0x52,&lt;br /&gt;
where (dwSectionSize) is the size of the whole section (which may be calculated&lt;br /&gt;
as the difference between the start positions of the next and the current&lt;br /&gt;
sections), (dwOutSize) is the value from the section's descriptor. This&lt;br /&gt;
formula can be easily derived knowing the fact the compressed data is composed&lt;br /&gt;
of blocks (0x1E bytes each -- for stereo stream) which are decompressed into&lt;br /&gt;
0x1C*4 bytes each (for stereo stream). Note that this formula is valid for&lt;br /&gt;
both stereo and mono MGI files.&lt;br /&gt;
&lt;br /&gt;
The compressed part contains EA ADPCM compressed stream. It's devided into&lt;br /&gt;
small blocks of 0x1E (stereo) or 0xF (mono) bytes. The non-compressed part&lt;br /&gt;
contains raw (16-bit signed) PCM data. All MGI files I've seen are stereo&lt;br /&gt;
22050 Hz 16-bit. The non-compressed part may be played right after the&lt;br /&gt;
compressed part.&lt;br /&gt;
&lt;br /&gt;
All sections may be played consequently right in their turn. Some MGI files&lt;br /&gt;
contain several quite independent tunes, though when played consequently,&lt;br /&gt;
those tunes form relatively seamless composition.&lt;br /&gt;
&lt;br /&gt;
== EA ADPCM Decompression Algorithm ==&lt;br /&gt;
&lt;br /&gt;
During the decompression four LONG variables must be maintained for stereo&lt;br /&gt;
stream: lCurSampleLeft, lCurSampleRight, lPrevSampleLeft, lPrevSampleRight&lt;br /&gt;
and two -- for mono stream: lCurSample, lPrevSample. At the beginning of each&lt;br /&gt;
section you must initialize these variables to zeros.&lt;br /&gt;
Note that LONG here is signed.&lt;br /&gt;
&lt;br /&gt;
The stream is divided into small blocks of 0x1E (stereo) or 0xF (mono) bytes.&lt;br /&gt;
You should process all blocks in their turn. Here's the code which&lt;br /&gt;
decompresses one stereo stream block.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
BYTE  InputBuffer[InputBufferSize]; // buffer containing data for one block&lt;br /&gt;
BYTE  bInput;&lt;br /&gt;
DWORD i;&lt;br /&gt;
LONG  c1left,c2left,c1right,c2right,left,right;&lt;br /&gt;
BYTE  dleft,dright;&lt;br /&gt;
&lt;br /&gt;
bInput=InputBuffer[0];&lt;br /&gt;
c1left=EATable[HINIBBLE(bInput)];   // predictor coeffs for left channel&lt;br /&gt;
c2left=EATable[HINIBBLE(bInput)+4];&lt;br /&gt;
c1right=EATable[LONIBBLE(bInput)];  // predictor coeffs for right channel&lt;br /&gt;
c2right=EATable[LONIBBLE(bInput)+4];&lt;br /&gt;
&lt;br /&gt;
bInput=InputBuffer[1];&lt;br /&gt;
dleft=HINIBBLE(bInput)+8;   // shift value for left channel&lt;br /&gt;
dright=LONIBBLE(bInput)+8;  // shift value for right channel&lt;br /&gt;
&lt;br /&gt;
for (i=2;i&amp;lt;0x1E;i++)&lt;br /&gt;
{&lt;br /&gt;
  left=HINIBBLE(InputBuffer[i]);  // HIGHER nibble for left channel&lt;br /&gt;
  left=(left&amp;lt;&amp;lt;0x1c)&amp;gt;&amp;gt;dleft;&lt;br /&gt;
  left=(left+lCurSampleLeft*c1left+lPrevSampleLeft*c2left+0x80)&amp;gt;&amp;gt;8;&lt;br /&gt;
  left=Clip16BitSample(left);&lt;br /&gt;
  lPrevSampleLeft=lCurSampleLeft;&lt;br /&gt;
  lCurSampleLeft=left;&lt;br /&gt;
&lt;br /&gt;
  right=LONIBBLE(InputBuffer[i]); // LOWER nibble for right channel&lt;br /&gt;
  right=(right&amp;lt;&amp;lt;0x1c)&amp;gt;&amp;gt;dright;&lt;br /&gt;
  right=(right+lCurSampleRight*c1right+lPrevSampleRight*c2right+0x80)&amp;gt;&amp;gt;8;&lt;br /&gt;
  right=Clip16BitSample(right);&lt;br /&gt;
  lPrevSampleRight=lCurSampleRight;&lt;br /&gt;
  lCurSampleRight=right;&lt;br /&gt;
&lt;br /&gt;
  // Now we've got lCurSampleLeft and lCurSampleRight which form one stereo&lt;br /&gt;
  // sample and all is set for the next step...&lt;br /&gt;
  Output((SHORT)lCurSampleLeft,(SHORT)lCurSampleRight); // send the sample to output&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
HINIBBLE and LONIBBLE are higher and lower 4-bit nibbles:&lt;br /&gt;
#define HINIBBLE(byte) ((byte) &amp;gt;&amp;gt; 4)&lt;br /&gt;
#define LONIBBLE(byte) ((byte) &amp;amp; 0x0F)&lt;br /&gt;
Note that depending on your compiler you may need to use additional nibble&lt;br /&gt;
separation in these defines, e.g. (((byte) &amp;gt;&amp;gt; 4) &amp;amp; 0x0F).&lt;br /&gt;
&lt;br /&gt;
EATable is the table given in the next section of this document.&lt;br /&gt;
&lt;br /&gt;
Output() is just a placeholder for any action you would like to perform for&lt;br /&gt;
decompressed sample value.&lt;br /&gt;
&lt;br /&gt;
Clip16BitSample is quite evident:&lt;br /&gt;
&lt;br /&gt;
LONG Clip16BitSample(LONG sample)&lt;br /&gt;
{&lt;br /&gt;
  if (sample&amp;gt;32767)&lt;br /&gt;
     return 32767;&lt;br /&gt;
  else if (sample&amp;lt;-32768)&lt;br /&gt;
     return (-32768);&lt;br /&gt;
  else&lt;br /&gt;
     return sample;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
As to mono sound, it's just analoguous -- you should process the blocks each&lt;br /&gt;
being 0xF bytes long:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
bInput=InputBuffer[0];&lt;br /&gt;
c1=EATable[HINIBBLE(bInput)];	// predictor coeffs&lt;br /&gt;
c2=EATable[HINIBBLE(bInput)+4];&lt;br /&gt;
d=LONIBBLE(bInput)+8;  // shift value&lt;br /&gt;
&lt;br /&gt;
for (i=1;i&amp;lt;0xF;i++)&lt;br /&gt;
{&lt;br /&gt;
  left=HINIBBLE(InputBuffer[i]);  // HIGHER nibble for left channel&lt;br /&gt;
  left=(left&amp;lt;&amp;lt;0x1c)&amp;gt;&amp;gt;dleft;&lt;br /&gt;
  left=(left+lCurSampleLeft*c1left+lPrevSampleLeft*c2left+0x80)&amp;gt;&amp;gt;8;&lt;br /&gt;
  left=Clip16BitSample(left);&lt;br /&gt;
  lPrevSampleLeft=lCurSampleLeft;&lt;br /&gt;
  lCurSampleLeft=left;&lt;br /&gt;
&lt;br /&gt;
  // Now we've got lCurSampleLeft which is one mono sample and all is set&lt;br /&gt;
  // for the next input nibble...&lt;br /&gt;
  Output((SHORT)lCurSampleLeft); // send the sample to output&lt;br /&gt;
&lt;br /&gt;
  left=LONIBBLE(InputBuffer[i]);  // LOWER nibble for left channel&lt;br /&gt;
  left=(left&amp;lt;&amp;lt;0x1c)&amp;gt;&amp;gt;dleft;&lt;br /&gt;
  left=(left+lCurSampleLeft*c1left+lPrevSampleLeft*c2left+0x80)&amp;gt;&amp;gt;8;&lt;br /&gt;
  left=Clip16BitSample(left);&lt;br /&gt;
  lPrevSampleLeft=lCurSampleLeft;&lt;br /&gt;
  lCurSampleLeft=left;&lt;br /&gt;
&lt;br /&gt;
  // Now we've got lCurSampleLeft which is one mono sample and all is set&lt;br /&gt;
  // for the next input byte...&lt;br /&gt;
  Output((SHORT)lCurSampleLeft); // send the sample to output&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
Note that HIGHER nibble is processed first for mono sound and corresponds to&lt;br /&gt;
LEFT channel for stereo.&lt;br /&gt;
&lt;br /&gt;
Of course, this decompression routine may be greatly optimized.&lt;br /&gt;
&lt;br /&gt;
== EA ADPCM Table ==&lt;br /&gt;
&lt;br /&gt;
LONG EATable[]=&lt;br /&gt;
{&lt;br /&gt;
  0x00000000,&lt;br /&gt;
  0x000000F0,&lt;br /&gt;
  0x000001CC,&lt;br /&gt;
  0x00000188,&lt;br /&gt;
  0x00000000,&lt;br /&gt;
  0x00000000,&lt;br /&gt;
  0xFFFFFF30,&lt;br /&gt;
  0xFFFFFF24,&lt;br /&gt;
  0x00000000,&lt;br /&gt;
  0x00000001,&lt;br /&gt;
  0x00000003,&lt;br /&gt;
  0x00000004,&lt;br /&gt;
  0x00000007,&lt;br /&gt;
  0x00000008,&lt;br /&gt;
  0x0000000A,&lt;br /&gt;
  0x0000000B,&lt;br /&gt;
  0x00000000,&lt;br /&gt;
  0xFFFFFFFF,&lt;br /&gt;
  0xFFFFFFFD,&lt;br /&gt;
  0xFFFFFFFC&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
== MGI Audio Files in TRE Archives ==&lt;br /&gt;
&lt;br /&gt;
When stored in .TRE resources, MGI audio files are stored &amp;quot;as is&amp;quot;, without&lt;br /&gt;
compression or encryption. That means if you want to play/extract MGI&lt;br /&gt;
file from the TRE resource you just need to search for (szID) id-string&lt;br /&gt;
(&amp;quot;\x8F\xC2\x35\x3F&amp;quot;), read MGI header starting at the beginning position of&lt;br /&gt;
found id-string and then use the approach outlined above to find the&lt;br /&gt;
section descriptors table. The found id-string will give you starting point&lt;br /&gt;
of MGI file and the size of the file will be the (dwStart) value in the&lt;br /&gt;
descriptor of the last section.&lt;br /&gt;
&lt;br /&gt;
==PC Games Using Origin MGI==&lt;br /&gt;
*[http://www.mobygames.com/game/windows/wing-commander-prophecy Wing Commander Prophecy]&lt;br /&gt;
[[Category:Game Formats]]&lt;/div&gt;</summary>
		<author><name>Dashcloud</name></author>
	</entry>
</feed>