public static StreamInfoRecord Read(BinaryReader r) { var record = new StreamInfoRecord(); record.fatId = r.ReadUInt16(); r.Skip(2); record.vol = r.ReadByte(); record.priority = r.ReadByte(); record.player = r.ReadByte(); record.forceStereo = r.ReadBoolean(); return(record); }
private void parseInfo(Stream stream) { using (var r = new BinaryReader(stream)) { var sig = r.Read4C(); if (sig != "INFO") { throw new InvalidDataException("INFO signature is wrong"); } var internalSize = r.ReadUInt32(); if (internalSize != stream.Length) { throw new InvalidDataException("INFO block size is wrong!"); } const int subsectionCount = 8; var subSectionPositions = r.ReadUInt32Array(subsectionCount); List <UInt32> ReadInfoRecordPtrTable(int subsectionIndex) { stream.Position = subSectionPositions[subsectionIndex]; var recordCount = r.ReadUInt32(); return(r.ReadUInt32Array((int)recordCount)); } using (var subReader = new BinaryReader(new SubStream(stream, 0))) { List <uint> recordPositions = ReadInfoRecordPtrTable(0); sequenceInfo = new List <SequenceInfoRecord>(recordPositions.Count); foreach (var position in recordPositions) { if (position == 0) { sequenceInfo.Add(null); continue; } subReader.BaseStream.Position = position; var record = SequenceInfoRecord.Read(subReader); sequenceInfo.Add(record); } } using (var subReader = new BinaryReader(new SubStream(stream, 0))) { List <uint> recordPositions = ReadInfoRecordPtrTable(2); bankInfo = new List <BankInfoRecord>(recordPositions.Count); foreach (var position in recordPositions) { if (position == 0) { bankInfo.Add(null); continue; } subReader.BaseStream.Position = position; var record = BankInfoRecord.Read(subReader); bankInfo.Add(record); } } using (var subReader = new BinaryReader(new SubStream(stream, 0))) { List <uint> recordPositions = ReadInfoRecordPtrTable(3); waveArchiveInfo = new List <WaveArchiveInfoRecord>(recordPositions.Count); foreach (var position in recordPositions) { if (position == 0) { waveArchiveInfo.Add(null); continue; } subReader.BaseStream.Position = position; WaveArchiveInfoRecord record = WaveArchiveInfoRecord.Read(subReader); waveArchiveInfo.Add(record); } } using (var subReader = new BinaryReader(new SubStream(stream, 0))) { List <uint> recordPositions = ReadInfoRecordPtrTable(4); playerInfo = new List <PlayerInfoRecord>(recordPositions.Count); foreach (var position in recordPositions) { if (position == 0) { playerInfo.Add(null); continue; } subReader.BaseStream.Position = position; PlayerInfoRecord record = PlayerInfoRecord.Read(subReader); playerInfo.Add(record); } } using (var subReader = new BinaryReader(new SubStream(stream, 0))) { List <uint> recordPositions = ReadInfoRecordPtrTable(5); groupInfo = new List <GroupInfoRecord>(recordPositions.Count); foreach (var position in recordPositions) { if (position == 0) { groupInfo.Add(null); continue; } subReader.BaseStream.Position = position; GroupInfoRecord record = GroupInfoRecord.Read(subReader); groupInfo.Add(record); } } using (var subReader = new BinaryReader(new SubStream(stream, 0))) { List <uint> recordPositions = ReadInfoRecordPtrTable(7); streamInfo = new List <StreamInfoRecord>(recordPositions.Count); foreach (var position in recordPositions) { if (position == 0) { streamInfo.Add(null); continue; } subReader.BaseStream.Position = position; StreamInfoRecord record = StreamInfoRecord.Read(subReader); streamInfo.Add(record); } } } }