From da84f3d5eff380df7c20337cbe878b39f1805ea4 Mon Sep 17 00:00:00 2001 From: RoosterDragon Date: Sun, 27 Dec 2015 00:05:28 +0000 Subject: [PATCH] Allow AUD file with sample rates other than 22050 Hz. --- OpenRA.Game/FileFormats/AudLoader.cs | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/OpenRA.Game/FileFormats/AudLoader.cs b/OpenRA.Game/FileFormats/AudLoader.cs index d7f7bfc9f5..847223a85d 100644 --- a/OpenRA.Game/FileFormats/AudLoader.cs +++ b/OpenRA.Game/FileFormats/AudLoader.cs @@ -45,7 +45,6 @@ namespace OpenRA.FileFormats public class AudLoader : ISoundLoader { - static readonly int ExpectedSampleRate = 22050; static readonly int[] IndexAdjust = { -1, -1, -1, -1, 2, 4, 6, 8 }; static readonly int[] StepTable = { @@ -119,19 +118,16 @@ namespace OpenRA.FileFormats return samples / sampleRate; } - public static bool LoadSound(Stream s, out byte[] rawData) + public static bool LoadSound(Stream s, out byte[] rawData, out int sampleRate) { rawData = null; - var sampleRate = s.ReadUInt16(); + sampleRate = s.ReadUInt16(); var dataSize = s.ReadInt32(); var outputSize = s.ReadInt32(); var readFlag = s.ReadByte(); var readFormat = s.ReadByte(); - if (sampleRate != ExpectedSampleRate) - return false; - if (!Enum.IsDefined(typeof(SoundFlags), readFlag)) return false; @@ -177,7 +173,7 @@ namespace OpenRA.FileFormats try { - if (!LoadSound(stream, out rawData)) + if (!LoadSound(stream, out rawData, out sampleRate)) return false; } catch (Exception e) @@ -194,7 +190,6 @@ namespace OpenRA.FileFormats channels = 1; sampleBits = 16; - sampleRate = ExpectedSampleRate; return true; }