attempt to handle poly-pressure (polyphonic aftertouch) similarly to other MIDI messages
[ardour.git] / libs / evoral / evoral / MIDIEvent.hpp
index d6541bafeb5b8c8eed5a16e5362f5ea04947d521..1ce70747883ccd186a6cf8ad9b433f106e71e4df 100644 (file)
@@ -39,7 +39,7 @@ namespace Evoral {
  * valid MIDI data for these functions to make sense.
  */
 template<typename Time>
-class LIBEVORAL_API MIDIEvent : public Event<Time> {
+class /*LIBEVORAL_API*/ MIDIEvent : public Event<Time> {
 public:
        MIDIEvent(EventType type=0, Time time=0, uint32_t size=0, uint8_t* buf=NULL, bool alloc=false)
                : Event<Time>(type, time, size, buf, alloc)
@@ -71,7 +71,7 @@ public:
        inline bool     is_pitch_bender()       const { return (type() == MIDI_CMD_BENDER); }
        inline bool     is_pgm_change()         const { return (type() == MIDI_CMD_PGM_CHANGE); }
        inline bool     is_note()               const { return (is_note_on() || is_note_off()); }
-       inline bool     is_aftertouch()         const { return (type() == MIDI_CMD_NOTE_PRESSURE); }
+       inline bool     is_poly_pressure()      const { return (type() == MIDI_CMD_NOTE_PRESSURE); }
        inline bool     is_channel_pressure()   const { return (type() == MIDI_CMD_CHANNEL_PRESSURE); }
        inline uint8_t  note()                  const { return (this->_buf[1]); }
        inline void     set_note(uint8_t n)           { this->_buf[1] = n; }
@@ -92,7 +92,8 @@ public:
                                                                | (0x7F & this->_buf[1]) ); }
        inline uint8_t  pgm_number()              const { return (this->_buf[1]); }
        inline void     set_pgm_number(uint8_t number)  { this->_buf[1] = number; }
-       inline uint8_t  aftertouch()              const { return (this->_buf[1]); }
+       inline uint8_t  poly_note()               const { return (this->_buf[1]); }
+       inline uint8_t  poly_pressure()           const { return (this->_buf[2]); }
        inline uint8_t  channel_pressure()        const { return (this->_buf[1]); }
        inline bool     is_channel_event()        const { return (0x80 <= type()) && (type() <= 0xE0); }
        inline bool     is_smf_meta_event()       const { return this->_buf[0] == 0xFF; }
@@ -101,9 +102,24 @@ public:
        inline bool     is_spp()                  const { return this->_buf[0] == 0xF2 && this->size() == 1; }
        inline bool     is_mtc_quarter()          const { return this->_buf[0] == 0xF1 && this->size() == 1; }
        inline bool     is_mtc_full()             const {
-               return this->size() == 10    && this->_buf[0] == 0xf0 && this->_buf[1] == 0x7f && 
+               return this->size() == 10    && this->_buf[0] == 0xf0 && this->_buf[1] == 0x7f &&
                       this->_buf[3] == 0x01 && this->_buf[4] == 0x01;
        }
+
+       inline uint16_t value() const {
+               switch (type()) {
+               case MIDI_CMD_CONTROL:
+                       return cc_value();
+               case MIDI_CMD_BENDER:
+                       return pitch_bender_value();
+               case MIDI_CMD_NOTE_PRESSURE:
+                       return poly_pressure();
+               case MIDI_CMD_CHANNEL_PRESSURE:
+                       return channel_pressure();
+               default:
+                       return 0;
+               }
+       }
 };
 
 } // namespace Evoral