Skip to content

Commit

Permalink
Kron is now properly synchronized with a global reset
Browse files Browse the repository at this point in the history
  • Loading branch information
denolehov committed Oct 19, 2024
1 parent 7d627d3 commit 2f943b6
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions src/Kron.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,12 @@ struct Kron final : DaisyExpander {
}

void process(const ProcessArgs& args) override {
DaisyExpander::process(args);
handleReset();
DaisyExpander::process(args);
handleVariantChange();
division = divisionMapping[divisionIdx];

const bool clockDivisionTriggered = globalClock % division == 0;
const bool clockDivisionTriggered = localClock % division == 0;
const bool isBlocked = getInput(MUTE_INPUT).getVoltage() >= 0.1f;

const float noiseVal = rescale(noise->eval(variant, localClock), -1.f, 1.f, 0.f, 100.f);
Expand Down Expand Up @@ -126,32 +126,31 @@ struct Kron final : DaisyExpander {
void handleVariantChange()
{
const float newVariant = getParam(VARIANT_PARAM).getValue();
if (newVariant != variant && variantChangeDivider.process())
if ((newVariant != variant && variantChangeDivider.process()) || variant == 0.f)
variant = newVariant;
}

void onClock(const uint32_t clock) override
{
clockProcessed = false;

globalClock++;
localClock++;

const uint32_t delta = clock - globalClock;
if (delta > 0) {
// The module has been disconnected for a while.
// We need to catch up the local clock to the global clock.
globalClock = clock;
localClock += delta;
} else {
globalClock = clock;
localClock = clock;
}

// Local clock cannot be greater than the global clock.
if (localClock > globalClock)
localClock = globalClock;
}


void reset() override {
localClock = 0;
localClock = -1;
pulse.reset();
}

Expand Down

0 comments on commit 2f943b6

Please sign in to comment.