Beispiel #1
0
        /// <summary>
        /// Read the file.
        /// </summary>
        /// <param name="br">The reader.</param>
        public override void Read(BinaryDataReader br)
        {
            //Set up helper.
            ReadHelper r = new ReadHelper(br);

            //Read header.
            ReadMagic(br);
            ReadByteOrder(br);
            ReadVersion(br);

            //String table offset.
            int strgOffset = br.ReadInt32();

            //Asset name offset.
            int assetOffset = br.ReadInt32();

            //Get datas.
            VolumeCurveType = (CurveType)br.ReadUInt32();
            int volOffset = br.ReadInt32();

            EnvFxCurveType = (CurveType)br.ReadUInt32();
            int envFxOffset = br.ReadInt32();

            FilterCurveType = (CurveType)br.ReadUInt32();
            int filterOffset = br.ReadInt32();

            SpreadCurveType = (CurveType)br.ReadUInt32();
            int spreadOffset = br.ReadInt32();

            PriorityCurveType = (CurveType)br.ReadUInt32();
            int priorityOffset = br.ReadInt32();

            //Culling name.
            int cullingOffset = br.ReadInt32();

            //Bools.
            ListenerEnabled  = br.ReadUInt32() > 0;
            OcclusionEnabled = br.ReadUInt32() > 0;

            //Read strings.
            r.JumpToOffset(br, strgOffset + assetOffset);
            AssetName = r.ReadNullTerminated(br);
            r.JumpToOffset(br, strgOffset + volOffset);
            VolumeCurveFile = r.ReadNullTerminated(br);
            r.JumpToOffset(br, strgOffset + envFxOffset);
            EnvFxCurveFile = r.ReadNullTerminated(br);
            r.JumpToOffset(br, strgOffset + filterOffset);
            FilterCurveFile = r.ReadNullTerminated(br);
            r.JumpToOffset(br, strgOffset + spreadOffset);
            SpreadCurveFile = r.ReadNullTerminated(br);
            r.JumpToOffset(br, strgOffset + priorityOffset);
            PriorityCurveFile = r.ReadNullTerminated(br);
            r.JumpToOffset(br, strgOffset + cullingOffset);
            CullingName = r.ReadNullTerminated(br);
        }
Beispiel #2
0
        /// <summary>
        /// Read a string entry.
        /// </summary>
        /// <param name="br">The reader.</param>
        /// <param name="r">The reader helper.</param>
        /// <param name="strgOffset">String table offset.</param>
        /// <param name="stringOffset">Offset from string table to string.</param>
        /// <returns>The string.</returns>
        public string ReadString(BinaryDataReader br, ReadHelper r, int strgOffset, int stringOffset)
        {
            //Read the string data.
            long bakPos = br.Position;

            r.JumpToOffset(br, strgOffset + 8 + stringOffset);
            string x = r.ReadNullTerminated(br);

            br.Position = bakPos;
            return(x);
        }
        /// <summary>
        /// Read the file.
        /// </summary>
        /// <param name="br">The reader.</param>
        public override void Read(BinaryDataReader br)
        {
            //Read magic.
            ReadMagic(br);

            //Read byte order.
            ReadByteOrder(br);

            //Read version.
            ReadVersion(br);

            //Rescource name offset.
            int resNameOffset = br.ReadInt32();

            //Number of filenames.
            int numFileNames = (int)br.ReadUInt32();

            //Offsets.
            int[] fileNameOffsets = br.ReadInt32s(numFileNames);

            //New file names.
            FileNames = new List <string>();

            //The table is a new structure.
            ReadHelper r = new ReadHelper(br);

            //Go to the rescource name offset.
            r.JumpToOffset(br, resNameOffset);

            //Read the rescource name.
            RescourceName = r.ReadNullTerminated(br);

            //Read each file name.
            foreach (int i in fileNameOffsets)
            {
                //Go to the offset.
                r.JumpToOffset(br, i);

                //Read the name.
                FileNames.Add(r.ReadNullTerminated(br));
            }
        }
Beispiel #4
0
        /// <summary>
        /// Read the file.
        /// </summary>
        /// <param name="br">The reader.</param>
        public override void Read(BinaryDataReader br)
        {
            //New read helper.
            ReadHelper r = new ReadHelper(br);

            //Read magic.
            ReadMagic(br);

            //Read endian.
            ReadByteOrder(br);

            //Read version.
            ReadVersion(br);

            //Skip file size.
            br.ReadUInt32();

            //Get offsets.
            int dataOffset = br.ReadInt32();
            int markOffset = br.ReadInt32();

            //Ext offset exists only in version 4+.
            int extOffset = -1;

            if (Version.Major >= 4)
            {
                extOffset = br.ReadInt32();
            }

            //String table offset.
            int strgTableOffset = br.ReadInt32();

            //Read the string table.
            List <string> strings = new List <string>();

            r.JumpToOffset(br, strgTableOffset);
            br.Position += 4;
            uint remainingSize = br.ReadUInt32();

            //Each block seems to be aligned to 4 bytes, read the ext block if exists.
            if (extOffset != -1)
            {
                //Get data.
                r.JumpToOffset(br, extOffset);

                //Skip header.
                br.ReadUInt64();

                //Get entries.
                uint count = br.ReadUInt32();
                for (int i = 0; i < count; i++)
                {
                    Exts.Add(new ExtMetaEntry()
                    {
                        Unk1 = br.ReadUInt32(), Unk2 = br.ReadUInt32()
                    });
                }
            }

            //Get data.
            r.JumpToOffset(br, dataOffset);

            //Header and size don't matter.
            br.ReadUInt64();

            //Read name.
            Name = ReadString(br, r, strgTableOffset, br.ReadInt32());

            //Data.
            NumSamples      = br.ReadUInt32();
            AudioType       = (AudioType)br.ReadByte();
            NumChannels     = br.ReadByte();
            NumTracks       = br.ReadByte();
            Flags           = br.ReadByte();
            Volume          = br.ReadSingle();
            SampleRate      = br.ReadUInt32();
            LoopStartSample = br.ReadUInt32();
            LoopEndSample   = br.ReadUInt32();
            Loudness        = br.ReadSingle();

            //Track info.
            for (int i = 0; i < 8; i++)
            {
                TrackInfo[i].Unk    = br.ReadUInt32();
                TrackInfo[i].Volume = br.ReadSingle();
            }

            //Amplitude peak value, if version is at least 4.
            if (Version.Major >= 4)
            {
                AmplitudePeakValue = br.ReadSingle();
            }

            //Markers.
            r.JumpToOffset(br, markOffset);

            //Skip header.
            br.ReadUInt64();

            //Read entries.
            uint markCount = br.ReadUInt32();

            for (int i = 0; i < markCount; i++)
            {
                Markers.Add(new MarkerMetaEntry()
                {
                    Id = br.ReadUInt32(), Name = ReadString(br, r, strgTableOffset, br.ReadInt32()), StartPosition = br.ReadUInt32(), Length = br.ReadUInt32()
                });
            }
        }