X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=libs%2Fmidi%2B%2B2%2Fmidi%2B%2B%2Fchannel.h;h=6bd08073b371c9518a5d21e715ae2d2abf2535bd;hb=00caabf73583fa029601b7d4e9ccdb9b2da7925c;hp=d397c99ea09c9bb2d7fb496b716818a9b91d3b55;hpb=4dc63966f0872efe768dad61eb9b8785d06b92d1;p=ardour.git diff --git a/libs/midi++2/midi++/channel.h b/libs/midi++2/midi++/channel.h index d397c99ea0..6bd08073b3 100644 --- a/libs/midi++2/midi++/channel.h +++ b/libs/midi++2/midi++/channel.h @@ -21,6 +21,7 @@ #define __midichannel_h__ #include +#include #include "pbd/signals.h" #include "midi++/parser.h" @@ -75,23 +76,26 @@ class LIBMIDIPP_API Channel : public PBD::ScopedConnectionList { _controller_val[n%128] = val; } + controller_value_t rpn_value (uint16_t rpn_id); + controller_value_t nrpn_value (uint16_t rpn_id); + bool channel_msg (byte id, byte val1, byte val2, timestamp_t timestamp); bool all_notes_off (timestamp_t timestamp) { return channel_msg (MIDI::controller, 123, 0, timestamp); } - + bool control (byte id, byte value, timestamp_t timestamp) { return channel_msg (MIDI::controller, id, value, timestamp); } - + bool note_on (byte note, byte velocity, timestamp_t timestamp) { return channel_msg (MIDI::on, note, velocity, timestamp); } - + bool note_off (byte note, byte velocity, timestamp_t timestamp) { return channel_msg (MIDI::off, note, velocity, timestamp); } - + bool aftertouch (byte value, timestamp_t timestamp) { return channel_msg (MIDI::chanpress, value, 0, timestamp); } @@ -108,6 +112,11 @@ class LIBMIDIPP_API Channel : public PBD::ScopedConnectionList { return channel_msg (MIDI::pitchbend, lsb, msb, timestamp); } + float rpn_value (uint16_t rpn) const; + float nrpn_value (uint16_t nrpn) const; + float rpn_value_absolute (uint16_t rpn) const; + float nrpn_value_absolute (uint16_t nrpn) const; + protected: friend class Port; void connect_signals (); @@ -115,14 +124,26 @@ class LIBMIDIPP_API Channel : public PBD::ScopedConnectionList { private: Port& _port; + enum RPNState { + HaveLSB = 0x1, + HaveMSB = 0x2, + HaveValue = 0x4 + }; + /* Current channel values */ byte _channel_number; unsigned short _bank_number; byte _program_number; byte _rpn_msb; byte _rpn_lsb; + byte _rpn_val_msb; + byte _rpn_val_lsb; byte _nrpn_msb; byte _nrpn_lsb; + byte _nrpn_val_lsb; + byte _nrpn_val_msb; + RPNState _rpn_state; + RPNState _nrpn_state; byte _chanpress; byte _polypress[128]; bool _controller_14bit[128]; @@ -139,8 +160,13 @@ class LIBMIDIPP_API Channel : public PBD::ScopedConnectionList { bool _mono; size_t _notes_on; + typedef std::map RPNList; + + RPNList rpns; + RPNList nrpns; + void reset (timestamp_t timestamp, framecnt_t nframes, bool notes_off = true); - + void process_note_off (Parser &, EventTwoBytes *); void process_note_on (Parser &, EventTwoBytes *); void process_controller (Parser &, EventTwoBytes *); @@ -149,6 +175,14 @@ class LIBMIDIPP_API Channel : public PBD::ScopedConnectionList { void process_chanpress (Parser &, byte); void process_pitchbend (Parser &, pitchbend_t); void process_reset (Parser &); + bool maybe_process_rpns (Parser&, EventTwoBytes *); + + void rpn_reset (); + void nrpn_reset (); + + static const RPNState RPN_READY_FOR_VALUE; + static const RPNState RPN_VALUE_READY; + }; } // namespace MIDI