From f11d9299afca21e52e0093784bed0b5ef8a506d0 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Tue, 17 Apr 2007 07:26:37 +0000 Subject: Fix missed events timestamp bug (for real this time). git-svn-id: http://svn.drobilla.net/lad/machina@453 a436a847-0d15-0410-975c-d299462d15a1 --- src/engine/Machine.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'src/engine/Machine.cpp') diff --git a/src/engine/Machine.cpp b/src/engine/Machine.cpp index 0639881..d4a3425 100644 --- a/src/engine/Machine.cpp +++ b/src/engine/Machine.cpp @@ -23,6 +23,7 @@ #include "machina/MidiAction.hpp" using namespace std; +using namespace Raul; namespace Machina { @@ -220,7 +221,8 @@ Machine::run(const Raul::TimeSlice& time) const SharedPtr sink = _sink.lock(); - const BeatCount cycle_end = _time + time.length_beats(); + const TickTime cycle_end_ticks = time.start_ticks() + time.length_ticks() - 1; + const BeatCount cycle_end_beats = time.ticks_to_beats(cycle_end_ticks); assert(_is_activated); @@ -257,17 +259,16 @@ Machine::run(const Raul::TimeSlice& time) break; // Earliest active state ends this cycle - // Must do comparison in ticks here to avoid rounding up and executing - // an event outside the current cycle } else if (time.beats_to_ticks(earliest->exit_time()) - < time.beats_to_ticks(cycle_end)) { + <= cycle_end_ticks) { this_time += earliest->exit_time() - _time; - _time = earliest->exit_time(); + _time = time.ticks_to_beats( + time.beats_to_ticks(earliest->exit_time())); exit_node(sink, earliest); // Earliest active state ends in the future, done this cycle } else { - _time = cycle_end; + _time = cycle_end_beats; this_time = time.length_beats(); // ran the entire cycle break; } -- cgit v1.2.1