Ejemplo n.º 1
0
        /// <summary>
        /// New binary wave.
        /// </summary>
        /// <param name="wave">Wave to create this from.</param>
        public BinaryWave(b_wav wave)
        {
            //Set data.
            ByteOrder  = Syroot.BinaryData.ByteOrder.LittleEndian;
            Major      = 0;
            Minor      = 1;
            SampleRate = wave.info.sampleRate;
            NumSamples = wave.info.loopEnd;
            switch (wave.info.encoding)
            {
            case 0:
                wave.data.dspAdpcm = EncoderFactory.Pcm16ToDspApdcmWAV(EncoderFactory.SignedPcm8ToPcm16(wave.data.pcm8), ref wave);
                break;

            case 1:
                wave.data.dspAdpcm = EncoderFactory.Pcm16ToDspApdcmWAV(wave.data.pcm16, ref wave);
                break;
            }
            DspAdpcmInfo = new DspAdpcmInfo[wave.info.channelInfo.Count];
            for (int i = 0; i < DspAdpcmInfo.Length; i++)
            {
                DspAdpcmInfo[i] = wave.info.channelInfo[i].dspAdpcmInfo;
            }
            Loops           = wave.info.isLoop;
            LoopStartSample = wave.info.loopStart;
            LoopEndSample   = wave.info.loopEnd;
            Data            = wave.data;

            //Do channel pans.
            ChannelPans = new ChannelPan[wave.info.channelInfo.Count()];
            for (int i = 0; i < wave.info.channelInfo.Count(); i++)
            {
                if (i == wave.info.channelInfo.Count() - 1)
                {
                    ChannelPans[i] = ChannelPan.Middle;
                }
                else if (i % 2 == 0)
                {
                    ChannelPans[i] = ChannelPan.Left;
                    ChannelPans[i] = ChannelPan.Right;
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// New binary wave.
        /// </summary>
        /// <param name="s">The stream.</param>
        public BinaryWave(b_stm s)
        {
            //Set data.
            ByteOrder  = Syroot.BinaryData.ByteOrder.LittleEndian;
            Major      = 0;
            Minor      = 1;
            SampleRate = s.info.streamSoundInfo.sampleRate;
            NumSamples = s.info.streamSoundInfo.sampleCount;
            switch (s.info.streamSoundInfo.encoding)
            {
            case 0:
                s.data.dspAdpcm = EncoderFactory.Pcm16ToDspAdpcmSTM(EncoderFactory.SignedPcm8ToPcm16(s.data.pcm8), s);
                break;

            case 1:
                s.data.dspAdpcm = EncoderFactory.Pcm16ToDspAdpcmSTM(s.data.pcm16, s);
                break;
            }
            DspAdpcmInfo = new DspAdpcmInfo[s.info.channels.Count];
            for (int i = 0; i < DspAdpcmInfo.Length; i++)
            {
                DspAdpcmInfo[i] = s.info.channels[i].dspAdpcmInfo;
            }
            Loops           = s.info.streamSoundInfo.isLoop;
            LoopStartSample = s.info.streamSoundInfo.loopStart;
            LoopEndSample   = s.info.streamSoundInfo.sampleCount;
            Data            = s.data;

            //Do channel pans.
            ChannelPans = new ChannelPan[s.info.channels.Count];
            for (int i = 0; i < s.info.channels.Count; i++)
            {
                if (i == s.info.channels.Count - 1)
                {
                    ChannelPans[i] = ChannelPan.Middle;
                }
                else if (i % 2 == 0)
                {
                    ChannelPans[i]     = ChannelPan.Left;
                    ChannelPans[i + 1] = ChannelPan.Right;
                    i++;
                }
            }
            if (s.info.tracks != null)
            {
                foreach (var t in s.info.tracks)
                {
                    if (t.globalChannelIndexTable.count > 0)
                    {
                        if (t.globalChannelIndexTable.count > 1)
                        {
                            ChannelPans[t.globalChannelIndexTable.entries[0]] = ChannelPan.Left;
                            ChannelPans[t.globalChannelIndexTable.entries[1]] = ChannelPan.Right;
                        }
                        else
                        {
                            ChannelPans[t.globalChannelIndexTable.entries[0]] = ChannelPan.Middle;
                        }
                    }
                }
            }
        }