Beispiel #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MidiWriter"/> with the specified stream.
        /// </summary>
        /// <param name="stream">Stream to write MIDI file to.</param>
        /// <exception cref="ArgumentNullException"><paramref name="stream"/> is <c>null</c>.</exception>
        /// <exception cref="ArgumentException"><paramref name="stream"/> does not support writing,
        /// or is already closed.</exception>
        public MidiWriter(Stream stream, WriterSettings settings)
        {
            _stream       = stream;
            _useBuffering = settings.UseBuffering;

            _buffer = new byte[settings.BufferSize];
        }
Beispiel #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MidiWriter"/> with the specified stream.
        /// </summary>
        /// <param name="stream">Stream to write MIDI file to.</param>
        /// <param name="settings">Settings according to which MIDI data should be written.</param>
        /// <exception cref="ArgumentNullException">
        /// <para>One of the following errors occured:</para>
        /// <list type="bullet">
        /// <item>
        /// <description><paramref name="stream"/> is <c>null</c>.</description>
        /// </item>
        /// <item>
        /// <description><paramref name="settings"/> is <c>null</c>.</description>
        /// </item>
        /// </list>
        /// </exception>
        /// <exception cref="ArgumentException"><paramref name="stream"/> does not support writing,
        /// or is already closed.</exception>
        public MidiWriter(Stream stream, WriterSettings settings)
        {
            ThrowIfArgument.IsNull(nameof(stream), stream);
            ThrowIfArgument.IsNull(nameof(settings), settings);

            _settings = settings;

            _stream       = stream;
            _useBuffering = settings.UseBuffering;

            if (_useBuffering)
            {
                PrepareBuffer();
            }
        }