From 8711844a023b83684ed553f5b4f3f37d36875ad3 Mon Sep 17 00:00:00 2001 From: midilab Date: Thu, 21 Sep 2023 18:11:46 -0300 Subject: [PATCH] shuffle template size calculus inside method for cleaner use of API --- src/uClock.cpp | 5 +++-- src/uClock.h | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/uClock.cpp b/src/uClock.cpp index eca1b6b..292d8de 100755 --- a/src/uClock.cpp +++ b/src/uClock.cpp @@ -262,11 +262,12 @@ void uClockClass::setShuffleData(uint8_t step, int8_t tick) ATOMIC(shuffle.step[step] = tick) } -void uClockClass::setShuffleTemplate(int8_t * shuff, uint8_t size) +void uClockClass::setShuffleTemplate(int8_t * shuff) { + uint8_t size = sizeof(shuff) / sizeof(shuff[0]); if (size > MAX_SHUFFLE_TEMPLATE_SIZE) size = MAX_SHUFFLE_TEMPLATE_SIZE; - setShuffleSize(size); + ATOMIC(shuffle.size = size) for (uint8_t i=0; i < size; i++) { setShuffleData(i, shuff[i]); } diff --git a/src/uClock.h b/src/uClock.h index 661c92d..6ea32cf 100755 --- a/src/uClock.h +++ b/src/uClock.h @@ -161,7 +161,7 @@ public: bool isShuffled(); void setShuffleSize(uint8_t size); void setShuffleData(uint8_t step, int8_t tick); - void setShuffleTemplate(int8_t * shuff, uint8_t size); + void setShuffleTemplate(int8_t * shuff); // use this to know how many positive or negative ticks to add to current note length int8_t getShuffleLength();