2 #include <ossia/dataflow/value_vector.hpp>
4 #include <libremidi/message.hpp>
11 static const constexpr
int which = 1;
13 value_vector<libremidi::message> messages;
15 using message = libremidi::message;
16 using message_type = libremidi::message_type;
17 using midi_bytes = libremidi::midi_bytes;
19 message& note_on(uint8_t channel, uint8_t note, uint8_t velocity) noexcept
21 return create(make_command(message_type::NOTE_ON, channel), note, velocity);
24 message& note_off(uint8_t channel, uint8_t note, uint8_t velocity) noexcept
26 return create(make_command(message_type::NOTE_OFF, channel), note, velocity);
29 message& control_change(uint8_t channel, uint8_t control, uint8_t value) noexcept
31 return create(make_command(message_type::CONTROL_CHANGE, channel), control, value);
34 message& program_change(uint8_t channel, uint8_t value) noexcept
36 return create(make_command(message_type::PROGRAM_CHANGE, channel), value);
39 message& pitch_bend(uint8_t channel,
int value) noexcept
42 make_command(message_type::PITCH_BEND, channel), (
unsigned char)(value & 0x7F),
43 (uint8_t)((value >> 7) & 0x7F));
46 message& pitch_bend(uint8_t channel, uint8_t lsb, uint8_t msb) noexcept
48 return create(make_command(message_type::PITCH_BEND, channel), lsb, msb);
51 message& poly_pressure(uint8_t channel, uint8_t note, uint8_t value) noexcept
53 return create(make_command(message_type::POLY_PRESSURE, channel), note, value);
56 message& aftertouch(uint8_t channel, uint8_t value) noexcept
58 return create(make_command(message_type::AFTERTOUCH, channel), value);
62 static uint8_t make_command(
const message_type type,
const int channel) noexcept
64 return (uint8_t)((uint8_t)type |
std::clamp(channel, 0, channel - 1));
67 message& create(uint8_t b0, uint8_t b1) noexcept
69 auto& m = messages.emplace_back();
73 message& create(uint8_t b0, uint8_t b1, uint8_t b2) noexcept
75 auto& m = messages.emplace_back();
76 m.bytes = {b0, b1, b2};
81 struct midi_delay_line
83 std::vector<value_vector<libremidi::message>> messages;
constexpr OSSIA_INLINE T clamp(T d, const T min, const T max) noexcept
clamp Returns the value bounded by a min and a max
Definition: math.hpp:154