public static Chunk Parse(Stream stream) { try { BinaryReader br = new BinaryReader(stream); int ctype = br.ReadInt32(); int length = br.ReadInt32(); length = StaticFunc.ConvertHostorder(length); byte[] buffer = br.ReadBytes(length); int cval = StaticFunc.ConvertHostorder(ctype); switch (StaticFunc.ConvertHostorder(ctype)) { case 0x4d546864: return(new Header(ctype, length, buffer)); case 0x4d54726b: return(new Track(ctype, length, buffer)); } return(new Chunk(ctype, length, buffer)); } catch { return(null); } }