1. public static void MixStereoToMono()
  2. {
  3. byte[] input = File.ReadAllBytes("options.wav");
  4. byte[] output = new byte[input.Length / 2];
  5. int outputIndex = 0;
  6. for (int n = 0; n < input.Length; n += 4)
  7. {
  8. int leftChannel = BitConverter.ToInt16(input, n);
  9. int rightChannel = BitConverter.ToInt16(input, n + 2);
  10. int mixed = (leftChannel + rightChannel) / 2;
  11. byte[] outSample = BitConverter.GetBytes((short)mixed);
  12. // copy in the first 16 bit sample
  13. output[outputIndex++] = outSample[0];
  14. output[outputIndex++] = outSample[1];
  15. }
  16. File.WriteAllBytes("options1.wav", output);
  17. }