예제 #1
0
        /// <summary>
        /// Initializes a new instance of the WaveFormat class.
        /// </summary>
        /// <param name="waveFormatExtensible">WaveFormatExtensible instance representing an audio format.</param>
        public WaveFormat(WaveFormatExtensible waveFormatExtensible)
        {
            if (waveFormatExtensible == null)
            {
                throw new ArgumentNullException("waveFormatExtensible");
            }

            this.WaveFormatExtensible = waveFormatExtensible;
        }
예제 #2
0
        /// <summary>
        /// Initializes a new instance of the WaveFormat class.
        /// </summary>
        /// <param name="waveFormatExtensible">WaveFormatExtensible instance representing an audio format.</param>
        public WaveFormat(WaveFormatExtensible waveFormatExtensible)
        {
            if (waveFormatExtensible == null)
            {
                throw new ArgumentNullException("waveFormatExtensible");
            }

            this.WaveFormatExtensible = waveFormatExtensible;
        }
        /// <summary>
        /// Returns a string representing the structure in little-endian
        /// hexadecimal format.
        /// </summary>
        /// <remarks>
        /// The string generated here is intended to be passed as
        /// CodecPrivateData for Silverlight 2's MediaStreamSource
        /// </remarks>
        /// <returns>
        /// A string representing the structure in little-endia hexadecimal
        /// format.
        /// </returns>
        public override string ToHexString()
        {
            string s = WaveFormatExtensible.ToHexString();

            s += string.Format(CultureInfo.InvariantCulture, "{0:X4}", this.Id).ToLittleEndian();
            s += string.Format(CultureInfo.InvariantCulture, "{0:X8}", this.BitratePaddingMode).ToLittleEndian();
            s += string.Format(CultureInfo.InvariantCulture, "{0:X4}", this.BlockSize).ToLittleEndian();
            s += string.Format(CultureInfo.InvariantCulture, "{0:X4}", this.FramesPerBlock).ToLittleEndian();
            s += string.Format(CultureInfo.InvariantCulture, "{0:X4}", this.CodecDelay).ToLittleEndian();
            return(s);
        }
 /// <summary>
 /// Returns a string representing all of the fields in the object.
 /// </summary>
 /// <returns>
 /// A string representing all of the fields in the object.
 /// </returns>
 public override string ToString()
 {
     return("MPEGLAYER3 "
            + WaveFormatExtensible.ToString()
            + string.Format(
                CultureInfo.InvariantCulture,
                "ID: {0}, Flags: {1}, BlockSize: {2}, FramesPerBlock {3}, CodecDelay {4}",
                this.Id,
                this.BitratePaddingMode,
                this.BlockSize,
                this.FramesPerBlock,
                this.CodecDelay));
 }
예제 #5
0
 /// <summary>
 /// Initializes a new instance of the HeAacWaveFormat class.
 /// </summary>
 /// <param name="waveFormatExtensible">WaveFormatExtensible instance representing this audio format.</param>
 public HeAacWaveFormat(WaveFormatExtensible waveFormatExtensible)
     : base(waveFormatExtensible)
 {
 }
예제 #6
0
 /// <summary>
 /// Initializes a new instance of the HeAacWaveFormat class.
 /// </summary>
 /// <param name="waveFormatExtensible">WaveFormatExtensible instance representing this audio format.</param>
 public HeAacWaveFormat(WaveFormatExtensible waveFormatExtensible)
     : base(waveFormatExtensible)
 {
 }
예제 #7
0
        /// <summary>
        /// Initializes a WaveFormatExtensible instance representing an MP3 frame.
        /// </summary>
        /// <param name="audioFrame">Audio frame representing an MP3 frame.</param>
        /// <returns>A WaveFormatExtensible for the supplied audio frame.</returns>
        private static MpegLayer3WaveFormat CreateMp3WaveFormat(AudioFrame audioFrame)
        {
            if (audioFrame == null)
            {
                throw new ArgumentNullException("audioFrame");
            }

            WaveFormatExtensible waveFormatExtensible = new WaveFormatExtensible()
            {
                AverageBytesPerSecond = audioFrame.BitRate / 8,
                BitsPerSample = 0,
                BlockAlign = 1,
                Channels = (short)audioFrame.NumberOfChannels,
                FormatTag = 85,
                SamplesPerSec = audioFrame.SamplingRate,
                Size = 12
            };

            MpegLayer3WaveFormat waveFormat = new MpegLayer3WaveFormat(waveFormatExtensible);
            waveFormat.Id = 1;
            waveFormat.BitratePaddingMode = 0;
            waveFormat.FramesPerBlock = 1;
            waveFormat.BlockSize = (short)audioFrame.FrameSize;
            waveFormat.CodecDelay = 0;

            return waveFormat;
        }
예제 #8
0
        /// <summary>
        /// Initializes a WaveFormatExtensible instance representing an AAC+ frame.
        /// </summary>
        /// <param name="audioFrame">Audio frame representing an AAC+ frame.</param>
        /// <returns>A WaveFormatExtensible for the supplied audio frame.</returns>
        private static HeAacWaveFormat CreateAacPlusFormat(AudioFrame audioFrame)
        {
            if (audioFrame == null)
            {
                throw new ArgumentNullException("audioFrame");
            }

            WaveFormatExtensible wfx = new WaveFormatExtensible();

            wfx.FormatTag = 0x1610;
            wfx.Channels = (short)audioFrame.NumberOfChannels;
            wfx.SamplesPerSec = audioFrame.SamplingRate;
            wfx.AverageBytesPerSecond = audioFrame.BitRate / 8;
            wfx.BlockAlign = 1;
            wfx.BitsPerSample = 0;
            wfx.Size = 12;

            HeAacWaveFormat aacf = new HeAacWaveFormat(wfx);

            // Extra 3 words in WAVEFORMATEX
            aacf.PayloadType = 0x1; // Audio Data Transport Stream (ADTS). The stream contains an adts_sequence, as defined by MPEG-2.
            aacf.AudioProfileLevelIndication = 0xFE;
            aacf.StructType = 0;

            return aacf;
        }
 /// <summary>
 /// Initializes a new instance of the MpegLayer3WaveFormat class.
 /// </summary>
 /// <param name="waveFormatExtensible">WaveFormatExtensible instance representing this audio format.</param>
 public MpegLayer3WaveFormat(WaveFormatExtensible waveFormatExtensible)
     : base(waveFormatExtensible)
 {
 }
예제 #10
0
 /// <summary>
 /// Initializes a new instance of the MpegLayer3WaveFormat class.
 /// </summary>
 /// <param name="waveFormatExtensible">WaveFormatExtensible instance representing this audio format.</param>
 public MpegLayer3WaveFormat(WaveFormatExtensible waveFormatExtensible)
     : base(waveFormatExtensible)
 {
 }