private byte[] GetAudioFrom(uint InstanceID, DBPFFile dbpf)
{
if (InstanceID == 0)
return null;
//all game sfx has type id 0x2026960B
byte[] dat = dbpf.GetItemByID((ulong)DBPFTypeID.SoundFX + (((ulong)InstanceID)<<32));
if (dat != null)
{
string head = new string(new char[] { (char)dat[0], (char)dat[1], (char)dat[2], (char)dat[3] });
if (head.StartsWith("XA"))
return new XAFile(dat).DecompressedData;
else if (head.StartsWith("UTM0"))
{
var utk = new UTKFile2(dat);
utk.UTKDecode();
return utk.DecompressedWav;
}
else
return dat; //either wav or mp3.
}
else
Debug.WriteLine("Couldn't find sound!");
return null;
}