Fix event type and parameter type confusion
authorDavid Robillard <d@drobilla.net>
Mon, 7 Nov 2016 10:14:55 +0000 (05:14 -0500)
committerDavid Robillard <d@drobilla.net>
Sat, 3 Dec 2016 20:28:19 +0000 (15:28 -0500)
I'm not sure if this is really the best way to do event types (should it
just be a completely static enum in evoral, or completely dynamic and
provided by the type map, or a mix like currently?), but previously the
event type was frequently set to either total garbage, or parameter
types, which are a different thing.

This fixes all those cases, and makes Evoral::EventType an enum so the
compiler will warn about implicit conversions from int.

20 files changed:
libs/ardour/ardour/event_type_map.h
libs/ardour/ardour/midi_buffer.h
libs/ardour/async_midi_port.cc
libs/ardour/event_type_map.cc
libs/ardour/import.cc
libs/ardour/midi_buffer.cc
libs/ardour/midi_diskstream.cc
libs/ardour/midi_state_tracker.cc
libs/ardour/midi_track.cc
libs/ardour/smf_source.cc
libs/evoral/evoral/Event.hpp
libs/evoral/evoral/Parameter.hpp
libs/evoral/evoral/PatchChange.hpp
libs/evoral/evoral/TypeMap.hpp
libs/evoral/evoral/types.hpp
libs/evoral/src/Note.cpp
libs/evoral/src/Sequence.cpp
libs/evoral/test/SMFTest.cpp
libs/evoral/test/SequenceTest.cpp
libs/evoral/test/SequenceTest.hpp

index d7adfa8f626ca35559fa825ee83fc70f855838f4..b3aa05ee78c8721c80911917da82e59a439c8c32 100644 (file)
@@ -43,7 +43,9 @@ public:
 
        bool     type_is_midi(uint32_t type) const;
        uint8_t  parameter_midi_type(const Evoral::Parameter& param) const;
-       uint32_t midi_event_type(uint8_t status) const;
+
+       Evoral::ParameterType midi_parameter_type(const uint8_t* buf, uint32_t len) const;
+
        Evoral::ControlList::InterpolationStyle interpolation_of(const Evoral::Parameter& param);
 
        Evoral::Parameter from_symbol(const std::string& str) const;
index 1b0bf2a151a6919a53d6d5ff42519c6d7a7e902d..cc48e28d618fa5b8ee2446a2155b4cbdfa51f618 100644 (file)
@@ -20,8 +20,9 @@
 #ifndef __ardour_midi_buffer_h__
 #define __ardour_midi_buffer_h__
 
-#include "evoral/midi_util.h"
 #include "evoral/EventSink.hpp"
+#include "evoral/midi_util.h"
+#include "evoral/types.hpp"
 
 #include "midi++/event.h"
 
@@ -93,7 +94,7 @@ public:
                        uint8_t* ev_start = buffer->_data + offset + sizeof(TimeType);
                        int event_size = Evoral::midi_event_size(ev_start);
                        assert(event_size >= 0);
-                       return EventType(midi_parameter_type(*ev_start),
+                       return EventType(Evoral::MIDI_EVENT,
                                        *(reinterpret_cast<TimeType*>((uintptr_t)(buffer->_data + offset))),
                                        event_size, ev_start);
                }
@@ -166,8 +167,6 @@ public:
                return iterator (*this, i.offset);
        }
 
-       uint8_t* data() const { return _data; }
-
        /**
         * returns true if the message with the second argument as its MIDI
         * status byte should preceed the message with the first argument as
index ce8ab40a0166b1fc687e87d5caa93aaeac6513cf..f7147676b0b5286775e92546af9982be42e8d065 100644 (file)
@@ -143,7 +143,7 @@ AsyncMIDIPort::cycle_start (MIDI::pframes_t nframes)
                        if (!have_timer) {
                                when += (*b).time();
                        }
-                       input_fifo.write (when, (Evoral::EventType) 0, (*b).size(), (*b).buffer());
+                       input_fifo.write (when, Evoral::NO_EVENT, (*b).size(), (*b).buffer());
                }
 
                if (!mb.empty()) {
index 87fe4bc6e13219ec1d0a99a7f05116f74ba32271..ca7b51eb2724d7b28a707c712ca47f1cfc540c68 100644 (file)
@@ -62,10 +62,10 @@ EventTypeMap::parameter_midi_type(const Evoral::Parameter& param) const
        return ARDOUR::parameter_midi_type((AutomationType)param.type());
 }
 
-uint32_t
-EventTypeMap::midi_event_type(uint8_t status) const
+Evoral::ParameterType
+EventTypeMap::midi_parameter_type(const uint8_t* buf, uint32_t len) const
 {
-       return (uint32_t)ARDOUR::midi_parameter_type(status);
+       return (uint32_t)ARDOUR::midi_parameter_type(buf[0]);
 }
 
 Evoral::ControlList::InterpolationStyle
index 36dc48e65194c8e789b425429b43a8faa101c5d4..d441494ad7c5a5e7a969aeda3fe99b5767be5c88 100644 (file)
@@ -418,7 +418,7 @@ write_midi_data_to_new_files (Evoral::SMF* source, ImportStatus& status,
                                smfs->append_event_beats(
                                        source_lock,
                                        Evoral::Event<Evoral::Beats>(
-                                               0,
+                                               Evoral::MIDI_EVENT,
                                                Evoral::Beats::ticks_at_rate(t, source->ppqn()),
                                                size,
                                                buf));
index 652be5290c83a746967036840cff19f9bc62af61..adad9c35dc454f9b6128d4d7925a3d5b8688c6ea 100644 (file)
@@ -85,7 +85,7 @@ MidiBuffer::copy(MidiBuffer const * const copy)
 {
        assert(_capacity >= copy->size ());
        _size = copy->size ();
-       memcpy(_data, copy->data(), _size);
+       memcpy(_data, copy->_data, _size);
 }
 
 
index 22a3df1145c929e1302cdf1768ead7a0794f6f9c..675d1db0bf0e7b28502a10b5a5c16a83dc4d386f 100644 (file)
@@ -445,7 +445,7 @@ MidiDiskstream::process (BufferSet& bufs, framepos_t transport_frame, pframes_t
                        }
 
                        if (!filter || !filter->filter(ev.buffer(), ev.size())) {
-                               _capture_buf->write(event_time, ev.type(), ev.size(), ev.buffer());
+                               _capture_buf->write(event_time, ev.event_type(), ev.size(), ev.buffer());
                        }
                }
                g_atomic_int_add(const_cast<gint*>(&_frames_pending_write), nframes);
index 17ecd10e9469dbaf13d869701459c5b68170994b..4374c064635fa47d61d3d985e1136df1ec60dc10 100644 (file)
@@ -123,7 +123,7 @@ MidiStateTracker::resolve_notes (MidiBuffer &dst, framepos_t time)
                        while (_active_notes[note + 128 * channel]) {
                                uint8_t buffer[3] = { ((uint8_t) (MIDI_CMD_NOTE_OFF | channel)), uint8_t (note), 0 };
                                Evoral::Event<MidiBuffer::TimeType> noteoff
-                                       (MIDI_CMD_NOTE_OFF, time, 3, buffer, false);
+                                       (Evoral::MIDI_EVENT, time, 3, buffer, false);
                                /* note that we do not care about failure from
                                   push_back() ... should we warn someone ?
                                */
@@ -157,7 +157,7 @@ MidiStateTracker::resolve_notes (Evoral::EventSink<framepos_t> &dst, framepos_t
                                /* note that we do not care about failure from
                                   write() ... should we warn someone ?
                                */
-                               dst.write (time, midi_parameter_type (buf[0]), 3, buf);
+                               dst.write (time, Evoral::MIDI_EVENT, 3, buf);
                                _active_notes[note + 128 * channel]--;
                                DEBUG_TRACE (PBD::DEBUG::MidiTrackers, string_compose ("%1: EVS-resolved note %2/%3 at %4\n",
                                                                                       this, (int) note, (int) channel, time));
@@ -181,7 +181,7 @@ MidiStateTracker::resolve_notes (MidiSource& src, const MidiSource::Lock& lock,
        for (int channel = 0; channel < 16; ++channel) {
                for (int note = 0; note < 128; ++note) {
                        while (_active_notes[note + 128 * channel]) {
-                               Evoral::Event<Evoral::Beats> ev ((MIDI_CMD_NOTE_OFF|channel), time, 3, 0, true);
+                               Evoral::Event<Evoral::Beats> ev (Evoral::MIDI_EVENT, time, 3, 0, true);
                                ev.set_type (MIDI_CMD_NOTE_OFF);
                                ev.set_channel (channel);
                                ev.set_note (note);
index 69291f1cce3031f398a2e17d7fb161f7e9b34282..c17bc916d9cbab61842f74632dad974dadd2a0d1 100644 (file)
@@ -557,7 +557,7 @@ MidiTrack::push_midi_input_to_step_edit_ringbuffer (framecnt_t nframes)
 
                        if (ev.is_note_on()) {
                                /* we don't care about the time for this purpose */
-                               _step_edit_ring_buffer.write (0, ev.type(), ev.size(), ev.buffer());
+                               _step_edit_ring_buffer.write (0, ev.event_type(), ev.size(), ev.buffer());
                        }
                }
        }
@@ -689,8 +689,7 @@ MidiTrack::write_immediate_event(size_t size, const uint8_t* buf)
                cerr << "WARNING: Ignoring illegal immediate MIDI event" << endl;
                return false;
        }
-       const uint32_t type = midi_parameter_type(buf[0]);
-       return (_immediate_events.write (0, type, size, buf) == size);
+       return (_immediate_events.write (0, Evoral::MIDI_EVENT, size, buf) == size);
 }
 
 void
index bcd3e437496e50a32eef20ce6bb393ac867ef8c0..6a05ab706dd1416ced741ccacc5fbd6f205cc0f7 100644 (file)
@@ -231,7 +231,6 @@ SMFSource::read_unlocked (const Lock&                    lock,
 
        // Output parameters for read_event (which will allocate scratch in buffer as needed)
        uint32_t ev_delta_t = 0;
-       uint32_t ev_type    = 0;
        uint32_t ev_size    = 0;
        uint8_t* ev_buffer  = 0;
 
@@ -277,10 +276,8 @@ SMFSource::read_unlocked (const Lock&                    lock,
                        continue;
                }
 
-               ev_type = midi_parameter_type(ev_buffer[0]);
-
-               DEBUG_TRACE (DEBUG::MidiSourceIO, string_compose ("SMF read_unlocked delta %1, time %2, buf[0] %3, type %4\n",
-                                                                 ev_delta_t, time, ev_buffer[0], ev_type));
+               DEBUG_TRACE (DEBUG::MidiSourceIO, string_compose ("SMF read_unlocked delta %1, time %2, buf[0] %3\n",
+                                                                 ev_delta_t, time, ev_buffer[0]));
 
                assert(time >= start_ticks);
 
@@ -295,7 +292,7 @@ SMFSource::read_unlocked (const Lock&                    lock,
 
                if (ev_frame_time < start + duration) {
                        if (!filter || !filter->filter(ev_buffer, ev_size)) {
-                               destination.write (ev_frame_time, ev_type, ev_size, ev_buffer);
+                               destination.write (ev_frame_time, Evoral::MIDI_EVENT, ev_size, ev_buffer);
                                if (tracker) {
                                        tracker->track(ev_buffer);
                                }
@@ -377,7 +374,7 @@ SMFSource::write_unlocked (const Lock&                 lock,
                time -= position;
 
                ev.set(buf, size, time);
-               ev.set_event_type(midi_parameter_type(ev.buffer()[0]));
+               ev.set_event_type(Evoral::MIDI_EVENT);
                ev.set_id(Evoral::next_event_id());
 
                if (!(ev.is_channel_event() || ev.is_smf_meta_event() || ev.is_sysex())) {
@@ -674,7 +671,6 @@ SMFSource::load_model (const Glib::Threads::Mutex::Lock& lock, bool force_reload
                                if (!have_event_id) {
                                        event_id = Evoral::next_event_id();
                                }
-                               const uint32_t            event_type = midi_parameter_type(buf[0]);
                                const Evoral::Beats event_time = Evoral::Beats::ticks_at_rate(time, ppqn());
 #ifndef NDEBUG
                                std::string ss;
@@ -685,13 +681,13 @@ SMFSource::load_model (const Glib::Threads::Mutex::Lock& lock, bool force_reload
                                        ss += b;
                                }
 
-                               DEBUG_TRACE (DEBUG::MidiSourceIO, string_compose ("SMF %7 load model delta %1, time %2, size %3 buf %4, type %5 id %6\n",
-                                                       delta_t, time, size, ss , event_type, event_id, name()));
+                               DEBUG_TRACE (DEBUG::MidiSourceIO, string_compose ("SMF %7 load model delta %1, time %2, size %3 buf %4, id %6\n",
+                                                       delta_t, time, size, ss, event_id, name()));
 #endif
 
                                eventlist.push_back(make_pair (
                                                        new Evoral::Event<Evoral::Beats> (
-                                                               event_type, event_time,
+                                                               Evoral::MIDI_EVENT, event_time,
                                                                size, buf, true)
                                                        , event_id));
 
index 526513b3fe2921c3b3046c54eb7566ec4b091d4d..696fb995ab3c358d63466b37b86bdc74d0bbb89e 100644 (file)
@@ -48,7 +48,7 @@ template<typename Time>
 class LIBEVORAL_API Event {
 public:
 #ifdef EVORAL_EVENT_ALLOC
-       Event(EventType type=0, Time time=Time(), uint32_t size=0, uint8_t* buf=NULL, bool alloc=false);
+       Event(EventType type=NO_EVENT, Time time=Time(), uint32_t size=0, uint8_t* buf=NULL, bool alloc=false);
 
        Event(EventType type, Time time, uint32_t size, const uint8_t* buf);
 
@@ -108,7 +108,7 @@ public:
        }
 
        inline void clear() {
-               _type          = 0;
+               _type          = NO_EVENT;
                _original_time = Time();
                _nominal_time  = Time();
                _size          = 0;
index 1412699b4d2fab28c4b92b53f03d021d6a918b5e..2614a03d867de4ede9b46fefca4aacf171c48702 100644 (file)
@@ -25,6 +25,7 @@
 #include <boost/shared_ptr.hpp>
 
 #include "evoral/visibility.h"
+#include "evoral/types.hpp"
 
 namespace Evoral {
 
@@ -40,13 +41,13 @@ namespace Evoral {
 class LIBEVORAL_API Parameter
 {
 public:
-       inline Parameter(uint32_t type, uint8_t channel=0, uint32_t id=0)
+       inline Parameter(ParameterType type, uint8_t channel=0, uint32_t id=0)
                : _type(type), _id(id), _channel(channel)
        {}
 
-       inline uint32_t type()    const { return _type; }
-       inline uint8_t  channel() const { return _channel; }
-       inline uint32_t id()      const { return _id; }
+       inline ParameterType type()    const { return _type; }
+       inline uint8_t       channel() const { return _channel; }
+       inline uint32_t      id()      const { return _id; }
 
        /** Equivalence operator
         * It is obvious from the definition that this operator
@@ -80,9 +81,9 @@ public:
        inline operator bool() const { return (_type != 0); }
 
 private:
-       uint32_t _type;
-       uint32_t _id;
-       uint8_t  _channel;
+       ParameterType _type;
+       uint32_t      _id;
+       uint8_t       _channel;
 };
 
 } // namespace Evoral
index a775a72cc31f9529f9a2373484a8b7be721afaa3..90d3dba732b5c3132a83ff7d6542aff1983f6dd3 100644 (file)
@@ -39,9 +39,9 @@ public:
         *  @param b Bank number (counted from 0, 14-bit).
         */
        PatchChange (Time t, uint8_t c, uint8_t p, int b)
-               : _bank_change_msb (0, t, 3, 0, true)
-               , _bank_change_lsb (0, t, 3, 0, true)
-               , _program_change (0, t, 2, 0, true)
+               : _bank_change_msb (MIDI_EVENT, t, 3, 0, true)
+               , _bank_change_lsb (MIDI_EVENT, t, 3, 0, true)
+               , _program_change (MIDI_EVENT, t, 2, 0, true)
        {
                _bank_change_msb.buffer()[0] = MIDI_CMD_CONTROL | c;
                _bank_change_msb.buffer()[1] = MIDI_CTL_MSB_BANK;
index d09439daa6b304a73f7535d675d7306bd96a9880..0ebc81370bf5daa86c8582c02bbf36c761b706be 100644 (file)
@@ -24,6 +24,7 @@
 #include <string>
 
 #include "evoral/visibility.h"
+#include "evoral/types.hpp"
 
 namespace Evoral {
 
@@ -47,9 +48,8 @@ public:
         */
        virtual uint8_t parameter_midi_type(const Parameter& param) const = 0;
 
-       /** The type ID for a MIDI event with the given status byte
-        */
-       virtual uint32_t midi_event_type(uint8_t status) const = 0;
+       /** The parameter type for the given MIDI event. */
+       virtual ParameterType midi_parameter_type(const uint8_t* buf, uint32_t len) const = 0;
 
        /** Return the description of a parameter. */
        virtual ParameterDescriptor descriptor(const Parameter& param) const = 0;
index a5d4a8ca1e8f8e22a0771d6140d7a88ea2a0d088..72b95f84604f411b03914121f872297d2f0844ab 100644 (file)
@@ -1,5 +1,5 @@
 /* This file is part of Evoral.
- * Copyright (C) 2008 David Robillard <http://drobilla.net>
+ * Copyright (C) 2008-2016 David Robillard <http://drobilla.net>
  * Copyright (C) 2000-2008 Paul Davis
  *
  * Evoral is free software; you can redistribute it and/or modify it under the
@@ -37,8 +37,23 @@ namespace Evoral {
 */
 typedef int32_t event_id_t;
 
-/** Type of an event (opaque, mapped by application) */
-typedef uint32_t EventType;
+/** Type of an event (opaque, mapped by application, e.g. MIDI).
+ *
+ * Event types are really an arbitrary integer provided by the type map, and it
+ * is safe to use values not in this enum, but this enum exists so the compiler
+ * can catch mistakes like setting the event type to a MIDI status byte.  Event
+ * types come from the type map and describe a format/protocol like MIDI, and
+ * must not be confused with the payload (such as a note on or CC change).
+ * There is a static value for MIDI as this type is handled specially by
+ * various parts of Evoral.
+ */
+enum EventType {
+       NO_EVENT,
+       MIDI_EVENT
+};
+
+/** Type of a parameter (opaque, mapped by application, e.g. gain) */
+typedef uint32_t ParameterType;
 
 class Beats;
 
index 3b56a33241d2f6fb7c2c2603f4c583584acc6a5f..52a4d6335b39a2be0d9f90e675e4071f12a21979 100644 (file)
@@ -30,9 +30,8 @@ namespace Evoral {
 
 template<typename Time>
 Note<Time>::Note(uint8_t chan, Time t, Time l, uint8_t n, uint8_t v)
-       // FIXME: types?
-       : _on_event (0xDE, t, 3, NULL, true)
-       , _off_event (0xAD, t + l, 3, NULL, true)
+       : _on_event (MIDI_EVENT, t, 3, NULL, true)
+       , _off_event (MIDI_EVENT, t + l, 3, NULL, true)
 {
        assert(chan < 16);
 
index 3098d0339d67ee2b46e6b3251a69d790704ba9dd..14e3b65f3725335f72d65c366d8bc9fa7b68e459 100644 (file)
@@ -63,7 +63,7 @@ template<typename Time>
 Sequence<Time>::const_iterator::const_iterator()
        : _seq(NULL)
        , _event(boost::shared_ptr< Event<Time> >(new Event<Time>()))
-       , _active_patch_change_message (0)
+       , _active_patch_change_message (NO_EVENT)
        , _type(NIL)
        , _is_end(true)
        , _control_iter(_control_iters.end())
@@ -191,7 +191,7 @@ Sequence<Time>::const_iterator::const_iterator(const Sequence<Time>&
 
        // Allocate a new event for storing the current event in MIDI format
        _event = boost::shared_ptr< Event<Time> >(
-               new Event<Time>(0, Time(), 4, NULL, true));
+               new Event<Time>(NO_EVENT, Time(), 4, NULL, true));
 
        // Set event from chosen sub-iterator
        set_event();
@@ -515,9 +515,8 @@ Sequence<Time>::Sequence(const Sequence<Time>& other)
        assert(! _end_iter._lock);
 }
 
-/** Write the controller event pointed to by \a iter to \a ev.
- * The buffer of \a ev will be allocated or resized as necessary.
- * The event_type of \a ev should be set to the expected output type.
+/** Write the controller event pointed to by `iter` to `ev`.
+ * The buffer of `ev` will be allocated or resized as necessary.
  * \return true on success
  */
 template<typename Time>
@@ -527,15 +526,14 @@ Sequence<Time>::control_to_midi_event(
        const ControlIterator&            iter) const
 {
        assert(iter.list.get());
-       const uint32_t event_type = iter.list->parameter().type();
 
        // initialize the event pointer with a new event, if necessary
        if (!ev) {
-               ev = boost::shared_ptr< Event<Time> >(new Event<Time>(event_type, Time(), 3, NULL, true));
+               ev = boost::shared_ptr< Event<Time> >(new Event<Time>(NO_EVENT, Time(), 3, NULL, true));
        }
 
-       uint8_t midi_type = _type_map.parameter_midi_type(iter.list->parameter());
-       ev->set_event_type(_type_map.midi_event_type(midi_type));
+       const uint8_t midi_type = _type_map.parameter_midi_type(iter.list->parameter());
+       ev->set_event_type(MIDI_EVENT);
        ev->set_id(-1);
        switch (midi_type) {
        case MIDI_CMD_CONTROL:
@@ -933,23 +931,28 @@ Sequence<Time>::append(const Event<Time>& ev, event_id_t evid)
                        _bank[ev.channel()] |= ev.cc_value();
                }
        } else if (ev.is_cc()) {
+               const ParameterType ptype = _type_map.midi_parameter_type(ev.buffer(), ev.size());
                append_control_unlocked(
-                       Parameter(ev.event_type(), ev.channel(), ev.cc_number()),
+                       Parameter(ptype, ev.channel(), ev.cc_number()),
                        ev.time(), ev.cc_value(), evid);
        } else if (ev.is_pgm_change()) {
                /* write a patch change with this program change and any previously set-up bank number */
-               append_patch_change_unlocked (PatchChange<Time> (ev.time(), ev.channel(), ev.pgm_number(), _bank[ev.channel()]), evid);
+               append_patch_change_unlocked (
+                       PatchChange<Time> (ev.time(), ev.channel(),
+                                          ev.pgm_number(), _bank[ev.channel()]), evid);
        } else if (ev.is_pitch_bender()) {
+               const ParameterType ptype = _type_map.midi_parameter_type(ev.buffer(), ev.size());
                append_control_unlocked(
-                       Parameter(ev.event_type(), ev.channel()),
+                       Parameter(ptype, ev.channel()),
                        ev.time(), double ((0x7F & ev.pitch_bender_msb()) << 7
                                           | (0x7F & ev.pitch_bender_lsb())),
                        evid);
        } else if (ev.is_poly_pressure()) {
                append_control_unlocked (Parameter (ev.event_type(), ev.channel(), ev.poly_note()), ev.time(), ev.poly_pressure(), evid);
        } else if (ev.is_channel_pressure()) {
+               const ParameterType ptype = _type_map.midi_parameter_type(ev.buffer(), ev.size());
                append_control_unlocked(
-                       Parameter(ev.event_type(), ev.channel()),
+                       Parameter(ptype, ev.channel()),
                        ev.time(), ev.channel_pressure(), evid);
        } else if (!_type_map.type_is_midi(ev.event_type())) {
                printf("WARNING: Sequence: Unknown event type %X: ", ev.event_type());
@@ -1215,7 +1218,7 @@ template<typename Time>
 typename Sequence<Time>::SysExes::const_iterator
 Sequence<Time>::sysex_lower_bound (Time t) const
 {
-       SysExPtr search (new Event<Time> (0, t));
+       SysExPtr search (new Event<Time> (NO_EVENT, t));
        typename Sequence<Time>::SysExes::const_iterator i = _sysexes.lower_bound (search);
        assert (i == _sysexes.end() || (*i)->time() >= t);
        return i;
@@ -1250,7 +1253,7 @@ template<typename Time>
 typename Sequence<Time>::SysExes::iterator
 Sequence<Time>::sysex_lower_bound (Time t)
 {
-       SysExPtr search (new Event<Time> (0, t));
+       SysExPtr search (new Event<Time> (NO_EVENT, t));
        typename Sequence<Time>::SysExes::iterator i = _sysexes.lower_bound (search);
        assert (i == _sysexes.end() || (*i)->time() >= t);
        return i;
index 0907cdc2f547aa1be8b6f373da6f644c46e2a812..108052c98f95f51e8528f3af218ece10a9883cd0 100644 (file)
@@ -59,7 +59,7 @@ SMFTest::takeFiveTest ()
                if (ret > 0) { // didn't skip (meta) event
                        //cerr << "read smf event type " << hex << int(buf[0]) << endl;
                        ev.set_time(Evoral::Beats::ticks_at_rate(time, smf.ppqn()));
-                       ev.set_event_type(type_map->midi_event_type(buf[0]));
+                       ev.set_event_type(Evoral::MIDI_EVENT);
                        seq->append(ev, next_event_id ());
                }
        }
index a3dfabe139b54496e6cd757e64530662f5c16aab..16e93b37d200763014762a8f7b94bfca519bef19 100644 (file)
@@ -25,7 +25,7 @@ SequenceTest::preserveEventOrderingTest ()
        for (Notes::const_iterator i = test_notes.begin(); i != test_notes.end(); ++i) {
                uint8_t buffer[3];
                Event<Time>* event = new Event<Time>(
-                               DummyTypeMap::CONTROL, (*i)->on_event().time(), 3, buffer, true
+                       (Evoral::EventType)DummyTypeMap::CONTROL, (*i)->on_event().time(), 3, buffer, true
                );
 
                event->buffer()[0] = MIDI_CMD_CONTROL;
@@ -77,12 +77,12 @@ SequenceTest::iteratorSeekTest ()
        bool on = true;
        for (Sequence<Time>::const_iterator i = seq->begin(Evoral::Beats(600)); i != seq->end(); ++i) {
                if (on) {
-                       CPPUNIT_ASSERT((*i)->is_note_on());
+                       CPPUNIT_ASSERT(i->is_note_on());
                        CPPUNIT_ASSERT_EQUAL(i->time(), Time((num_notes + 6) * 100));
                        ++num_notes;
                        on = false;
                } else {
-                       CPPUNIT_ASSERT((*i)->is_note_off());
+                       CPPUNIT_ASSERT(i->is_note_off());
                        on = true;
                }
        }
index de51f714a12b4eab70f4567351ce080492d92ee8..48dff308b6b4e4e0d596b09367287981454f374c 100644 (file)
@@ -31,13 +31,14 @@ public:
                };
        }
 
-       uint32_t midi_event_type(uint8_t status) const {
-               status &= 0xf0;
-               switch (status) {
-               case MIDI_CMD_CONTROL:          return CONTROL;
-               case MIDI_CMD_COMMON_SYSEX:     return SYSEX;
-               default:                        return 0;
-               };
+       virtual ParameterType midi_parameter_type(const uint8_t* buf, uint32_t len) const {
+               switch (buf[0] & 0xF0) {
+               case MIDI_CMD_CONTROL:      return CONTROL;
+               case MIDI_CMD_COMMON_SYSEX: return SYSEX;
+               case MIDI_CMD_NOTE_ON:      return NOTE;
+               case MIDI_CMD_NOTE_OFF:     return NOTE;
+               default: return 0;
+               }
        }
 
        ParameterDescriptor descriptor(const Parameter& param) const {