/// <summary>
/// Decodes the ogg-vorbis file
/// </summary>
/// <param name="input">Stream of the ogg-vorbis file</param>
/// <returns>PCM-Wave version of the input</returns>
public WaveFile Decode(Stream input)
{
MemoryStream output = new MemoryStream();
WaveFile wf = new WaveFile();
VorbisFile vf = new VorbisFile((FileStream)input, null, 0);
Info inf = vf.getInfo(-1);
wf.Channels = (short)inf.channels;
wf.Frequency = inf.rate;
wf.Bits = 16;
Axiom.Core.LogManager.Instance.Write("SoundSystem: File is Ogg Vorbis "+inf.version.ToString()+" "+inf.rate.ToString()+"Hz, "+inf.channels.ToString()+" channels");
int bufferlen = 4096;
int result = 1;
byte[] buffer = new byte[bufferlen];
int[] section = new int[1];
while(result != 0)
{
result = vf.read(buffer, bufferlen, 0, 2, 1, section);
output.Write(buffer, 0, result);
}
output.Seek(0, SeekOrigin.Begin);
wf.Data = output;
return wf;
}