Exemple #1
0
        /// <summary>
        /// From a b_wav.
        /// </summary>
        /// <param name="b"></param>
        public FISP(b_wav b)
        {
            regions = new List <RegionInfo>();
            tracks  = new List <TrackInfo>();
            data    = new DataInfo();
            stream  = new StreamInfo();

            //Stream info.
            stream.sampleRate        = b.info.sampleRate;
            stream.encoding          = b.info.encoding;
            stream.isLoop            = b.info.isLoop;
            stream.loopEnd           = b.info.loopEnd;
            stream.loopStart         = b.info.loopStart;
            stream.originalLoopEnd   = b.info.loopEnd;
            stream.originalLoopStart = b.info.originalLoopStart;
            stream.vMajor            = b.fileHeader.vMajor;
            stream.vMinor            = b.fileHeader.vMinor;
            stream.vRevision         = b.fileHeader.vRevision;

            //Data.
            switch (b.info.encoding)
            {
            //PCM8.
            case EncodingTypes.PCM8:
                data.data = EncoderFactory.SignedPcm8ToPcm16(b.data.pcm8).ToList();
                break;

            //PCM16.
            case EncodingTypes.PCM16:
                data.data = b.data.pcm16.ToList();
                break;

            //DSP-ADPCM.
            case EncodingTypes.DSP_ADPCM:
                data.data = (b.data.GetDataWAV(b.info) as short[][]).ToList();
                break;
            }
        }
Exemple #2
0
        /// <summary>
        /// From a stream.
        /// </summary>
        /// <param name="s"></param>
        public FISP(b_stm s)
        {
            regions = new List <RegionInfo>();
            tracks  = new List <TrackInfo>();
            data    = new DataInfo();
            stream  = new StreamInfo();

            //Stream info.
            stream.sampleRate        = s.info.streamSoundInfo.sampleRate;
            stream.encoding          = s.info.streamSoundInfo.encoding;
            stream.isLoop            = s.info.streamSoundInfo.isLoop;
            stream.loopEnd           = s.info.streamSoundInfo.sampleCount;
            stream.loopStart         = s.info.streamSoundInfo.loopStart;
            stream.originalLoopEnd   = s.info.streamSoundInfo.originalLoopEnd;
            stream.originalLoopStart = s.info.streamSoundInfo.originalLoopStart;
            stream.vMajor            = s.fileHeader.vMajor;
            stream.vMinor            = s.fileHeader.vMinor;
            stream.vRevision         = s.fileHeader.vRevision;
            stream.secretInfo        = s.info.streamSoundInfo.secretInfo;

            //Data.
            switch (s.info.streamSoundInfo.encoding)
            {
            //PCM8.
            case EncodingTypes.PCM8:
                data.data = EncoderFactory.SignedPcm8ToPcm16(s.data.pcm8).ToList();
                break;

            //PCM16.
            case EncodingTypes.PCM16:
                data.data = s.data.pcm16.ToList();
                break;

            //DSP-ADPCM.
            case EncodingTypes.DSP_ADPCM:
                data.data = (s.data.GetDataSTM(s.info.streamSoundInfo, s.info) as short[][]).ToList();
                break;
            }

            //Tracks.
            if (s.info.tracks != null)
            {
                foreach (b_stm.TrackInfo i in s.info.tracks)
                {
                    TrackInfo t = new TrackInfo()
                    {
                        pan          = i.pan,
                        span         = i.span,
                        surroundMode = i.surroundMode,
                        volume       = i.volume,
                        channels     = i.globalChannelIndexTable.entries
                    };
                    tracks.Add(t);
                }
            }

            //Regions.
            if (s.region != null)
            {
                foreach (SoundNStreamRegionBlock.RegionInfo i in s.region.regions)
                {
                    regions.Add(new RegionInfo()
                    {
                        start = i.start,
                        end   = i.end,
                    });
                }
            }
        }