Class BytesToMidiEventConverter
Provides methods to convert bytes to an instance of the
MidiEvent.
Inheritance
BytesToMidiEventConverter
Assembly: Melanchall.DryWetMidi.dll
Syntax
public sealed class BytesToMidiEventConverter : IDisposable
Constructors
BytesToMidiEventConverter()
Declaration
public BytesToMidiEventConverter()
BytesToMidiEventConverter(int)
Declaration
public BytesToMidiEventConverter(int capacity)
Parameters
Type |
Name |
Description |
int |
capacity |
Initial capacity of the internal buffer. |
Exceptions
Properties
Gets or sets the format of source bytes layout. The default is
File.
Declaration
public BytesFormat BytesFormat { get; set; }
Property Value
Exceptions
Gets or sets collection of custom meta events types.
Declaration
public EventTypesCollection CustomMetaEventTypes { get; set; }
Property Value
DecodeTextCallback
Gets or sets a callback used to decode a string from the specified bytes during reading a text-based
meta event's text. The default is null
.
Declaration
public DecodeTextCallback DecodeTextCallback { get; set; }
Property Value
InvalidChannelEventParameterValuePolicy
Gets or sets reaction of the reading engine on invalid value of a channel event's
parameter value. The default is
Abort.
Declaration
public InvalidChannelEventParameterValuePolicy InvalidChannelEventParameterValuePolicy { get; set; }
Property Value
Exceptions
Gets or sets reaction of the reading engine on invalid value of a meta event's
parameter value. The default is
Abort.
Declaration
public InvalidMetaEventParameterValuePolicy InvalidMetaEventParameterValuePolicy { get; set; }
Property Value
Exceptions
InvalidSystemCommonEventParameterValuePolicy
Gets or sets reaction of the reading engine on invalid value of a system common event's
parameter value. The default is
Abort.
Declaration
public InvalidSystemCommonEventParameterValuePolicy InvalidSystemCommonEventParameterValuePolicy { get; set; }
Property Value
Exceptions
NotEnoughBytesPolicy
Gets or sets reaction of the reading engine on lack of bytes in the underlying stream
that are needed to read MIDI data (for example, DWORD requires 4 bytes available).
The default is
Abort.
Declaration
public NotEnoughBytesPolicy NotEnoughBytesPolicy { get; set; }
Property Value
Exceptions
ReadDeltaTimes
Gets or sets a value indicating whether incoming bytes array contains delta-times before
each event data (and thus they must be read) or not. The default value is false
.
Declaration
public bool ReadDeltaTimes { get; set; }
Property Value
SilentNoteOnPolicy
Gets or sets reaction of the reading engine on
Note On
events with velocity of zero.
The default is
NoteOff.
Declaration
public SilentNoteOnPolicy SilentNoteOnPolicy { get; set; }
Property Value
Exceptions
TextEncoding
Gets or sets an
Encoding that will be used to read the text of a
text-based meta events. The default is
ASCII.
Declaration
public Encoding TextEncoding { get; set; }
Property Value
UnknownChannelEventCallback
Declaration
public UnknownChannelEventCallback UnknownChannelEventCallback { get; set; }
Property Value
UnknownChannelEventPolicy
Gets or sets reaction of the reading engine on unknown channel event. The default is
Abort.
Declaration
public UnknownChannelEventPolicy UnknownChannelEventPolicy { get; set; }
Property Value
Exceptions
ZeroLengthDataPolicy
Gets or sets reaction of the reading engine on zero-length objects such as strings or arrays.
The default is
ReadAsEmptyObject.
Declaration
public ZeroLengthDataPolicy ZeroLengthDataPolicy { get; set; }
Property Value
Exceptions
Methods
Convert(byte, byte[])
Converts the specified status byte and data bytes to an instance of the
MidiEvent.
Declaration
public MidiEvent Convert(byte statusByte, byte[] dataBytes)
Parameters
Type |
Name |
Description |
byte |
statusByte |
The status byte of MIDI event. |
byte[] |
dataBytes |
Data bytes of MIDI event (bytes except status byte). Can be null
if MIDI event has no data bytes. |
Returns
Convert(byte[])
Converts the specified bytes to an instance of the
MidiEvent. First byte is
the status byte of MIDI event. If bytes array contains multiple events, only first one will be read.
Declaration
public MidiEvent Convert(byte[] bytes)
Parameters
Type |
Name |
Description |
byte[] |
bytes |
Bytes representing a MIDI event. |
Returns
Exceptions
Convert(byte[], int, int)
Converts sub-array of the specified bytes to an instance of the
MidiEvent. First byte
at the specified offset is the status byte of MIDI event. If sub-array contains multiple events, only
first one will be read.
Declaration
public MidiEvent Convert(byte[] bytes, int offset, int length)
Parameters
Type |
Name |
Description |
byte[] |
bytes |
Bytes to take sub-array from. |
int |
offset |
Offset of sub-array to read MIDI event from. |
int |
length |
Length of sub-array to read MIDI event from. |
Returns
Type |
Description |
MidiEvent |
MidiEvent read from bytes starting from
offset and taking length of bytes. |
Exceptions
ConvertMultiple(byte[])
Converts the specified bytes to a collection of
MidiEvent.
Declaration
public ICollection<MidiEvent> ConvertMultiple(byte[] bytes)
Parameters
Type |
Name |
Description |
byte[] |
bytes |
Bytes to convert to collection of MidiEvent. |
Returns
Exceptions
ConvertMultiple(byte[], int, int)
Converts sub-array of the specified bytes to a collection of
MidiEvent.
Declaration
public ICollection<MidiEvent> ConvertMultiple(byte[] bytes, int offset, int length)
Parameters
Type |
Name |
Description |
byte[] |
bytes |
Bytes to take sub-array from. |
int |
offset |
Offset of sub-array to read MIDI events from. |
int |
length |
Length of sub-array to read MIDI events from. |
Returns
Exceptions
Dispose()
Declaration
Implements