Index: /OniSplit/Sound/WavExporter.cs
===================================================================
--- /OniSplit/Sound/WavExporter.cs	(revision 1125)
+++ /OniSplit/Sound/WavExporter.cs	(revision 1126)
@@ -14,7 +14,20 @@
         private static readonly byte[] formatTemplate = new byte[50]
         {
-            0x02, 0, 0, 0, 0x22, 0x56, 0, 0, 0, 0, 0, 0, 0, 0x02, 0x04, 0,
-            0x20, 0, 0xf4, 0x03, 0x07, 0, 0, 0x01, 0, 0, 0, 0x02, 0, 0xff, 0, 0, 0, 0, 0xc0, 0, 0x40, 0,
-            0xf0, 0, 0, 0, 0xcc, 0x01, 0x30, 0xff, 0x88, 0x01, 0x18, 0xff
+            0x02, 0,    // format ID (always 2)
+            0, 0,       // ChannelCount (overwritten)
+            0x22, 0x56, 0, 0, // SampleRate (usually 22050, can be 44100)
+            0, 0, 0, 0, // average data rate (computed and overwritten)
+            0, 0x02,    // block alignment (default 512, can be 1024)
+            0x04, 0,    // bits per sample (always 4)
+            0x20, 0,    // size of extended header block
+            0xf4, 0x03, // samples per block (usually 1012, can be 2036)
+            0x07, 0,    // standard ADPCM coefficient table (always the same)
+            0, 0x01, 0, 0,
+            0, 0x02, 0, 0xff,
+            0, 0, 0, 0,
+            0xc0, 0, 0x40, 0,
+            0xf0, 0, 0, 0,
+            0xcc, 0x01, 0x30, 0xff,
+            0x88, 0x01, 0x18, 0xff
         };
 
@@ -35,7 +48,12 @@
                 var format = (byte[])formatTemplate.Clone();
 
+                var blockAlignment = 512 * sound.ChannelCount * sound.SampleRate / 22050;
+                var samplesPerBlock = 2 + (blockAlignment - sound.ChannelCount * 7) * 8 / sound.ChannelCount / 4;
+                var averageRate = sound.SampleRate * blockAlignment / samplesPerBlock;
                 Array.Copy(BitConverter.GetBytes(sound.ChannelCount), 0, format, 2, 2);
-                Array.Copy(BitConverter.GetBytes(sound.ChannelCount == 1 ? 11155 : 22311), 0, format, 8, 4);
-                Array.Copy(BitConverter.GetBytes(sound.ChannelCount == 1 ? 512 : 1024), 0, format, 12, 2);
+                Array.Copy(BitConverter.GetBytes(sound.SampleRate), 0, format, 4, 4);
+                Array.Copy(BitConverter.GetBytes(averageRate), 0, format, 8, 4);
+                Array.Copy(BitConverter.GetBytes(blockAlignment), 0, format, 12, 2);
+                Array.Copy(BitConverter.GetBytes(samplesPerBlock), 0, format, 18, 2);
 
                 writer.Write(fcc_RIFF);
