24#ifndef SBL_PROTOCOL_MIDI_MONITOR_HPP_
25#define SBL_PROTOCOL_MIDI_MONITOR_HPP_
27#ifdef SBL_MIDI_MONITOR
37inline int format_event(
char* buf,
size_t size,
const MidiEvent& e) {
38 uint8_t ch = e.channel + 1;
42 return log::format(buf, size,
"#MIDI ch=%u type=note_on num=%u vel=%u\r\n",
43 ch, e.note(), e.velocity());
45 return log::format(buf, size,
"#MIDI ch=%u type=note_off num=%u vel=%u\r\n",
46 ch, e.note(), e.velocity());
48 return log::format(buf, size,
"#MIDI ch=%u type=cc num=%u val=%u\r\n",
49 ch, e.cc_number(), e.cc_value());
51 return log::format(buf, size,
"#MIDI ch=%u type=pb val=%u\r\n",
52 ch, e.pitch_bend_raw());
54 return log::format(buf, size,
"#MIDI ch=%u type=pc val=%u\r\n",
57 return log::format(buf, size,
"#MIDI ch=%u type=cp val=%u\r\n",
60 return log::format(buf, size,
"#MIDI ch=%u type=pp num=%u val=%u\r\n",
61 ch, e.data1, e.data2);
65 return log::format(buf, size,
"#MIDI type=clock\r\n");
67 return log::format(buf, size,
"#MIDI type=start\r\n");
69 return log::format(buf, size,
"#MIDI type=continue\r\n");
71 return log::format(buf, size,
"#MIDI type=stop\r\n");
73 return log::format(buf, size,
"#MIDI type=active_sensing\r\n");
75 return log::format(buf, size,
"#MIDI type=system_reset\r\n");
79 return log::format(buf, size,
"#MIDI type=song_pos val=%u\r\n",
80 (
static_cast<uint16_t
>(e.data2) << 7) | e.data1);
82 return log::format(buf, size,
"#MIDI type=song_sel val=%u\r\n", e.data1);
84 return log::format(buf, size,
"#MIDI type=tune_req\r\n");
int format(char *buf, size_t size, const char *fmt,...)
Format a string into a buffer (snprintf-style)
MIDI parser, encoder, SMF and sequencer.