public MusicInstrument(MusicAudioBinaryFile file, BinaryReader binaryReader, int entryIndex) { Offset = file.InstrumentSectionOffset + binaryReader.ReadUInt32At(file.InstrumentSectionOffset + 0x10 + entryIndex * 0x04); Version = binaryReader.ReadByteAt(Offset); UnknownAt1 = binaryReader.ReadByteAt(Offset + 1); Size = binaryReader.ReadUInt16At(Offset + 2); Type = binaryReader.ReadByteAt(Offset + 4); var materialCount = binaryReader.ReadByteAt(Offset + 0x05); Category = binaryReader.ReadByteAt(Offset + 0x06); Priority = binaryReader.ReadByteAt(Offset + 0x07); UnknownAt8 = binaryReader.ReadUInt16At(Offset + 0x08); Flags = binaryReader.ReadByteAt(Offset + 0x0a); DistanceAttenuationCurve = binaryReader.ReadByteAt(Offset + 0x0b); InteriorFactor = binaryReader.ReadFloatAt(Offset + 0x0c); AudibleRange = binaryReader.ReadFloatAt(Offset + 0x10); InnerRange = binaryReader.ReadFloatAt(Offset + 0x14); PlayLength = binaryReader.ReadFloatAt(Offset + 0x18); NameOffset = Offset + 0x30; NameSize = 15; Name = Encoding.ASCII.GetString(binaryReader.ReadBytesAt(NameOffset, NameSize)); var materialOffset = NameOffset + NameSize + 0x01; for (int materialIndex = 0; materialIndex < materialCount; materialIndex++) { var material = new MusicInstrumentMaterial(); material.Read(binaryReader, materialOffset); materialOffset += material.MaterialSize; } }
public MusicSlice(BinaryReader binaryReader, MusicAudioBinaryFile file, MusicEntry entry, int sliceIndex) { Index = sliceIndex; Offset = entry.Offset + binaryReader.ReadUInt32At(entry.TableOffset + sliceIndex * 0x04); Version = binaryReader.ReadByteAt(Offset); Size = binaryReader.ReadUInt16At(Offset + 0x02); int layerCount; if (Version <= 7) { /* 0x04: meter count */ layerCount = binaryReader.ReadByteAt(Offset + 0x05); CustomPointsCount = binaryReader.ReadUInt16At(Offset + 0x06); EntryPointsSample = binaryReader.ReadUInt32At(Offset + 0x08); ExitPointsSample = binaryReader.ReadUInt32At(Offset + 0x0c); LoopStart = binaryReader.ReadUInt32At(Offset + 0x10); LoopEnd = binaryReader.ReadUInt32At(Offset + 0x14); /* 0x18+: meter transition timing info (offsets, points, curves, etc) */ NameOffset = 0x30; NameSize = 0x0f; SubTableOffset = Offset + Size; } else { NameSize = binaryReader.ReadByteAt(Offset + 0x04); layerCount = binaryReader.ReadByteAt(Offset + 0x05); CustomPointsCount = binaryReader.ReadUInt16At(Offset + 0x06); EntryPointsSample = binaryReader.ReadUInt32At(Offset + 0x08); ExitPointsSample = binaryReader.ReadUInt32At(Offset + 0x0c); LoopStart = binaryReader.ReadUInt32At(Offset + 0x10); LoopEnd = binaryReader.ReadUInt32At(Offset + 0x14); MeterCount = binaryReader.ReadUInt32At(Offset + 0x18); /* 0x18: meter count */ /* 0x1c+: meter transition timing info (offsets, points, curves, etc) */ NameOffset = Offset + Size; SubTableOffset = file.AlignToBlockStart(NameOffset + NameSize + 0x0f); } Name = Encoding.ASCII.GetString(binaryReader.ReadBytesAt(NameOffset, NameSize)); for (int layerIndex = 0; layerIndex < layerCount; layerIndex++) { var musicSectionlayer = new MusicLayer(); musicSectionlayer.Read(binaryReader, this, layerIndex); Layers.Add(musicSectionlayer); } }
public MusicEntry(MusicAudioBinaryFile file, BinaryReader binaryReader, int entryIndex) { Index = entryIndex; Offset = file.MusicSectionOffset + binaryReader.ReadUInt32At(file.MusicSectionOffset + 0x10 + entryIndex * 0x04); Version = binaryReader.ReadByteAt(Offset); Flags = binaryReader.ReadByte(); Size = binaryReader.ReadUInt16(); SliceCount = binaryReader.ReadByte(); ModeCount = binaryReader.ReadByte(); NameSize = binaryReader.ReadByteAt(Offset + 0x48); if (Version <= 8) { NameOffset = Offset + 0x10; Size = 0x0f; } else { NameOffset = Offset + Size; } Name = Encoding.ASCII.GetString(binaryReader.ReadBytesAt(NameOffset, NameSize)); TableOffset = file.AlignToBlockStart(NameOffset + NameSize + 0x0f); for (int sliceIndex = 0; sliceIndex < SliceCount; sliceIndex++) { var slice = new MusicSlice(binaryReader, file, this, sliceIndex); Slices.Add(slice); } for (int modeIndex = 0; modeIndex < ModeCount; modeIndex++) { var section = new MusicMode(this, binaryReader, modeIndex); Modes.Add(section); } }