示例#1
0
        private static void AddTimeSpan(IWaveSource source, MediaFoundationEncoder mediaFoundationEncoder, TimeSpan startTimeSpan, TimeSpan endTimeSpan)
        {
            source.SetPosition(startTimeSpan);

            int  read          = 0;
            long bytesToEncode = source.GetRawElements(endTimeSpan - startTimeSpan);

            var buffer = new byte[source.WaveFormat.BytesPerSecond];

            while ((read = source.Read(buffer, 0, buffer.Length)) > 0)
            {
                int bytesToWrite = (int)Math.Min(read, bytesToEncode);
                mediaFoundationEncoder.Write(buffer, 0, bytesToWrite);
                bytesToEncode -= bytesToWrite;
            }
        }
示例#2
0
 public ExtendedDurationWaveSource(IWaveSource waveSource, int milliSecondsToExtend) : base(waveSource)
 {
     bytesToExtend = (int)waveSource.GetRawElements(milliSecondsToExtend);
     Length        = base.Length + bytesToExtend;
 }
 public ExtendedDurationWaveSource(IWaveSource waveSource, int milliSecondsToExtend) : base(waveSource)
 {
     bytesToExtend = (int)waveSource.GetRawElements(milliSecondsToExtend);
     Length = base.Length + bytesToExtend;
 }
示例#4
0
 public TrimmedWaveSource(IWaveSource source, TimeSpan length)
     : base(source)
 {
     _lengthInBytes = source.GetRawElements(length);
 }
示例#5
0
 public TrimmedWaveSource(IWaveSource source, TimeSpan length)
     : base(source)
 {
     _lengthInBytes = source.GetRawElements(length);
 }