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; } }
public ExtendedDurationWaveSource(IWaveSource waveSource, int milliSecondsToExtend) : base(waveSource) { bytesToExtend = (int)waveSource.GetRawElements(milliSecondsToExtend); Length = base.Length + bytesToExtend; }
public TrimmedWaveSource(IWaveSource source, TimeSpan length) : base(source) { _lengthInBytes = source.GetRawElements(length); }