26#ifdef SBL_MIDI_MONITOR
36inline int format_event(
char* buf,
size_t size,
const MidiEvent& e) {
37 uint8_t ch = e.channel + 1;
41 return log::format(buf, size,
"#MIDI ch=%u type=note_on num=%u vel=%u\r\n",
42 ch, e.note(), e.velocity());
44 return log::format(buf, size,
"#MIDI ch=%u type=note_off num=%u vel=%u\r\n",
45 ch, e.note(), e.velocity());
47 return log::format(buf, size,
"#MIDI ch=%u type=cc num=%u val=%u\r\n",
48 ch, e.cc_number(), e.cc_value());
50 return log::format(buf, size,
"#MIDI ch=%u type=pb val=%u\r\n",
51 ch, e.pitch_bend_raw());
53 return log::format(buf, size,
"#MIDI ch=%u type=pc val=%u\r\n",
56 return log::format(buf, size,
"#MIDI ch=%u type=cp val=%u\r\n",
59 return log::format(buf, size,
"#MIDI ch=%u type=pp num=%u val=%u\r\n",
60 ch, e.data1, e.data2);
64 return log::format(buf, size,
"#MIDI type=clock\r\n");
66 return log::format(buf, size,
"#MIDI type=start\r\n");
68 return log::format(buf, size,
"#MIDI type=continue\r\n");
70 return log::format(buf, size,
"#MIDI type=stop\r\n");
72 return log::format(buf, size,
"#MIDI type=active_sensing\r\n");
74 return log::format(buf, size,
"#MIDI type=system_reset\r\n");
78 return log::format(buf, size,
"#MIDI type=song_pos val=%u\r\n",
79 (
static_cast<uint16_t
>(e.data2) << 7) | e.data1);
81 return log::format(buf, size,
"#MIDI type=song_sel val=%u\r\n", e.data1);
83 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)