diff --git a/OpenRA.Mods.Cnc/AudioLoaders/AudLoader.cs b/OpenRA.Mods.Cnc/AudioLoaders/AudLoader.cs index c72ed35f0c..3cad70667f 100644 --- a/OpenRA.Mods.Cnc/AudioLoaders/AudLoader.cs +++ b/OpenRA.Mods.Cnc/AudioLoaders/AudLoader.cs @@ -49,7 +49,7 @@ namespace OpenRA.Mods.Cnc.AudioLoaders public sealed class AudFormat : ISoundFormat { - public int Channels { get { return 1; } } + public int Channels { get { return channels; } } public int SampleBits { get { return sampleBits; } } public int SampleRate { get { return sampleRate; } } public float LengthInSeconds { get { return AudReader.SoundLength(sourceStream); } } @@ -58,6 +58,7 @@ namespace OpenRA.Mods.Cnc.AudioLoaders readonly Stream sourceStream; readonly Func audStreamFactory; + readonly int channels; readonly int sampleBits; readonly int sampleRate; @@ -65,7 +66,7 @@ namespace OpenRA.Mods.Cnc.AudioLoaders { sourceStream = stream; - if (!AudReader.LoadSound(stream, out audStreamFactory, out sampleRate, out sampleBits)) + if (!AudReader.LoadSound(stream, out audStreamFactory, out sampleRate, out sampleBits, out channels)) throw new InvalidDataException(); } } diff --git a/OpenRA.Mods.Cnc/FileFormats/AudReader.cs b/OpenRA.Mods.Cnc/FileFormats/AudReader.cs index 467defdc36..977df37b78 100644 --- a/OpenRA.Mods.Cnc/FileFormats/AudReader.cs +++ b/OpenRA.Mods.Cnc/FileFormats/AudReader.cs @@ -49,7 +49,7 @@ namespace OpenRA.Mods.Cnc.FileFormats return (float)samples / sampleRate; } - public static bool LoadSound(Stream s, out Func result, out int sampleRate, out int sampleBits) + public static bool LoadSound(Stream s, out Func result, out int sampleRate, out int sampleBits, out int channels) { result = null; var startPosition = s.Position; @@ -60,6 +60,7 @@ namespace OpenRA.Mods.Cnc.FileFormats var outputSize = s.ReadInt32(); var readFlag = s.ReadByte(); sampleBits = (readFlag & (int)SoundFlags._16Bit) == 0 ? 8 : 16; + channels = (readFlag & (int)SoundFlags.Stereo) == 0 ? 1 : 2; var readFormat = s.ReadByte(); if (!Enum.IsDefined(typeof(SoundFormat), readFormat))