示例#1
0
        /// <summary>Initializes a new <see cref="WaveFormatExtensible"/> structure.</summary>
        /// <param name="samplesPerSecond">The sample rate, in hertz (Hz).</param>
        /// <param name="averageBytesPerSecond">For buffer estimation.</param>
        /// <param name="blockAlign">The block size of data, in bytes.</param>
        /// <param name="bitsPerSample">The number of bits per sample.</param>
        /// <param name="samples">Either ValidBitsPerSample, SamplesPerBlock or Reserved(0).</param>
        /// <param name="channelMask">Indicates which channels are present in the stream.</param>
        /// <param name="subFormat">Sub format <see cref="Guid"/>.</param>
        /// <exception cref="ArgumentOutOfRangeException"/>
        /// <exception cref="InvalidEnumArgumentException"/>
        public WaveFormatExtensible(int samplesPerSecond, int averageBytesPerSecond, int blockAlign, int bitsPerSample, int samples, AudioChannels channelMask, Guid subFormat)
        {
            if (samples < 0 || samples > ushort.MaxValue)
            {
                throw new ArgumentOutOfRangeException("samples");
            }

            try
            {
                baseFormat = new WaveFormatEx((short)WaveFormatTag.Extensible, channelMask.GetChannelCount(), samplesPerSecond, averageBytesPerSecond, blockAlign, bitsPerSample, ExpectedExtraInfoSize);
            }
            catch (ArgumentOutOfRangeException)
            {
                throw;
            }

            this.samples     = (ushort)samples;
            this.channelMask = channelMask;
            this.subFormat   = subFormat;
        }