Пример #1
0
        /// <summary>
        /// Create a wave from a binary wave.
        /// </summary>
        /// <param name="w">The binary wave.</param>
        /// <param name="version">Version of the file.</param>
        /// <returns></returns>
        public static b_wav CreateWave(BinaryWave w, byte vMajor, byte vMinor, byte vRevision)
        {
            b_wav b = new b_wav();

            b.fileHeader = new FileHeader("FWAV", ByteOrder.BigEndian, vMajor, vMinor, vRevision, 0, new List <SizedReference>());
            b.data       = w.Data;

            b.info                   = new b_wav.InfoBlock();
            b.info.sampleRate        = w.SampleRate;
            b.info.originalLoopStart = w.LoopStartSample;
            b.info.loopStart         = w.LoopStartSample;
            b.info.loopEnd           = w.LoopEndSample == 0xFFFFFFFF ? w.NumSamples : w.LoopEndSample;
            b.info.isLoop            = w.Loops && w.LoopEndSample != 0xFFFFFFFF;
            b.info.encoding          = 2;

            b.info.channelInfo = new List <b_wav.InfoBlock.ChannelInfo>();
            foreach (DspAdpcmInfo d in w.DspAdpcmInfo)
            {
                b_wav.InfoBlock.ChannelInfo i = new b_wav.InfoBlock.ChannelInfo();
                i.dspAdpcmInfo = d;
                b.info.channelInfo.Add(i);
            }

            b.Update(ByteOrder.BigEndian);

            return(b);
        }
Пример #2
0
        /// <summary>
        /// Create a RIFF wave from a binary wave.
        /// </summary>
        /// <param name="b">Binary wave.</param>
        /// <returns>The binary wave.</returns>
        public static RiffWave CreateRiffWave(BinaryWave b)
        {
            RiffWave r = new RiffWave();
            UInt16   bytesPerSample = 2;

            //Non-looping.
            if (!b.Loops)
            {
                r = CreateRiffWave(b.SampleRate, bytesPerSample, b.Data.GetDataWAV(b.DspAdpcmInfo, b.LoopEndSample));
            }

            //Looping.
            else
            {
                r = CreateRiffWave(b.SampleRate, bytesPerSample, b.Data.GetDataWAV(b.DspAdpcmInfo, b.LoopEndSample), b.LoopStartSample, b.LoopEndSample);
            }

            return(r);
        }
Пример #3
0
 /// <summary>
 /// Create a stream from a binary wave.
 /// </summary>
 /// <param name="b">The binary wave.</param>
 /// <param name="version">Version of the output stream.</param>
 /// <returns></returns>
 public static b_stm CreateStream(BinaryWave b, byte vMajor, byte vMinor, byte vRevision)
 {
     //Simple hack, but doesn't hurt optimization since SEEK must be recreated anyway.
     return(CreateStream(RiffWaveFactory.CreateRiffWave(b), true, vMajor, vMinor, vRevision));
 }