예제 #1
0
        public MP3Format(int sampleRate, int channels, int blockSize, int bitRate)
            : base(sampleRate, 0, channels, AudioEncoding.MpegLayer3, Mp3WaveFormatExtraBytes)
        {
            if (bitRate < 0)
                throw new ArgumentOutOfRangeException("bitRate");

            _bytesPerSecond = bitRate / 8;
            blockAlign = 1; // must be 1

            extraSize = Mp3WaveFormatExtraBytes;
            _id = Mp3FormatId.Mpeg;
            _flags = Mp3PaddingFlags.PaddingIso;
            blockSize = (ushort)blockSize;
            _framesPerBlock = 1;
            _codecDelay = 0;
        }
예제 #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Mp3Format"/> class.
        /// </summary>
        /// <param name="sampleRate">Sample rate in Hz.</param>
        /// <param name="channels">Number of channels.</param>
        /// <param name="blockSize">Block size in bytes. This value equals the frame length in bytes x <see cref="FramesPerBlock"/>. For MP3 audio, the frame length is calculated as follows: 144 x (bitrate / sample rate) + padding.</param>
        /// <param name="bitRate">Bitrate.</param>
        public Mp3Format(int sampleRate, int channels, int blockSize, int bitRate)
            : base(sampleRate, 0, channels, AudioEncoding.MpegLayer3, Mp3WaveFormatExtraBytes)
        {
            if (bitRate < 0)
            {
                throw new ArgumentOutOfRangeException("bitRate");
            }

            BytesPerSecond = bitRate / 8;
            BlockAlign     = 1; // must be 1

            ExtraSize      = Mp3WaveFormatExtraBytes;
            Id             = Mp3FormatId.Mpeg;
            Flags          = Mp3PaddingFlags.PaddingIso;
            BlockSize      = (short)blockSize;
            FramesPerBlock = 1;
            CodecDelay     = 0;
        }