Esempio n. 1
0
        /// <summary>
        /// Read a seek block.
        /// </summary>
        /// <param name="br">The reader.</param>
        /// <param name="info">The stream info.</param>
        public SoundNStreamSeekBlock(ref BinaryDataReader br, b_stm.StreamSoundInfo info, FileHeader h)
        {
            //Set endian.
            if (h.magic[0] == 'C')
            {
                br.ByteOrder = Syroot.BinaryData.ByteOrder.LittleEndian;
            }
            else
            {
                br.ByteOrder = Syroot.BinaryData.ByteOrder.BigEndian;
            }

            //Size and other useless data.
            br.ReadUInt32s(2);

            //New history info.
            history = new HistoryInfo[info.blockCount][];
            for (int i = 0; i < history.Length; i++)
            {
                history[i] = new HistoryInfo[info.channelCount];
                for (int j = 0; j < history[i].Length; j++)
                {
                    history[i][j] = new HistoryInfo()
                    {
                        yn1 = br.ReadInt16(),
                        yn2 = br.ReadInt16()
                    };

                    //Random padding.
                    br.ReadBytes((int)info.sizeOfSeekInfo - 4);
                }
            }

            //Set endian.
            if (h.byteOrder == ByteOrder.LittleEndian)
            {
                br.ByteOrder = Syroot.BinaryData.ByteOrder.LittleEndian;
            }
            else
            {
                br.ByteOrder = Syroot.BinaryData.ByteOrder.BigEndian;
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Make a new region block.
        /// </summary>
        /// <param name="br">The reader.</param>
        /// <param name="info">The stream info.</param>
        public SoundNStreamRegionBlock(ref BinaryDataReader br, b_stm.StreamSoundInfo info)
        {
            //Block header stuff.
            br.ReadUInt32s(2);

            //Go to offset.
            br.Position += info.regionDataOffset.offset;

            //New region infos.
            regions = new RegionInfo[info.regionCount];

            //Read regions.
            for (int i = 0; i < regions.Length; i++)
            {
                regions[i] = new RegionInfo()
                {
                    start    = br.ReadUInt32(),
                    end      = br.ReadUInt32(),
                    loopInfo = new RegionInfo.DspAdpcmLoopInfo[info.channelCount]
                };

                //Read loop info.
                for (int j = 0; j < info.channelCount; j++)
                {
                    regions[i].loopInfo[j] = new RegionInfo.DspAdpcmLoopInfo()
                    {
                        loopPredScale = br.ReadUInt16(),
                        loopYn1       = br.ReadInt16(),
                        loopYn2       = br.ReadInt16()
                    };
                }

                //Read padding.
                int readBytes = 8 + (info.channelCount * 6);
                br.ReadBytes(info.regionInfoBytesize - readBytes);
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Get data from a b_stm.
        /// </summary>
        /// <param name="wavInfo"></param>
        /// <returns></returns>
        public object GetDataSTM(b_stm.StreamSoundInfo wavInfo, b_stm.InfoBlock info)
        {
            object returnValue = null;

            //See encoding.
            switch (wavInfo.encoding)
            {
            case EncodingTypes.PCM8:
                return(EncoderFactory.SignedPcm8ToPcm8(pcm8));

            case EncodingTypes.PCM16:
                return(pcm16);

            case EncodingTypes.DSP_ADPCM:
                List <DspAdpcmInfo> context = new List <DspAdpcmInfo>();
                foreach (b_stm.ChannelInfo c in info.channels)
                {
                    context.Add(c.dspAdpcmInfo);
                }
                return(EncoderFactory.DspApcmToPcm16(dspAdpcm, wavInfo.sampleCount, context.ToArray()));
            }

            return(returnValue);
        }