- public static void MixStereoToMono()
- {
- byte[] input = File.ReadAllBytes("options.wav");
- byte[] output = new byte[input.Length / 2];
- int outputIndex = 0;
- for (int n = 0; n < input.Length; n += 4)
- {
- int leftChannel = BitConverter.ToInt16(input, n);
- int rightChannel = BitConverter.ToInt16(input, n + 2);
- int mixed = (leftChannel + rightChannel) / 2;
- byte[] outSample = BitConverter.GetBytes((short)mixed);
-
- // copy in the first 16 bit sample
- output[outputIndex++] = outSample[0];
- output[outputIndex++] = outSample[1];
- }
- File.WriteAllBytes("options1.wav", output);
- }