Let the game determine song length.

This commit is contained in:
Paul Chote
2010-09-10 20:24:22 +12:00
parent b8ed9d7da5
commit 190311c68c
5 changed files with 49 additions and 96 deletions

View File

@@ -102,6 +102,20 @@ namespace OpenRA.FileFormats
return output;
}
public static float SoundLength(Stream s)
{
var br = new BinaryReader(s);
var sampleRate = br.ReadUInt16();
/*var dataSize = */ br.ReadInt32();
var outputSize = br.ReadInt32();
var flags = (SoundFlags) br.ReadByte();
var samples = outputSize;
if (0 != (flags & SoundFlags.Stereo)) samples /= 2;
if (0 != (flags & SoundFlags._16Bit)) samples /= 2;
return samples / sampleRate;
}
public static byte[] LoadSound(Stream s)
{
var br = new BinaryReader(s);