Search Results for

    Show / Hide Table of Contents

    Class MidiWriter

    Writer of the MIDI data types.
    Inheritance
    object
    MidiWriter
    Implements
    IDisposable
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: Melanchall.DryWetMidi.Core
    Assembly: Melanchall.DryWetMidi.dll
    Syntax
    public sealed class MidiWriter : IDisposable

    Constructors

    MidiWriter(Stream, WriterSettings)

    Initializes a new instance of the MidiWriter with the specified stream.
    Declaration
    public MidiWriter(Stream stream, WriterSettings settings)
    Parameters
    Type Name Description
    Stream stream Stream to write MIDI file to.
    WriterSettings settings Settings according to which MIDI data should be written.
    Exceptions
    Type Condition
    ArgumentNullException

    One of the following errors occurred:

    • stream is null.
    • settings is null.
    ArgumentException stream does not support writing, or is already closed.

    Properties

    Length

    Gets the current count of written bytes.
    Declaration
    public long Length { get; }
    Property Value
    Type Description
    long

    Methods

    Dispose()

    Releases all resources used by the current instance of the MidiWriter class.
    Declaration
    public void Dispose()

    Write3ByteDword(uint)

    Writes a DWORD value (32-bit unsigned integer) to the underlying stream as three bytes and advances the current position by three bytes.
    Declaration
    public void Write3ByteDword(uint value)
    Parameters
    Type Name Description
    uint value DWORD value to write.
    Exceptions
    Type Condition
    ObjectDisposedException Method was called after the writer was disposed.
    IOException An I/O error occurred on the underlying stream.

    WriteByte(byte)

    Writes an unsigned byte to the underlying stream and advances the stream position by one byte.
    Declaration
    public void WriteByte(byte value)
    Parameters
    Type Name Description
    byte value The unsigned byte to write.
    Exceptions
    Type Condition
    ObjectDisposedException Method was called after the writer was disposed.
    IOException An I/O error occurred on the underlying stream.

    WriteBytes(byte[])

    Writes a byte array to the underlying stream.
    Declaration
    public void WriteBytes(byte[] bytes)
    Parameters
    Type Name Description
    byte[] bytes A byte array containing the data to write.
    Exceptions
    Type Condition
    ArgumentNullException bytes is null.
    ObjectDisposedException Method was called after the writer was disposed.
    IOException An I/O error occurred on the underlying stream.

    WriteDword(uint)

    Writes a DWORD value (32-bit unsigned integer) to the underlying stream and advances the current position by four bytes.
    Declaration
    public void WriteDword(uint value)
    Parameters
    Type Name Description
    uint value DWORD value to write.
    Exceptions
    Type Condition
    ObjectDisposedException Method was called after the writer was disposed.
    IOException An I/O error occurred on the underlying stream.

    WriteInt16(short)

    Writes a INT16 value (16-bit signed integer) to the underlying stream and advances the current position by two bytes.
    Declaration
    public void WriteInt16(short value)
    Parameters
    Type Name Description
    short value INT16 value to write.
    Exceptions
    Type Condition
    ObjectDisposedException Method was called after the writer was disposed.
    IOException An I/O error occurred on the underlying stream.

    WriteSByte(sbyte)

    Writes a signed byte to the underlying stream and advances the stream position by one byte.
    Declaration
    public void WriteSByte(sbyte value)
    Parameters
    Type Name Description
    sbyte value The signed byte to write.
    Exceptions
    Type Condition
    ObjectDisposedException Method was called after the writer was disposed.
    IOException An I/O error occurred on the underlying stream.

    WriteString(string)

    Writes a string to the underlying stream as set of ASCII bytes.
    Declaration
    public void WriteString(string value)
    Parameters
    Type Name Description
    string value The string to write.
    Exceptions
    Type Condition
    ObjectDisposedException Method was called after the writer was disposed.
    IOException An I/O error occurred on the underlying stream.

    WriteVlqNumber(int)

    Writes a 32-bit signed integer to the underlying stream in compressed format called variable-length quantity (VLQ).
    Declaration
    public void WriteVlqNumber(int value)
    Parameters
    Type Name Description
    int value The value to write.
    Remarks
    Numbers in VLQ format are represented 7 bits per byte, most significant bits first. All bytes except the last have bit 7 set, and the last byte has bit 7 clear. If the number is between 0 and 127, it is thus represented exactly as one byte.
    Exceptions
    Type Condition
    ObjectDisposedException Method was called after the writer was disposed.
    IOException An I/O error occurred on the underlying stream.

    WriteVlqNumber(long)

    Writes a 64-bit signed integer to the underlying stream in compressed format called variable-length quantity (VLQ).
    Declaration
    public void WriteVlqNumber(long value)
    Parameters
    Type Name Description
    long value The value to write.
    Remarks
    Numbers in VLQ format are represented 7 bits per byte, most significant bits first. All bytes except the last have bit 7 set, and the last byte has bit 7 clear. If the number is between 0 and 127, it is thus represented exactly as one byte.
    Exceptions
    Type Condition
    ObjectDisposedException Method was called after the writer was disposed.
    IOException An I/O error occurred on the underlying stream.

    WriteWord(ushort)

    Writes a WORD value (16-bit unsigned integer) to the underlying stream and advances the current position by two bytes.
    Declaration
    public void WriteWord(ushort value)
    Parameters
    Type Name Description
    ushort value WORD value to write.
    Exceptions
    Type Condition
    ObjectDisposedException Method was called after the writer was disposed.
    IOException An I/O error occurred on the underlying stream.

    Implements

    IDisposable
    In this article
    Back to top 2024 / Generated by DocFX