Ejemplo n.º 1
0
        /// <summary>
        /// Convert to stream.
        /// </summary>
        /// <returns></returns>
        public b_stm toB_stm()
        {
            this.update();
            b_stm b = new b_stm();

            b = this.toB_wav().toB_stm();
            b.info.stream.loop      = stream.loop;
            b.info.stream.loopStart = stream.loopStart;
            b.info.stream.loopEnd   = stream.loopEnd;
            b.info.track            = new List <b_stm.infoBlock.trackInfo>();
            for (int i = 0; i < tracks.Count; i++)
            {
                b_stm.infoBlock.trackInfo t = new b_stm.infoBlock.trackInfo();
                t.volume                   = tracks[i].volume;
                t.pan                      = tracks[i].pan;
                t.flags                    = tracks[i].flags;
                t.byteTable                = new b_stm.infoBlock.trackInfo.byteTableTrack();
                t.byteTable.count          = tracks[i].channelCount;
                t.byteTable.channelIndexes = tracks[i].channels;
                b.info.track.Add(t);
            }
            b.numSamples = channelData[0].Length;
            b.update(endianNess.big, true);

            return(b);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Get the wave data from a file path.
        /// </summary>
        /// <returns>Wave data.</returns>
        public Wave GetWave()
        {
            string wavePath = GetWavePath();

            if (wavePath == "")
            {
                return(null);
            }

            //Extension.
            string ext = Path.GetExtension(wavePath).ToLower();

            //RIFF.
            if (ext.StartsWith(".w"))
            {
                RiffWave r = new RiffWave();
                r.Load(System.IO.File.ReadAllBytes(wavePath));
                return(new Wave()
                {
                    Wav = WaveFactory.CreateWave(r, true, forceWavMaj, forceWavMin, forceWavRev)
                });
            }

            //Wave.
            else if (ext.EndsWith("wav"))
            {
                b_wav b = new b_wav();
                b.Load(System.IO.File.ReadAllBytes(wavePath));
                return(new Wave()
                {
                    Wav = b
                });
            }

            //Stream.
            else if (ext.EndsWith("stm"))
            {
                b_stm s = new b_stm();
                s.Load(System.IO.File.ReadAllBytes(wavePath));
                return(new Wave()
                {
                    Wav = WaveFactory.CreateWave(s, forceWavMaj, forceWavMin, forceWavRev)
                });
            }

            //Null.
            return(null);
        }
Ejemplo n.º 3
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,
                    });
                }
            }
        }