diff --git a/OpenRA.Game/FileFormats/AdpcmLoader.cs b/OpenRA.Game/FileFormats/ImaAdpcmLoader.cs similarity index 78% rename from OpenRA.Game/FileFormats/AdpcmLoader.cs rename to OpenRA.Game/FileFormats/ImaAdpcmLoader.cs index 98fecdebc8..7eed094652 100644 --- a/OpenRA.Game/FileFormats/AdpcmLoader.cs +++ b/OpenRA.Game/FileFormats/ImaAdpcmLoader.cs @@ -13,14 +13,14 @@ using System.IO; namespace OpenRA.FileFormats { - struct AdpcmChunk + struct ImaAdpcmChunk { public int CompressedSize; public int OutputSize; - public static AdpcmChunk Read(Stream s) + public static ImaAdpcmChunk Read(Stream s) { - AdpcmChunk c; + ImaAdpcmChunk c; c.CompressedSize = s.ReadUInt16(); c.OutputSize = s.ReadUInt16(); if (s.ReadUInt32() != 0xdeaf) @@ -29,7 +29,7 @@ namespace OpenRA.FileFormats } } - public static class AdpcmLoader + public static class ImaAdpcmLoader { static readonly int[] indexAdjust = { -1, -1, -1, -1, 2, 4, 6, 8 }; static readonly int[] stepTable = @@ -46,7 +46,7 @@ namespace OpenRA.FileFormats 16818, 18500, 20350, 22385, 24623, 27086, 29794, 32767 }; - static short DecodeAdpcmSample(byte b, ref int index, ref int current) + static short DecodeImaAdpcmSample(byte b, ref int index, ref int current) { var sb = (b & 8) != 0; b &= 7; @@ -65,13 +65,13 @@ namespace OpenRA.FileFormats return (short)current; } - public static byte[] LoadAdpcmSound(byte[] raw, ref int index) + public static byte[] LoadImaAdpcmSound(byte[] raw, ref int index) { var currentSample = 0; - return LoadAdpcmSound(raw, ref index, ref currentSample); + return LoadImaAdpcmSound(raw, ref index, ref currentSample); } - public static byte[] LoadAdpcmSound(byte[] raw, ref int index, ref int currentSample) + public static byte[] LoadImaAdpcmSound(byte[] raw, ref int index, ref int currentSample) { var s = new MemoryStream(raw); var dataSize = raw.Length; @@ -84,11 +84,11 @@ namespace OpenRA.FileFormats { var b = s.ReadUInt8(); - var t = DecodeAdpcmSample(b, ref index, ref currentSample); + var t = DecodeImaAdpcmSample(b, ref index, ref currentSample); output[offset++] = (byte)t; output[offset++] = (byte)(t >> 8); - t = DecodeAdpcmSample((byte)(b >> 4), ref index, ref currentSample); + t = DecodeImaAdpcmSample((byte)(b >> 4), ref index, ref currentSample); output[offset++] = (byte)t; output[offset++] = (byte)(t >> 8); } diff --git a/OpenRA.Game/FileFormats/WavLoader.cs b/OpenRA.Game/FileFormats/WavLoader.cs index ea44596ac1..f718f42bc8 100644 --- a/OpenRA.Game/FileFormats/WavLoader.cs +++ b/OpenRA.Game/FileFormats/WavLoader.cs @@ -30,7 +30,7 @@ namespace OpenRA.FileFormats public readonly int DataSize; public readonly byte[] RawOutput; - public enum WaveType { Pcm = 0x1, Adpcm = 0x11 }; + public enum WaveType { Pcm = 0x1, ImaAdpcm = 0x11 }; public static WaveType Type { get; private set; } public WavLoader(Stream s) @@ -53,7 +53,7 @@ namespace OpenRA.FileFormats FmtChunkSize = s.ReadInt32(); AudioFormat = s.ReadInt16(); Type = (WaveType)AudioFormat; - if (Type != WaveType.Pcm && Type != WaveType.Adpcm) + if (Type != WaveType.Pcm && Type != WaveType.ImaAdpcm) throw new NotSupportedException("Compression type is not supported."); Channels = s.ReadInt16(); SampleRate = s.ReadInt32(); @@ -84,9 +84,9 @@ namespace OpenRA.FileFormats } } - if (Type == WaveType.Adpcm) + if (Type == WaveType.ImaAdpcm) { - RawOutput = DecodeAdpcmData(); + RawOutput = DecodeImaAdpcmData(); BitsPerSample = 16; } } @@ -110,7 +110,7 @@ namespace OpenRA.FileFormats return length / (channels * sampleRate * bitsPerSample); } - public byte[] DecodeAdpcmData() + public byte[] DecodeImaAdpcmData() { var s = new MemoryStream(RawOutput); @@ -124,7 +124,7 @@ namespace OpenRA.FileFormats var predictor = new int[Channels]; var index = new int[Channels]; - // Decode each block of ADPCM data in RawOutput + // Decode each block of IMA ADPCM data in RawOutput for (var block = 0; block < numBlocks; block++) { // Each block starts with a initial state per-channel @@ -150,7 +150,7 @@ namespace OpenRA.FileFormats { // Decode 4 bytes (to 16 bytes of output) per channel var chunk = s.ReadBytes(4); - var decoded = AdpcmLoader.LoadAdpcmSound(chunk, ref index[c], ref predictor[c]); + var decoded = ImaAdpcmLoader.LoadImaAdpcmSound(chunk, ref index[c], ref predictor[c]); // Interleave output, one sample per channel var outOffsetChannel = outOffset + (2 * c); diff --git a/OpenRA.Game/OpenRA.Game.csproj b/OpenRA.Game/OpenRA.Game.csproj index 626be20eaf..e34a8dba7e 100644 --- a/OpenRA.Game/OpenRA.Game.csproj +++ b/OpenRA.Game/OpenRA.Game.csproj @@ -261,7 +261,7 @@ - +