32#ifndef _NICMIDI_SYSEX_H
33#define _NICMIDI_SYSEX_H
66 void Clear() { buffer.clear(); chk_sum = 0; }
70 unsigned char GetChecksum()
const {
return (
unsigned char)(chk_sum & 0x7f); }
74 unsigned char GetData(
int i)
const {
return buffer[i]; }
77 const unsigned char*
GetBuffer()
const {
return buffer.data(); }
85 void PutSysByte(
unsigned char b) { buffer.push_back(b); }
94 {
PutByte((
unsigned char)(b & 0xf));
PutByte((
unsigned char)(b >> 4)); }
97 {
PutByte((
unsigned char)(b >> 4));
PutByte((
unsigned char)(b & 0xf)); }
103 std::vector<unsigned char> buffer;
104 unsigned char chk_sum;
106 static const unsigned char GMReset_data[];
107 static const unsigned char GSReset_data[];
108 static const unsigned char XGReset_data[];
109 static const int GMReset_len = 6;
110 static const int GSReset_len = 11;
111 static const int XGReset_len = 9;
Stores a buffer of MIDI data bytes in a std::vector, plus a byte for the checksum.
Definition: sysex.h:45
void ClearChecksum()
Resets the checksum to 0.
Definition: sysex.h:68
void PutChecksum()
Appends the checksum to the buffer.
Definition: sysex.h:99
MIDISystemExclusive(unsigned int len=0)
Creates a new object initially empty.
void PutNibblizedByteLH(unsigned char b)
Appends two bytes, containing the low (1st) and the high nibble of b. Adds them to the checksum.
Definition: sysex.h:93
unsigned char GetData(int i) const
Returns the i-th byte in the buffer.
Definition: sysex.h:74
const unsigned char * GetBuffer() const
Returns a pointer to the data buffer.
Definition: sysex.h:77
void PutByte(unsigned char b)
Appends a byte to the buffer, adding it to checksum.
Definition: sysex.h:87
MIDISystemExclusive & operator=(const MIDISystemExclusive &se)
The assignment operator.
MIDISystemExclusive(const MIDISystemExclusive &e)
The copy constructor.
MIDISystemExclusive(const unsigned char *buf, unsigned int len)
Creates a new object from the given buffer of bytes.
void PutNibblizedByteHL(unsigned char b)
Appends two bytes, containing the high (1st) and the low nibble of b. Adds them to the checksum.
Definition: sysex.h:96
bool IsXGReset() const
Returns true if the buffer contains a XG Reset sysex message.
int GetLength() const
Returns the number of data bytes stored in the buffer.
Definition: sysex.h:72
bool IsGMReset() const
Returns true if the buffer contains a GM Reset sysex message.
bool operator==(const MIDISystemExclusive &se) const
The equal operator compares the data buffer and the checksum.
bool IsGSReset() const
Returns true if the buffer contains a GS Reset sysex message.
virtual ~MIDISystemExclusive()
The destructor.
Definition: sysex.h:58
void Clear()
Resets the buffer to 0 length data and the checksum to 0.
Definition: sysex.h:66
void PutEOX()
Appends a System exclusive End byte (0xF7) to the buffer, without affecting the checksum.
Definition: sysex.h:91
void PutSysByte(unsigned char b)
Appends a byte to the buffer, without adding it to checksum.
Definition: sysex.h:85
unsigned char GetChecksum() const
Returns the checksum.
Definition: sysex.h:70
void PutEXC()
Appends a System exclusive Start byte (0xF0) to the buffer, without affecting the checksum.
Definition: sysex.h:89
@ SYSEX_START
Start of a sysex.
Definition: midi.h:101
@ SYSEX_END
End of a sysex.
Definition: midi.h:106
Contains the MIDI values enumerations (to have readable values instead of hexadecimal values) and som...