Index: /OniSplit/Sound/AifExporter.cs
===================================================================
--- /OniSplit/Sound/AifExporter.cs	(revision 1155)
+++ /OniSplit/Sound/AifExporter.cs	(revision 1156)
@@ -31,12 +31,10 @@
         {
             var sound = SoundData.Read(descriptor, do_pc_demo_test);
+            if (!(sound.IsIMA4))
+                throw new NotSupportedException("Transcoding from MS ADPCM (PC) to IMA4 ADPCM (Mac) not supported!");
 
             using (var stream = File.Create(Path.Combine(OutputDirPath, descriptor.FullName + ".aif")))
             using (var writer = new BinaryWriter(stream))
             {
-                if (!(sound.IsIMA4))
-                {
-                    throw new NotSupportedException("Transcoding from MS ADPCM (PC) to IMA4 ADPCM (Mac) not supported!");
-                }
                 writer.Write(Utils.ByteSwap(fcc_FORM));
                 writer.Write(Utils.ByteSwap(50 + sound.Data.Length));
Index: /OniSplit/Sound/AifImporter.cs
===================================================================
--- /OniSplit/Sound/AifImporter.cs	(revision 1155)
+++ /OniSplit/Sound/AifImporter.cs	(revision 1156)
@@ -53,4 +53,5 @@
                 writer.Write(aif.SoundData.Length);
                 writer.Write(WriteRawPart(aif.SoundData));
+                writer.Skip(8);
             }
 		}
Index: /OniSplit/Sound/SoundData.cs
===================================================================
--- /OniSplit/Sound/SoundData.cs	(revision 1155)
+++ /OniSplit/Sound/SoundData.cs	(revision 1156)
@@ -158,7 +158,4 @@
                 }
             }
-//            Console.WriteLine("Sample count:");
-//            Console.WriteLine(sound.SampleCount);
-
             return sound;
         }
Index: /OniSplit/Sound/WavExporter.cs
===================================================================
--- /OniSplit/Sound/WavExporter.cs	(revision 1155)
+++ /OniSplit/Sound/WavExporter.cs	(revision 1156)
@@ -154,19 +154,5 @@
             using (var writer = new BinaryWriter(stream))
             {
-                var blockSizeADPCM = sound.BlockAlignment;
-                
-                int wholeBlocks = sound.Data.Length / blockSizeADPCM;
-                int leftoverBytes = sound.Data.Length - (wholeBlocks * blockSizeADPCM);
-                int leftoverSamples = 0;
-                if(leftoverBytes > 14)
-                    leftoverSamples = 2 + (leftoverBytes - 7 * sound.ChannelCount)
-                                    * 8 / sound.BitsPerSample / sound.ChannelCount;
-                int paddingBytes = 0;
-                if (leftoverBytes > 0) // incomplete trailing block
-                    paddingBytes = blockSizeADPCM - leftoverBytes;
-                var samplesPerBlock = 2 + (blockSizeADPCM - sound.ChannelCount * 7) * 8 / sound.ChannelCount / sound.BitsPerSample;
-
-                Int32 sampleCount = wholeBlocks * samplesPerBlock + leftoverSamples;
-
+                int blockSizeADPCM, samplesPerBlock, sampleCount, paddingBytes = 0;
                 if (sound.IsIMA4) // IMA4 ADPCM format
                 {
@@ -174,4 +160,20 @@
                     samplesPerBlock = 64;
                     sampleCount = (sound.Data.Length / blockSizeADPCM) * samplesPerBlock;
+                }
+                else
+                {
+                    blockSizeADPCM = sound.BlockAlignment;
+                    int wholeBlocks = sound.Data.Length / blockSizeADPCM;
+                    int leftoverBytes = sound.Data.Length - (wholeBlocks * blockSizeADPCM);
+                    int leftoverSamples = 0;
+                    if (leftoverBytes > 7 * sound.ChannelCount)
+                        leftoverSamples = 2 + (leftoverBytes - 7 * sound.ChannelCount)
+                                        * 8 / sound.BitsPerSample / sound.ChannelCount;
+                    else
+                        Console.Error.WriteLine("Improper trailing bytes/samples!");
+                    if (leftoverBytes > 0) // incomplete trailing block
+                        paddingBytes = blockSizeADPCM - leftoverBytes;
+                    samplesPerBlock = 2 + (blockSizeADPCM - sound.ChannelCount * 7) * 8 / sound.ChannelCount / sound.BitsPerSample;
+                    sampleCount = wholeBlocks * samplesPerBlock + leftoverSamples;
                 }
                 if (!convert_to_PCM)
Index: /OniSplit/Sound/WavFile.cs
===================================================================
--- /OniSplit/Sound/WavFile.cs	(revision 1155)
+++ /OniSplit/Sound/WavFile.cs	(revision 1156)
@@ -40,5 +40,5 @@
                 var header = new WavFile()
                 {
-                    sampleCount = 0
+                    sampleCount = -1
                 };
 
@@ -56,6 +56,5 @@
                         header.ReadDataChunk(reader, chunkSize);
                 }
-
-                header.ValidateSampleCount();
+                header.TruncatePerFact();
                 return header;
             }
@@ -86,15 +85,26 @@
             soundData = reader.ReadBytes(chunkSize);
         }
-        private void ValidateSampleCount() // TODO: ACTUAL VALIDATION/CORRECTION
+        private void TruncatePerFact() // TODO: MORE THOROUGH VALIDATION?
         {
-            int sampleCountFromData = 0;
-            int wholeBlocks = soundData.Length / blockAlign;
-            if(sampleCount == 0) // not explicitly set (no fact chunk present)
+            if(sampleCount == -1) // not explicitly set (no fact chunk present)
             {
                 Console.WriteLine("The imported WAV file has no FACT chunk.");
             }
-            else // TODO: calculate sampleCountFromData, compare with sampleCount
+            else if (format == WavFormat.Adpcm) // calculate truncated data size
             {
-
+                var blockSizeADPCM = blockAlign;
+                var samplesPerBlock = 2 + (blockSizeADPCM - channelCount * 7) * 8 / channelCount / bitsPerSample;
+                int wholeBlocks = sampleCount / samplesPerBlock;
+                if (wholeBlocks * blockAlign > soundData.Length)
+                    Console.Error.WriteLine("Sample count exceeds the range of sound data.");
+                int leftoverSamples = sampleCount - wholeBlocks * samplesPerBlock;
+                if (leftoverSamples < 2) // a block always starts with at least two samples?
+                    Console.Error.WriteLine("Improper trailing bytes/samples!");
+                if (bitsPerSample != 4) // are MS ADPCM nibbles always 4-bit-sized?
+                    Console.Error.WriteLine("Nibble size is expected to be 4 bits!");
+                int leftoverNibbles = (leftoverSamples - 2) * channelCount;
+                int leftoverBytes = 7 * channelCount
+                    + (int)Math.Ceiling((leftoverNibbles * bitsPerSample) * 0.125);
+                Array.Resize(ref soundData, wholeBlocks * blockAlign + leftoverBytes);
             }
         }
@@ -106,4 +116,5 @@
         public int BlockAlign => blockAlign;
         public int BitsPerSample => bitsPerSample;
+        public int SampleCount => sampleCount;
         public byte[] ExtraData => extraData;
         public byte[] SoundData => soundData;
Index: /OniSplit/Sound/WavImporter.cs
===================================================================
--- /OniSplit/Sound/WavImporter.cs	(revision 1155)
+++ /OniSplit/Sound/WavImporter.cs	(revision 1156)
@@ -46,8 +46,5 @@
         private void WriteSNDD(string name, WavFile wav)
         {
-            float duration = wav.SoundData.Length * 8.0f / wav.BitsPerSample;
-            duration /= wav.SampleRate;
-            duration /= wav.ChannelCount;
-            duration *= 60.0f;
+            float duration = wav.SampleCount * 60.0f / wav.SampleRate;
 
             var sndd = CreateInstance(TemplateTag.SNDD, name);
@@ -74,4 +71,5 @@
                     writer.Write(wav.SoundData.Length);
                     writer.Write(WriteRawPart(wav.SoundData));
+                    writer.Skip(8);
                 }
             }
@@ -97,4 +95,5 @@
                     writer.Write(wav.SoundData.Length);
                     writer.Write(WriteRawPart(wav.SoundData));
+                    writer.Skip(24);
                 }
             }
