예제 #1
0
        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);
            }
        }
예제 #2
0
        public MusicMode(MusicEntry entry, BinaryReader binaryReader, int index)
        {
            Offset   = entry.Offset + binaryReader.ReadUInt32At(entry.TableOffset + entry.SliceCount * 0x04 + index * 0x04);
            Version  = binaryReader.ReadByteAt(Offset);
            Size     = binaryReader.ReadUInt16At(Offset + 0x02);
            NameSize = binaryReader.ReadByteAt(Offset + 0x06);

            if (Version <= 2)
            {
                NameOffset = Offset + 0x20;
                NameSize   = 0x0f;
            }
            else
            {
                NameOffset = Offset + Size;
            }

            Name = Encoding.ASCII.GetString(binaryReader.ReadBytesAt(NameOffset, NameSize));
        }
예제 #3
0
        protected override void ParseSections(BinaryReader reader)
        {
            MusicSectionOffset      = InnerFileStartOffset + GetSectionDeclaration(Magic_Musc).OffsetInInnerFile;
            InstrumentSectionOffset = InnerFileStartOffset + GetSectionDeclaration(Magic_Inst).OffsetInInnerFile;


            var trackEntryCount = reader.ReadUInt16At(MusicSectionOffset + 0x04);

            for (int entryIndex = 0; entryIndex < trackEntryCount; entryIndex++)
            {
                var entry = new MusicEntry(this, reader, entryIndex);
                Entries.Add(entry);
            }

            var instrumentEntryCount = reader.ReadUInt16At(InstrumentSectionOffset + 0x04);

            for (int instrumentIndex = 0; instrumentIndex < instrumentEntryCount; instrumentIndex++)
            {
                var instrument = new MusicInstrument(this, reader, instrumentIndex);
                Instruments.Add(instrument);
            }

            AddMaterialUsers();
        }