Beispiel #1
0
        public static void EncodeWholeSource(MediaFoundationEncoder encoder, IWaveSource source)
        {
            byte[] buffer = new byte[source.WaveFormat.BytesPerSecond * 4];
            int    read   = 0;

            while ((read = source.Read(buffer, 0, buffer.Length)) > 0)
            {
                Debug.WriteLine(String.Format("{0:#00.00}%", (double)source.Position / (double)source.Length * 100));
                encoder.Write(buffer, 0, read);
            }
        }
        /// <summary>
        ///     Encodes the whole <paramref name="source" /> with the specified <paramref name="encoder" />. The encoding process
        ///     stops as soon as the <see cref="IReadableAudioSource{T}.Read" /> method of the specified <paramref name="source" />
        ///     returns 0.
        /// </summary>
        /// <param name="encoder">The encoder which should be used to encode the audio data.</param>
        /// <param name="source">The <see cref="IWaveSource" /> which provides the raw audio data to encode.</param>
        public static void EncodeWholeSource(MediaFoundationEncoder encoder, IWaveSource source)
        {
            if (encoder == null)
            {
                throw new ArgumentNullException("encoder");
            }
            if (source == null)
            {
                throw new ArgumentNullException("source");
            }
            var buffer = new byte[source.WaveFormat.BytesPerSecond * 4];
            int read;

            while ((read = source.Read(buffer, 0, buffer.Length)) > 0)
            {
                Debug.WriteLine(String.Format("{0:#00.00}%", source.Position / (double)source.Length * 100));
                encoder.Write(buffer, 0, read);
            }
        }
 public static void EncodeWholeSource(MediaFoundationEncoder encoder, IWaveSource source)
 {
     byte[] buffer = new byte[source.WaveFormat.BytesPerSecond * 4];
     int read = 0;
     while ((read = source.Read(buffer, 0, buffer.Length)) > 0)
     {
         Debug.WriteLine(String.Format("{0:#00.00}%", (double)source.Position / (double)source.Length * 100));
         encoder.Write(buffer, 0, read);
     }
 }
Beispiel #4
0
 /// <summary>
 ///     Encodes the whole <paramref name="source" /> with the specified <paramref name="encoder" />. The encoding process
 ///     stops as soon as the <see cref="IReadableAudioSource{T}.Read" /> method of the specified <paramref name="source" />
 ///     returns 0.
 /// </summary>
 /// <param name="encoder">The encoder which should be used to encode the audio data.</param>
 /// <param name="source">The <see cref="IWaveSource" /> which provides the raw audio data to encode.</param>
 public static void EncodeWholeSource(MediaFoundationEncoder encoder, IWaveSource source)
 {
     if (encoder == null)
         throw new ArgumentNullException("encoder");
     if (source == null)
         throw new ArgumentNullException("source");
     var buffer = new byte[source.WaveFormat.BytesPerSecond * 4];
     int read;
     while ((read = source.Read(buffer, 0, buffer.Length)) > 0)
     {
         Debug.WriteLine(String.Format("{0:#00.00}%", source.Position / (double) source.Length * 100));
         encoder.Write(buffer, 0, read);
     }
 }