aboutsummaryrefslogtreecommitdiffstats
path: root/src/engine/Machine.cpp
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2007-04-17 07:26:37 +0000
committerDavid Robillard <d@drobilla.net>2007-04-17 07:26:37 +0000
commitf11d9299afca21e52e0093784bed0b5ef8a506d0 (patch)
tree22987f9e445ae71dbe9e660d7b9c019667cc2515 /src/engine/Machine.cpp
parent9f3da0d87e9ca5183efd3493af8fea9ab8092d40 (diff)
downloadmachina-f11d9299afca21e52e0093784bed0b5ef8a506d0.tar.gz
machina-f11d9299afca21e52e0093784bed0b5ef8a506d0.tar.bz2
machina-f11d9299afca21e52e0093784bed0b5ef8a506d0.zip
Fix missed events timestamp bug (for real this time).
git-svn-id: http://svn.drobilla.net/lad/machina@453 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/engine/Machine.cpp')
-rw-r--r--src/engine/Machine.cpp13
1 files changed, 7 insertions, 6 deletions
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<Raul::MIDISink> 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;
}