Slightly hacky but functional fix for large quantities of MIDI output when interpolat...
[ardour.git] / libs / evoral / src / Sequence.cpp
index 88150714334b341a7eacc30be0aadc17415a153b..b6a7dceca14d16ea1a10cb83f1636fedc68c890c 100644 (file)
 using namespace std;
 using namespace PBD;
 
+/** Minimum time between MIDI outputs from a single controller,
+    expressed in beats.  This is to limit the rate at which MIDI messages
+    are generated, particularly for quickly-changing controllers which
+    are being interpolated.
+
+    XXX: This is a hack.  The time should probably be expressed in
+    seconds rather than beats, and should be configurable etc. etc.
+*/
+static double const time_between_controller_outputs = 1.0 / 256;
+
 namespace Evoral {
 
 // Read iterator (const_iterator)
@@ -253,9 +263,9 @@ Sequence<Time>::const_iterator::operator++()
        case CONTROL:
                // Increment current controller iterator
                if (_force_discrete) {
-                       ret = _control_iter->list->rt_safe_earliest_event_discrete_unlocked (_control_iter->x, x, y, false);
+                       ret = _control_iter->list->rt_safe_earliest_event_discrete_unlocked (_control_iter->x + time_between_controller_outputs, x, y, false);
                } else {
-                       ret = _control_iter->list->rt_safe_earliest_event_unlocked (_control_iter->x, x, y, false);
+                       ret = _control_iter->list->rt_safe_earliest_event_unlocked (_control_iter->x + time_between_controller_outputs, x, y, false);
                }
                assert(!ret || x > _control_iter->x);
                if (ret) {
@@ -817,7 +827,7 @@ Sequence<Time>::append_note_off_unlocked (NotePtr note)
 
 template<typename Time>
 void
-Sequence<Time>::append_control_unlocked(const Parameter& param, Time time, double value, event_id_t evid)
+Sequence<Time>::append_control_unlocked(const Parameter& param, Time time, double value, event_id_t /* evid */)
 {
         DEBUG_TRACE (DEBUG::Sequence, string_compose ("%1 %2 @ %3\t=\t%4 # controls: %5\n",
                                                       this, _type_map.to_symbol(param), time, value, _controls.size()));
@@ -828,7 +838,7 @@ Sequence<Time>::append_control_unlocked(const Parameter& param, Time time, doubl
 
 template<typename Time>
 void
-Sequence<Time>::append_sysex_unlocked(const MIDIEvent<Time>& ev, event_id_t evid)
+Sequence<Time>::append_sysex_unlocked(const MIDIEvent<Time>& ev, event_id_t /* evid */)
 {
 #ifdef DEBUG_SEQUENCE
         cerr << this << " SysEx @ " << ev.time() << " \t= \t [ " << hex;