From 397ca366c3af068034f063e3eb76639104b2645f Mon Sep 17 00:00:00 2001 From: falkTX Date: Wed, 8 Dec 2021 19:43:06 +0000 Subject: [PATCH] Fix BBT timing of Carla and Ildaeil modules Closes #73 --- plugins/Cardinal/src/Carla.cpp | 14 +++++++------- plugins/Cardinal/src/Ildaeil.cpp | 14 +++++++------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/plugins/Cardinal/src/Carla.cpp b/plugins/Cardinal/src/Carla.cpp index 48b60ed..b53ffa8 100644 --- a/plugins/Cardinal/src/Carla.cpp +++ b/plugins/Cardinal/src/Carla.cpp @@ -313,18 +313,18 @@ struct CarlaModule : Module { int32_t newBar = fCarlaTimeInfo.bbt.bar; int32_t newBeat = fCarlaTimeInfo.bbt.beat; - double newTick = fCarlaTimeInfo.bbt.tick + samplesPerTick * BUFFER_SIZE; + double newTick = fCarlaTimeInfo.bbt.tick + (double)BUFFER_SIZE / samplesPerTick; - while (newTick > pcontext->ticksPerBeat) + while (newTick >= fCarlaTimeInfo.bbt.ticksPerBeat) { - newTick -= pcontext->ticksPerBeat; + newTick -= fCarlaTimeInfo.bbt.ticksPerBeat; - if (++fCarlaTimeInfo.bbt.beat > pcontext->beatsPerBar) + if (++newBeat > fCarlaTimeInfo.bbt.beatsPerBar) { - fCarlaTimeInfo.bbt.beat = 1; + newBeat = 1; - if (++newBar) - fCarlaTimeInfo.bbt.barStartTick += pcontext->beatsPerBar * pcontext->ticksPerBeat; + ++newBar; + fCarlaTimeInfo.bbt.barStartTick += fCarlaTimeInfo.bbt.beatsPerBar * fCarlaTimeInfo.bbt.ticksPerBeat; } } diff --git a/plugins/Cardinal/src/Ildaeil.cpp b/plugins/Cardinal/src/Ildaeil.cpp index d0c35f9..50cc6a3 100644 --- a/plugins/Cardinal/src/Ildaeil.cpp +++ b/plugins/Cardinal/src/Ildaeil.cpp @@ -498,18 +498,18 @@ struct IldaeilModule : Module { int32_t newBar = fCarlaTimeInfo.bbt.bar; int32_t newBeat = fCarlaTimeInfo.bbt.beat; - double newTick = fCarlaTimeInfo.bbt.tick + samplesPerTick * BUFFER_SIZE; + double newTick = fCarlaTimeInfo.bbt.tick + (double)BUFFER_SIZE / samplesPerTick; - while (newTick > pcontext->ticksPerBeat) + while (newTick >= fCarlaTimeInfo.bbt.ticksPerBeat) { - newTick -= pcontext->ticksPerBeat; + newTick -= fCarlaTimeInfo.bbt.ticksPerBeat; - if (++fCarlaTimeInfo.bbt.beat > pcontext->beatsPerBar) + if (++newBeat > fCarlaTimeInfo.bbt.beatsPerBar) { - fCarlaTimeInfo.bbt.beat = 1; + newBeat = 1; - if (++newBar) - fCarlaTimeInfo.bbt.barStartTick += pcontext->beatsPerBar * pcontext->ticksPerBeat; + ++newBar; + fCarlaTimeInfo.bbt.barStartTick += fCarlaTimeInfo.bbt.beatsPerBar * fCarlaTimeInfo.bbt.ticksPerBeat; } }