From 13333852fbcfb57f655af2707757aa31cf55ddfa Mon Sep 17 00:00:00 2001 From: Matt Demanett Date: Sat, 11 May 2019 13:31:24 -0400 Subject: [PATCH] Fix crash-on-add for ADDR-SEQ, 8:1, 1:8. #48 --- src/AddrSeq.cpp | 2 +- src/EightOne.cpp | 2 +- src/OneEight.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/AddrSeq.cpp b/src/AddrSeq.cpp index 584c3b13..ef292019 100644 --- a/src/AddrSeq.cpp +++ b/src/AddrSeq.cpp @@ -34,7 +34,7 @@ void AddrSeq::step() { bool timer = _timer.next(); bool clock = _clock.process(inputs[CLOCK_INPUT].value) && !timer; - int steps = params[STEPS_PARAM].value; + int steps = clamp(params[STEPS_PARAM].value, 1.0f, 8.0f); int reverse = 1 - 2 * (params[DIRECTION_PARAM].value == 0.0f); _step = (_step + reverse * clock) % steps; _step += (_step < 0) * steps; diff --git a/src/EightOne.cpp b/src/EightOne.cpp index c7829485..723200ad 100644 --- a/src/EightOne.cpp +++ b/src/EightOne.cpp @@ -34,7 +34,7 @@ void EightOne::step() { bool timer = _timer.next(); bool clock = _clock.process(inputs[CLOCK_INPUT].value) && !timer; - int steps = params[STEPS_PARAM].value; + int steps = clamp(params[STEPS_PARAM].value, 1.0f, 8.0f); int reverse = 1 - 2 * (params[DIRECTION_PARAM].value == 0.0f); _step = (_step + reverse * clock) % steps; _step += (_step < 0) * steps; diff --git a/src/OneEight.cpp b/src/OneEight.cpp index 88f95a81..5083c332 100644 --- a/src/OneEight.cpp +++ b/src/OneEight.cpp @@ -34,7 +34,7 @@ void OneEight::step() { bool timer = _timer.next(); bool clock = _clock.process(inputs[CLOCK_INPUT].value) && !timer; - int steps = params[STEPS_PARAM].value; + int steps = clamp(params[STEPS_PARAM].value, 1.0f, 8.0f); int reverse = 1 - 2 * (params[DIRECTION_PARAM].value == 0.0f); _step = (_step + reverse * clock) % steps; _step += (_step < 0) * steps;