#region License
#endregion
#region Using Statements
using
System.IO;
using
Microsoft.Xna.Framework.Audio;
#endregion
namespace
Microsoft.Xna.Framework.Content
{
internal
class
SoundEffectReader : ContentTypeReader<SoundEffect>
{
#region Private Supported File Extensions Variable
static
string
[] supportedExtensions =
new
string
[] {
".wav"
};
#endregion
#region Internal Filename Normalizer Method
internal
static
string
Normalize(
string
fileName)
{
return
Normalize(fileName, supportedExtensions);
}
#endregion
#region Protected Read Method
protected
internal
override
SoundEffect Read(
ContentReader input,
SoundEffect existingInstance
) {
uint
formatLength = input.ReadUInt32();
ushort
format = input.ReadUInt16();
ushort
channels = input.ReadUInt16();
uint
sampleRate = input.ReadUInt32();
input.ReadUInt32();
ushort
blockAlign = input.ReadUInt16();
ushort
bitDepth = input.ReadUInt16();
input.ReadUInt16();
input.BaseStream.Seek(formatLength - 18, SeekOrigin.Current);
byte
[] data = input.ReadBytes(input.ReadInt32());
uint
loopStart = input.ReadUInt32();
uint
loopLength = input.ReadUInt32();
input.ReadUInt32();
return
new
SoundEffect(
input.AssetName,
data,
sampleRate,
channels,
loopStart,
loopLength,
format == 2,
(
uint
) ((format == 2) ? (((blockAlign / channels) - 6) * 2) : (bitDepth / 16))
);
}
#endregion
}
}