Index: /OniSplit/Program.cs
===================================================================
--- /OniSplit/Program.cs	(revision 1153)
+++ /OniSplit/Program.cs	(revision 1154)
@@ -844,5 +844,5 @@
                 case ".wav":
                     if (task.Type == TemplateTag.NONE || task.Type == TemplateTag.SNDD)
-                        importer = new WavImporter();
+                        importer = new WavImporter(args.Any(a => a == "-demo"));
                     break;
 
Index: /OniSplit/Sound/WavExporter.cs
===================================================================
--- /OniSplit/Sound/WavExporter.cs	(revision 1153)
+++ /OniSplit/Sound/WavExporter.cs	(revision 1154)
@@ -154,15 +154,18 @@
             using (var writer = new BinaryWriter(stream))
             {
-                var blockSizeADPCM = 512 * sound.ChannelCount * sound.SampleRate / 22050;
+                var blockSizeADPCM = sound.BlockAlignment;
+                
                 int wholeBlocks = sound.Data.Length / blockSizeADPCM;
                 int leftoverBytes = sound.Data.Length - (wholeBlocks * blockSizeADPCM);
-                int leftoverSamples = 8 * (leftoverBytes - 7 * sound.ChannelCount)
-                                      / 4 / sound.ChannelCount + 2; // 4 bits per sample
+                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 / 4;
-
-                Int32 sampleCount = sampleCount = wholeBlocks * samplesPerBlock + leftoverSamples;
+                var samplesPerBlock = 2 + (blockSizeADPCM - sound.ChannelCount * 7) * 8 / sound.ChannelCount / sound.BitsPerSample;
+
+                Int32 sampleCount = wholeBlocks * samplesPerBlock + leftoverSamples;
 
                 if (sound.IsIMA4) // IMA4 ADPCM format
Index: /OniSplit/Sound/WavFile.cs
===================================================================
--- /OniSplit/Sound/WavFile.cs	(revision 1153)
+++ /OniSplit/Sound/WavFile.cs	(revision 1154)
@@ -2,4 +2,5 @@
 using System.Collections.Generic;
 using System.IO;
+//using System.Runtime.Remoting.Metadata.W3cXsd2001;
 
 namespace Oni.Sound
@@ -10,5 +11,6 @@
         private const int fcc_RIFF = 0x46464952;
         private const int fcc_WAVE = 0x45564157;
-        private const int fcc_fmt = 0x20746d66;
+        private const int fcc_fmt  = 0x20746d66;
+        private const int fcc_fact = 0x74636166;
         private const int fcc_data = 0x61746164;
 
@@ -19,4 +21,5 @@
         private int blockAlign;
         private int bitsPerSample;
+        private int sampleCount;
         private byte[] extraData;
         private byte[] soundData;
@@ -35,5 +38,8 @@
                     throw new InvalidDataException("Not a WAV file");
 
-                var header = new WavFile();
+                var header = new WavFile()
+                {
+                    sampleCount = 0
+                };
 
                 for (int chunkType, chunkSize, chunkStart; reader.Position < size; reader.Position = chunkStart + chunkSize)
@@ -45,8 +51,11 @@
                     if (chunkType == fcc_fmt)
                         header.ReadFormatChunk(reader, chunkSize);
-                    else if (chunkType == fcc_data)
+                    if (chunkType == fcc_fact)
+                        header.ReadFactChunk(reader, chunkSize);
+                    if (chunkType == fcc_data)
                         header.ReadDataChunk(reader, chunkSize);
                 }
 
+                header.ValidateSampleCount();
                 return header;
             }
@@ -68,7 +77,25 @@
         }
 
+        private void ReadFactChunk(BinaryReader reader, int chunkSize)
+        {
+            sampleCount = reader.ReadInt32();
+        }
+
         private void ReadDataChunk(BinaryReader reader, int chunkSize)
         {
             soundData = reader.ReadBytes(chunkSize);
+        }
+        private void ValidateSampleCount() // TODO: ACTUAL VALIDATION/CORRECTION
+        {
+            int sampleCountFromData = 0;
+            int wholeBlocks = soundData.Length / blockAlign;
+            if(sampleCount == 0) // not explicitly set (no fact chunk present)
+            {
+                Console.WriteLine("The imported WAV file has no FACT chunk.");
+            }
+            else // TODO: calculate sampleCountFromData, compare with sampleCount
+            {
+
+            }
         }
 
Index: /OniSplit/Sound/WavImporter.cs
===================================================================
--- /OniSplit/Sound/WavImporter.cs	(revision 1153)
+++ /OniSplit/Sound/WavImporter.cs	(revision 1154)
@@ -6,4 +6,12 @@
     internal class WavImporter : Importer
     {
+        private readonly bool convertToDemo;
+
+        public WavImporter(bool toDemo)
+            : base(toDemo?InstanceFileHeader.OniMacTemplateChecksum:InstanceFileHeader.OniPCTemplateChecksum)
+        {
+            convertToDemo = toDemo;
+        }
+
         public override void Import(string filePath, string outputDirPath)
         {
@@ -44,19 +52,50 @@
 
             var sndd = CreateInstance(TemplateTag.SNDD, name);
+            if (convertToDemo)
+            {
+                // TODO: also validate other ADPCM parameters (coefficient table)?
+                if (wav.Format != WavFormat.Adpcm) // Or is PCM supported, actually?
+                    Console.WriteLine("Cannot convert to PC demo: ADPCM format required!");
+                if (wav.SampleRate != 22050)
+                    Console.WriteLine("Cannot convert to PC demo: 22050 kHz required!");
+                if (wav.BlockAlign != 512 * wav.ChannelCount)
+                    Console.WriteLine("Cannot convert to PC demo: wrong block alignment!");
+                if (wav.BitsPerSample != 4)
+                    Console.WriteLine("Cannot convert to PC demo: wrong bits per sample!");
 
-            using (var writer = sndd.OpenWrite(8))
+                using (var writer = sndd.OpenWrite())
+                {
+                    if (wav.ChannelCount == 2)
+                        writer.WriteInt16(3);
+                    else 
+                        writer.WriteInt16(1);
+                    writer.WriteInt16(0);
+                    writer.Write((int)duration);
+                    writer.Write(wav.SoundData.Length);
+                    writer.Write(WriteRawPart(wav.SoundData));
+                }
+            }
+            else
             {
-                writer.Write((short)wav.Format);
-                writer.WriteInt16(wav.ChannelCount);
-                writer.Write(wav.SampleRate);
-                writer.Write(wav.AverageBytesPerSecond);
-                writer.WriteInt16(wav.BlockAlign);
-                writer.WriteInt16(wav.BitsPerSample);
-                writer.WriteInt16(wav.ExtraData.Length);
-                writer.Write(wav.ExtraData);
-                writer.Skip(32 - wav.ExtraData.Length);
-                writer.Write((short)duration);
-                writer.Write(wav.SoundData.Length);
-                writer.Write(WriteRawPart(wav.SoundData));
+                using (var writer = sndd.OpenWrite())
+                {
+                    if (wav.Format == WavFormat.Adpcm)
+                        writer.WriteInt16(8);
+                    else
+                        writer.WriteInt16(0);
+                    writer.WriteInt16(0);
+                    writer.Write((short)wav.Format);
+                    writer.WriteInt16(wav.ChannelCount);
+                    writer.Write(wav.SampleRate);
+                    writer.Write(wav.AverageBytesPerSecond);
+                    writer.WriteInt16(wav.BlockAlign);
+                    writer.WriteInt16(wav.BitsPerSample);
+                    writer.WriteInt16(wav.ExtraData.Length);
+                    writer.Write(wav.ExtraData);
+                    writer.Skip(32 - wav.ExtraData.Length);
+                    writer.Write((short)duration);
+                    writer.Write(wav.SoundData.Length);
+                    writer.Write(WriteRawPart(wav.SoundData));
+                }
             }
         }
