From 546cb17e5f0f8640f4954d0f9329a7770269bef1 Mon Sep 17 00:00:00 2001 From: Colin Wallace Date: Sun, 21 Jun 2015 22:55:14 +0000 Subject: [PATCH] Simpler nextFullTact() algorithm --- include/MidiTime.h | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/include/MidiTime.h b/include/MidiTime.h index 788e6fb57..fe44ab4da 100644 --- a/include/MidiTime.h +++ b/include/MidiTime.h @@ -30,6 +30,7 @@ #include "lmms_basics.h" #include "export.h" +// note: 1 "Tact" = 1 Measure const int DefaultTicksPerTact = 192; const int DefaultStepsPerTact = 16; const int DefaultBeatsPerTact = DefaultTicksPerTact / DefaultStepsPerTact; @@ -85,6 +86,7 @@ public: return *this; } + // return the tact, rounded down and 0-based tact_t getTact() const { return m_ticks / s_ticksPerTact; @@ -92,11 +94,7 @@ public: tact_t nextFullTact() const { - if( m_ticks % s_ticksPerTact == 0 ) - { - return m_ticks / s_ticksPerTact; - } - return m_ticks / s_ticksPerTact + 1; + return (m_ticks + (s_ticksPerTact-1)) / s_ticksPerTact; } void setTicks( tick_t ticks )