示例#1
0
 public void FromBytes(byte[] bytes)
 {
     using (var reader = new BinaryDataReader(bytes))
     {
         Session     = reader.ReadString();
         LookAt      = reader.ReadVector();
         IsMoveRight = reader.ReadBoolean();
         IsMoveLeft  = reader.ReadBoolean();
         IsJump      = reader.ReadBoolean();
     }
 }
示例#2
0
        protected override ImageLayer Deserialize(BinaryDataReader reader)
        {
            var img = new ImageLayer();

            img.Z    = reader.ReadInt16();
            img.SubZ = reader.ReadInt16();
            /* Obsolete flag 1: Layered */
            img.IsLayered = reader.ReadBoolean();
            img.Id        = reader.ReadInt16();
            img.Offset    = reader.ReadInt16Coord();
            img.Data      = reader.ReadRemaining();
            return(img);
        }
示例#3
0
        public void FromBytes(byte[] bytes)
        {
            Items = new Dictionary <string, ServerDataItem>();

            using (var reader = new BinaryDataReader(bytes))
            {
                var count = reader.ReadInt();

                for (int i = 0; i < count; i++)
                {
                    var item = new ServerDataItem
                    {
                        Session     = reader.ReadString(),
                        LookAt      = reader.ReadVector(),
                        IsMoveRight = reader.ReadBoolean(),
                        IsMoveLeft  = reader.ReadBoolean(),
                        IsJump      = reader.ReadBoolean(),
                        Position    = reader.ReadVector()
                    };

                    Items[item.Session] = item;
                }
            }
        }
示例#4
0
        protected override TilesetLayer Deserialize(BinaryDataReader reader)
        {
            var tileset = new TilesetLayer();

            tileset.HasTransitions = reader.ReadBoolean();
            var flavorCount = reader.ReadUInt16();

            tileset.FlavorDensity = reader.ReadUInt16();
            tileset.FlavorObjects = new FlavorObjectData[flavorCount];
            for (int i = 0; i < flavorCount; i++)
            {
                var fob = new FlavorObjectData();
                fob.Resource             = new ResourceRef(reader.ReadCString(), reader.ReadUInt16());
                fob.Weight               = reader.ReadByte();
                tileset.FlavorObjects[i] = fob;
            }
            return(tileset);
        }
示例#5
0
        public bool TryVisitValue(VisitArgs args, out bool?value)
        {
            if (args.Index > 0 && !MoveToIndex(args.Index))
            {
                value = null;
                return(false);
            }
            var length = _reader.ReadByte();

            if (length == BinaryZPacker.Null)
            {
                value = null;
                return(true);
            }
            if (length != BinaryInformation.Boolean.FixedLength)
            {
                throw new UnexpectedLengthException(args, length);
            }

            value = _reader.ReadBoolean();
            return(true);
        }
示例#6
0
        private object ReadParamData(ShaderParamType type, BinaryDataReader reader)
        {
            switch (type)
            {
            case ShaderParamType.Bool: return(reader.ReadBoolean());

            case ShaderParamType.Bool2: return(reader.ReadBooleans(2));

            case ShaderParamType.Bool3: return(reader.ReadBooleans(3));

            case ShaderParamType.Bool4: return(reader.ReadBooleans(4));

            case ShaderParamType.Float: return(reader.ReadSingle());

            case ShaderParamType.Float2: return(reader.ReadSingles(2));

            case ShaderParamType.Float2x2: return(reader.ReadSingles(2 * 2));

            case ShaderParamType.Float2x3: return(reader.ReadSingles(2 * 3));

            case ShaderParamType.Float2x4: return(reader.ReadSingles(2 * 4));

            case ShaderParamType.Float3: return(reader.ReadSingles(3));

            case ShaderParamType.Float3x2: return(reader.ReadSingles(3 * 2));

            case ShaderParamType.Float3x3: return(reader.ReadSingles(3 * 3));

            case ShaderParamType.Float3x4: return(reader.ReadSingles(3 * 4));

            case ShaderParamType.Float4: return(reader.ReadSingles(4));

            case ShaderParamType.Float4x2: return(reader.ReadSingles(4 * 2));

            case ShaderParamType.Float4x3: return(reader.ReadSingles(4 * 3));

            case ShaderParamType.Float4x4: return(reader.ReadSingles(4 * 4));

            case ShaderParamType.Int: return(reader.ReadInt32());

            case ShaderParamType.Int2: return(reader.ReadInt32s(2));

            case ShaderParamType.Int3: return(reader.ReadInt32s(3));

            case ShaderParamType.Int4: return(reader.ReadInt32s(4));

            case ShaderParamType.UInt: return(reader.ReadInt32());

            case ShaderParamType.UInt2: return(reader.ReadInt32s(2));

            case ShaderParamType.UInt3: return(reader.ReadInt32s(3));

            case ShaderParamType.UInt4: return(reader.ReadInt32s(4));

            case ShaderParamType.Reserved2: return(reader.ReadBytes(2));

            case ShaderParamType.Reserved3: return(reader.ReadBytes(3));

            case ShaderParamType.Reserved4: return(reader.ReadBytes(4));

            case ShaderParamType.Srt2D:
                return(new Srt2D()
                {
                    Scaling = reader.ReadVector2F(),
                    Rotation = reader.ReadSingle(),
                    Translation = reader.ReadVector2F(),
                });

            case ShaderParamType.Srt3D:
                return(new Srt3D()
                {
                    Scaling = reader.ReadVector3F(),
                    Rotation = reader.ReadVector3F(),
                    Translation = reader.ReadVector3F(),
                });

            case ShaderParamType.TexSrt:
                return(new TexSrt()
                {
                    Mode = (TexSrtMode)reader.ReadInt32(),
                    Scaling = reader.ReadVector2F(),
                    Rotation = reader.ReadSingle(),
                    Translation = reader.ReadVector2F(),
                });

            case ShaderParamType.TexSrtEx:
                return(new TexSrtEx()
                {
                    Mode = (TexSrtMode)reader.ReadInt32(),
                    Scaling = reader.ReadVector2F(),
                    Rotation = reader.ReadSingle(),
                    Translation = reader.ReadVector2F(),
                    MatrixPointer = reader.ReadUInt32(),
                });
            }
            return(0);
        }
示例#7
0
 /// <summary>
 /// Reads a <see cref="Vector4Bool"/> instance from the current stream and returns it.
 /// </summary>
 /// <param name="self">The extended <see cref="BinaryDataReader"/>.</param>
 /// <param name="format">The <see cref="BinaryBooleanFormat"/> in which values are stored.</param>
 /// <returns>The <see cref="Vector4Bool"/> instance.</returns>
 public static Vector4Bool ReadVector4Bool(this BinaryDataReader self,
                                           BinaryBooleanFormat format = BinaryBooleanFormat.NonZeroByte)
 {
     return(new Vector4Bool(self.ReadBoolean(format), self.ReadBoolean(format), self.ReadBoolean(format),
                            self.ReadBoolean(format)));
 }
示例#8
0
        /// <summary>
        /// Load a file. WIP.
        /// </summary>
        /// <param name="b"></param>
        public void Load(byte[] b)
        {
            //Reader.
            MemoryStream     src = new MemoryStream(b);
            BinaryDataReader br  = new BinaryDataReader(src);

            magic       = br.ReadChars(4);
            trackCount  = br.ReadUInt32();
            regionCount = br.ReadUInt32();

            stream = new StreamInfo()
            {
                magic             = br.ReadChars(3),
                encoding          = br.ReadByte(),
                vMajor            = br.ReadByte(),
                vMinor            = br.ReadByte(),
                vRevision         = br.ReadByte(),
                isLoop            = br.ReadBoolean(),
                sampleRate        = br.ReadUInt32(),
                loopStart         = br.ReadUInt32(),
                loopEnd           = br.ReadUInt32(),
                originalLoopStart = br.ReadUInt32(),
                originalLoopEnd   = br.ReadUInt32(),
                secretInfo        = br.ReadUInt32()
            };

            tracks = new List <TrackInfo>();
            for (int i = 0; i < trackCount; i++)
            {
                TrackInfo t = new TrackInfo
                {
                    magic        = br.ReadChars(4),
                    volume       = br.ReadByte(),
                    pan          = br.ReadByte(),
                    span         = br.ReadByte(),
                    surroundMode = br.ReadByte(),
                    numChannels  = br.ReadUInt32(),
                };
                t.channels = br.ReadBytes((int)t.numChannels).ToList();

                tracks.Add(t);
            }

            regions = new List <RegionInfo>();
            for (int i = 0; i < regionCount; i++)
            {
                RegionInfo r = new RegionInfo()
                {
                    magic = br.ReadChars(4),
                    start = br.ReadUInt32(),
                    end   = br.ReadUInt32()
                };
                regions.Add(r);
            }

            data = new DataInfo()
            {
                magic       = br.ReadChars(4),
                numChannels = br.ReadUInt32(),
                numSamples  = br.ReadUInt32(),
                data        = new List <short[]>()
            };

            for (int i = 0; i < data.numChannels; i++)
            {
                data.data.Add(br.ReadInt16s((int)data.numSamples));
            }
        }
示例#9
0
        /// <summary>
        /// Read a sequence command.
        /// </summary>
        /// <param name="br">The reader.</param>
        /// <param name="type">Type of sequence command.</param>
        /// <returns>The read sequence command.</returns>
        public static SequenceCommand Read(BinaryDataReader br, SequenceCommandType type = SequenceCommandType.Normal)
        {
            //Get sequence command.
            SequenceCommand s = null;

            switch (type)
            {
            case SequenceCommandType.Normal:
                s = NewFromType(br.ReadByte(), (int)br.Position);
                break;

            case SequenceCommandType.Extended:
                s = NewFromTypeExtended(br.ReadByte(), (int)br.Position);
                break;
            }

            //Read the objects.
            int count = 0;

            foreach (var t in s.SequenceParameterTypes)
            {
                //Switch the type.
                switch (t)
                {
                //U8.
                case SequenceParameterType.u8:
                    s.Parameters[count] = br.ReadByte();
                    break;

                //U16.
                case SequenceParameterType.u16:
                    s.Parameters[count] = br.ReadUInt16();
                    break;

                //U24.
                case SequenceParameterType.u24:
                    s.Parameters[count] = new UInt24(br);
                    break;

                //U32.
                case SequenceParameterType.u32:
                    s.Parameters[count] = br.ReadUInt32();
                    break;

                //U64.
                case SequenceParameterType.u64:
                    s.Parameters[count] = br.ReadUInt64();
                    break;

                //S8.
                case SequenceParameterType.s8:
                    s.Parameters[count] = br.ReadSByte();
                    break;

                //S16.
                case SequenceParameterType.s16:
                    s.Parameters[count] = br.ReadInt16();
                    break;

                //S32.
                case SequenceParameterType.s32:
                    s.Parameters[count] = br.ReadInt32();
                    break;

                //S64.
                case SequenceParameterType.s64:
                    s.Parameters[count] = br.ReadInt64();
                    break;

                //Boolean.
                case SequenceParameterType.boolean:
                    s.Parameters[count] = br.ReadBoolean();
                    break;

                //Variable length.
                case SequenceParameterType.VariableLength:
                    s.Parameters[count] = VariableLength.ReadVariableLength(br);
                    break;

                //Sequence command.
                case SequenceParameterType.SeqCommand:

                    //The type of sequence command embedded depends on the command type.
                    switch ((CommandType)s.Identifier)
                    {
                    //Extended.
                    case CommandType.Extended:
                        s.Parameters[count] = Read(br, SequenceCommandType.Extended);
                        break;

                    //Random.
                    case CommandType.Random:
                        s.Parameters[count] = NewFromType(br.ReadByte(), (int)br.Position);

                        //Extended.
                        if (((SequenceCommand)s.Parameters[count]).Identifier == (byte)CommandType.Extended)
                        {
                            //Read a new extended command.
                            ((SequenceCommand)s.Parameters[count]).Parameters[0] = NewFromTypeExtended(br.ReadByte(), (int)br.Position);

                            //Remove the last parameter of the sequence command.
                            ((SequenceCommand)((SequenceCommand)s.Parameters[count]).Parameters[0]).SequenceParameterTypes.RemoveAt(((SequenceCommand)((SequenceCommand)s.Parameters[count]).Parameters[0]).SequenceParameterTypes.Count - 1);

                            //Read the parameters.
                            ((SequenceCommand)((SequenceCommand)s.Parameters[count]).Parameters[0]).ReadPrefixParameters(br);
                        }

                        //Regular.
                        else
                        {
                            //Remove the last parameter, since it is replaced with the min and max.
                            ((SequenceCommand)s.Parameters[count]).SequenceParameterTypes.RemoveAt(((SequenceCommand)s.Parameters[count]).SequenceParameterTypes.Count - 1);
                            ((SequenceCommand)s.Parameters[count]).ReadPrefixParameters(br);
                        }
                        break;

                    //Variable.
                    case CommandType.Variable:
                        s.Parameters[count] = NewFromType(br.ReadByte(), (int)br.Position);

                        //Extended.
                        if (((SequenceCommand)s.Parameters[count]).Identifier == (byte)CommandType.Extended)
                        {
                            //Read a new extended command.
                            ((SequenceCommand)s.Parameters[count]).Parameters[0] = NewFromTypeExtended(br.ReadByte(), (int)br.Position);

                            //Remove the last parameter of the sequence command.
                            ((SequenceCommand)((SequenceCommand)s.Parameters[count]).Parameters[0]).SequenceParameterTypes.RemoveAt(((SequenceCommand)((SequenceCommand)s.Parameters[count]).Parameters[0]).SequenceParameterTypes.Count - 1);

                            //Read the parameters.
                            ((SequenceCommand)((SequenceCommand)s.Parameters[count]).Parameters[0]).ReadPrefixParameters(br);
                        }

                        //Regular.
                        else
                        {
                            //Remove the last parameter, since it is replaced with the min and max.
                            ((SequenceCommand)s.Parameters[count]).SequenceParameterTypes.RemoveAt(((SequenceCommand)s.Parameters[count]).SequenceParameterTypes.Count - 1);
                            ((SequenceCommand)s.Parameters[count]).ReadPrefixParameters(br);
                        }
                        break;

                    //Last resort.
                    default:
                        s.Parameters[count] = Read(br);
                        break;
                    }
                    break;
                }

                //Increase count.
                count++;
            }

            //Return the command.
            return(s);
        }
示例#10
0
        /// <summary>
        /// Read parameters, but only for prefix commands.
        /// </summary>
        /// <param name="br">The reader</param>
        public void ReadPrefixParameters(BinaryDataReader br)
        {
            //Read the objects.
            int count = 0;

            foreach (var t in SequenceParameterTypes)
            {
                //Switch the type.
                switch (t)
                {
                //U8.
                case SequenceParameterType.u8:
                    Parameters[count] = br.ReadByte();
                    break;

                //U16.
                case SequenceParameterType.u16:
                    Parameters[count] = br.ReadUInt16();
                    break;

                //U24.
                case SequenceParameterType.u24:
                    Parameters[count] = new UInt24(br);
                    break;

                //U32.
                case SequenceParameterType.u32:
                    Parameters[count] = br.ReadUInt32();
                    break;

                //U64.
                case SequenceParameterType.u64:
                    Parameters[count] = br.ReadUInt64();
                    break;

                //S8.
                case SequenceParameterType.s8:
                    Parameters[count] = br.ReadSByte();
                    break;

                //S16.
                case SequenceParameterType.s16:
                    Parameters[count] = br.ReadInt16();
                    break;

                //S32.
                case SequenceParameterType.s32:
                    Parameters[count] = br.ReadInt32();
                    break;

                //S64.
                case SequenceParameterType.s64:
                    Parameters[count] = br.ReadInt64();
                    break;

                //Boolean.
                case SequenceParameterType.boolean:
                    Parameters[count] = br.ReadBoolean();
                    break;

                //Variable length.
                case SequenceParameterType.VariableLength:
                    Parameters[count] = VariableLength.ReadVariableLength(br);
                    break;

                //Sequence command.
                case SequenceParameterType.SeqCommand:
                    Parameters[count] = Read(br);
                    break;
                }

                //Increase count.
                count++;
            }
        }
示例#11
0
        /// <summary>
        /// Load a file.
        /// </summary>
        /// <param name="b">The file.</param>
        public void Load(byte[] b)
        {
            //Set up the reader.
            MemoryStream     src = new MemoryStream(b);
            BinaryDataReader br  = new BinaryDataReader(src);

            //Read the header.
            fileHeader = new FileHeader(ref br);

            //Read blocks.
            foreach (SizedReference s in fileHeader.blockOffsets)
            {
                if (s.offset != Reference.NULL_PTR)
                {
                    br.Position = s.offset;
                    switch (s.typeId)
                    {
                    //Info block.
                    case ReferenceTypes.STRM_Block_Info:
                        long basePos = br.Position + 8;
                        info = new InfoBlock()
                        {
                            magic               = br.ReadChars(4),
                            blockSize           = br.ReadUInt32(),
                            streamSoundInfoRef  = new Reference(ref br),
                            trackInfoTableRef   = new Reference(ref br),
                            channelInfoTableRef = new Reference(ref br),
                            streamSoundInfo     = null,
                            trackInfoRefTable   = null,
                            channelInfoRefTable = null,
                            tracks              = null,
                            channels            = null
                        };

                        //Stream sound info.
                        if (info.streamSoundInfoRef.typeId == ReferenceTypes.STRM_Info_StreamSound && info.streamSoundInfoRef.offset != Reference.NULL_PTR)
                        {
                            br.Position          = basePos + info.streamSoundInfoRef.offset;
                            info.streamSoundInfo = new StreamSoundInfo()
                            {
                                encoding                = br.ReadByte(),
                                isLoop                  = br.ReadBoolean(),
                                channelCount            = br.ReadByte(),
                                regionCount             = br.ReadByte(),
                                sampleRate              = br.ReadUInt32(),
                                loopStart               = br.ReadUInt32(),
                                sampleCount             = br.ReadUInt32(),
                                blockCount              = br.ReadUInt32(),
                                oneBlockBytesize        = br.ReadUInt32(),
                                oneBlockSamples         = br.ReadUInt32(),
                                lastBlockBytesize       = br.ReadUInt32(),
                                lastBlockSamples        = br.ReadUInt32(),
                                lastBlockPaddedBytesize = br.ReadUInt32(),
                                sizeOfSeekInfo          = br.ReadUInt32(),
                                seekInfoIntervalSamples = br.ReadUInt32(),
                                sampleDataOffset        = new Reference(ref br),
                                regionInfoBytesize      = 0x100,
                                padding                 = 0,
                                regionDataOffset        = new Reference(0, 0x18),
                                originalLoopStart       = 0,
                                originalLoopEnd         = 0,
                                secretInfo              = 0
                            };

                            if (fileHeader.vMajor >= regionInfo)
                            {
                                info.streamSoundInfo.regionInfoBytesize = br.ReadUInt16();
                                info.streamSoundInfo.padding            = br.ReadUInt16();
                                info.streamSoundInfo.regionDataOffset   = new Reference(ref br);
                            }

                            if (fileHeader.vMajor >= originalLoopInfo)
                            {
                                info.streamSoundInfo.originalLoopStart = br.ReadUInt32();
                                info.streamSoundInfo.originalLoopEnd   = br.ReadUInt32();
                            }

                            if (fileHeader.vMajor >= secretInfo)
                            {
                                info.streamSoundInfo.secretInfo = br.ReadUInt32();
                            }
                        }

                        //Track info.
                        if (info.trackInfoTableRef.typeId == ReferenceTypes.Tables + 1 && info.trackInfoTableRef.offset != Reference.NULL_PTR)
                        {
                            br.Position = basePos + info.trackInfoTableRef.offset;
                            long newPos = br.Position;
                            info.trackInfoRefTable = new ReferenceTable(ref br);

                            //Get tracks.
                            info.tracks = new List <TrackInfo>();
                            foreach (Reference r in info.trackInfoRefTable.references)
                            {
                                TrackInfo t = null;
                                if (r.typeId == ReferenceTypes.STRM_Info_Track && r.offset != Reference.NULL_PTR)
                                {
                                    br.Position = newPos + r.offset;
                                    t           = new TrackInfo()
                                    {
                                        volume       = br.ReadByte(),
                                        pan          = br.ReadByte(),
                                        span         = br.ReadByte(),
                                        surroundMode = br.ReadByte(),
                                        globalChannelIndexTableRef = new Reference(ref br),
                                        globalChannelIndexTable    = null
                                    };

                                    if (t.globalChannelIndexTableRef.offset != Reference.NULL_PTR)
                                    {
                                        br.Position = newPos + r.offset + t.globalChannelIndexTableRef.offset;
                                        t.globalChannelIndexTable         = new Table <byte>();
                                        t.globalChannelIndexTable.count   = br.ReadUInt32();
                                        t.globalChannelIndexTable.entries = new List <byte>();
                                        for (int i = 0; i < t.globalChannelIndexTable.count; i++)
                                        {
                                            t.globalChannelIndexTable.entries.Add(br.ReadByte());
                                        }
                                    }
                                }
                                info.tracks.Add(t);
                            }
                        }

                        //Channel info.
                        if (info.channelInfoTableRef.typeId == ReferenceTypes.Tables + 1 && info.channelInfoTableRef.offset != Reference.NULL_PTR)
                        {
                            br.Position = basePos + info.channelInfoTableRef.offset;
                            long newPos = br.Position;
                            info.channelInfoRefTable = new ReferenceTable(ref br);

                            //Get channels.
                            info.channels = new List <ChannelInfo>();
                            foreach (Reference r in info.channelInfoRefTable.references)
                            {
                                ChannelInfo c = null;
                                if (r.offset != Reference.NULL_PTR)
                                {
                                    br.Position = newPos + r.offset;
                                    c           = new ChannelInfo()
                                    {
                                        dspAdpcmInfoRef = new Reference(ref br),
                                        dspAdpcmInfo    = null
                                    };

                                    if (c.dspAdpcmInfoRef.offset != Reference.NULL_PTR)
                                    {
                                        br.Position    = newPos + r.offset + c.dspAdpcmInfoRef.offset;
                                        c.dspAdpcmInfo = new DspAdpcmInfo();
                                        c.dspAdpcmInfo = new DspAdpcmInfo()
                                        {
                                            coefs = new short[8][]
                                        };
                                        c.dspAdpcmInfo.coefs[0]        = br.ReadInt16s(2);
                                        c.dspAdpcmInfo.coefs[1]        = br.ReadInt16s(2);
                                        c.dspAdpcmInfo.coefs[2]        = br.ReadInt16s(2);
                                        c.dspAdpcmInfo.coefs[3]        = br.ReadInt16s(2);
                                        c.dspAdpcmInfo.coefs[4]        = br.ReadInt16s(2);
                                        c.dspAdpcmInfo.coefs[5]        = br.ReadInt16s(2);
                                        c.dspAdpcmInfo.coefs[6]        = br.ReadInt16s(2);
                                        c.dspAdpcmInfo.coefs[7]        = br.ReadInt16s(2);
                                        c.dspAdpcmInfo.pred_scale      = br.ReadUInt16();
                                        c.dspAdpcmInfo.yn1             = br.ReadInt16();
                                        c.dspAdpcmInfo.yn2             = br.ReadInt16();
                                        c.dspAdpcmInfo.loop_pred_scale = br.ReadUInt16();
                                        c.dspAdpcmInfo.loop_yn1        = br.ReadInt16();
                                        c.dspAdpcmInfo.loop_yn2        = br.ReadInt16();
                                    }
                                }
                                info.channels.Add(c);
                            }
                        }

                        break;

                    //Seek block.
                    case ReferenceTypes.STRM_Block_Seek:
                        seek = new SoundNStreamSeekBlock(ref br, info.streamSoundInfo, fileHeader);
                        break;

                    //Region block.
                    case ReferenceTypes.STRM_Block_Region:
                        region = new SoundNStreamRegionBlock(ref br, info.streamSoundInfo);
                        break;

                    //Data block.
                    case ReferenceTypes.STRM_Block_Data:
                        data = new SoundNStreamDataBlock(ref br, info);
                        break;
                    }
                }
            }
        }
示例#12
0
        /// <summary>
        /// Load a file.
        /// </summary>
        /// <param name="b">The file.</param>
        public void Load(byte[] b)
        {
            //Set up the reader.
            MemoryStream     src = new MemoryStream(b);
            BinaryDataReader br  = new BinaryDataReader(src);

            //Read file header.
            fileHeader = new FileHeader(ref br);

            //Read info block.
            info = null;
            if (fileHeader.blockOffsets[0].offset != Reference.NULL_PTR && fileHeader.blockOffsets[0].typeId == ReferenceTypes.WAV_Block_Info)
            {
                br.Position = fileHeader.blockOffsets[0].offset;
                info        = new InfoBlock
                {
                    magic               = br.ReadChars(4),
                    blockSize           = br.ReadUInt32(),
                    encoding            = br.ReadByte(),
                    isLoop              = br.ReadBoolean(),
                    padding             = br.ReadUInt16(),
                    sampleRate          = br.ReadUInt32(),
                    loopStart           = br.ReadUInt32(),
                    loopEnd             = br.ReadUInt32(),
                    originalLoopStart   = br.ReadUInt32(),
                    channelInfoRefTable = new ReferenceTable(ref br),
                    channelInfo         = new List <InfoBlock.ChannelInfo>()
                };

                //Read channel info.
                foreach (Reference r in info.channelInfoRefTable.references)
                {
                    //Set position.
                    br.Position = 0x5C + r.offset;

                    //New channel info.
                    InfoBlock.ChannelInfo c = new InfoBlock.ChannelInfo()
                    {
                        samplesRef      = new Reference(ref br),
                        dspAdpcmInfoRef = new Reference(ref br),
                        reserved        = br.ReadUInt32(),
                        dspAdpcmInfo    = null
                    };

                    //Read Dsp-Apdcm info.
                    if (c.dspAdpcmInfoRef.offset != Reference.NULL_PTR)
                    {
                        br.Position = 0x5C + r.offset + c.dspAdpcmInfoRef.offset;

                        c.dspAdpcmInfo                 = new DspAdpcmInfo();
                        c.dspAdpcmInfo.coefs           = new Int16[8][];
                        c.dspAdpcmInfo.coefs[0]        = br.ReadInt16s(2);
                        c.dspAdpcmInfo.coefs[1]        = br.ReadInt16s(2);
                        c.dspAdpcmInfo.coefs[2]        = br.ReadInt16s(2);
                        c.dspAdpcmInfo.coefs[3]        = br.ReadInt16s(2);
                        c.dspAdpcmInfo.coefs[4]        = br.ReadInt16s(2);
                        c.dspAdpcmInfo.coefs[5]        = br.ReadInt16s(2);
                        c.dspAdpcmInfo.coefs[6]        = br.ReadInt16s(2);
                        c.dspAdpcmInfo.coefs[7]        = br.ReadInt16s(2);
                        c.dspAdpcmInfo.pred_scale      = br.ReadUInt16();
                        c.dspAdpcmInfo.yn1             = br.ReadInt16();
                        c.dspAdpcmInfo.yn2             = br.ReadInt16();
                        c.dspAdpcmInfo.loop_pred_scale = br.ReadUInt16();
                        c.dspAdpcmInfo.loop_yn1        = br.ReadInt16();
                        c.dspAdpcmInfo.loop_yn2        = br.ReadInt16();
                    }

                    info.channelInfo.Add(c);
                }
            }

            //Read data block.
            if (fileHeader.blockOffsets[1].offset != Reference.NULL_PTR && fileHeader.blockOffsets[1].typeId == ReferenceTypes.WAV_Block_Data)
            {
                br.Position = fileHeader.blockOffsets[1].offset;
                data        = new SoundNStreamDataBlock(ref br, info);
            }
        }