From 459ae7f4e61ff159bd6ba39a5178bc6601849573 Mon Sep 17 00:00:00 2001 From: midilab Date: Sat, 6 Jan 2024 08:40:39 -0300 Subject: [PATCH] shuffle schema integrated to dinamicly PPQN system. missing reviewing more complex shuffle templates --- src/uClock.cpp | 23 +++++++++++++++++++++++ src/uClock.h | 10 +++++----- 2 files changed, 28 insertions(+), 5 deletions(-) diff --git a/src/uClock.cpp b/src/uClock.cpp index a81409c..d59d3eb 100755 --- a/src/uClock.cpp +++ b/src/uClock.cpp @@ -311,12 +311,35 @@ bool inline uClockClass::processShuffle() if (shuffle_shoot_ctrl == false && mod_counter == 0) shuffle_shoot_ctrl = true; + //if (mod_counter == mod_step_ref-1) + if (shff >= 0) { mod_shuffle = mod_counter - shff; + // any late shuffle? we should skip next mod_counter == 0 + if (last_shff < 0 && mod_counter != 1) + return false; } else if (shff < 0) { mod_shuffle = mod_counter - (mod_step_ref + shff); + //if (last_shff < 0 && mod_counter != 1) + // return false; + shuffle_shoot_ctrl = true; } + //Serial.println("-----------------"); + //Serial.print("shff: "); + //Serial.println(shff); + //Serial.print("mod_counter: "); + //Serial.println(mod_counter); + //Serial.print("mod_shuffle: "); + //Serial.println(mod_shuffle); + //Serial.print("shuffle_shoot_ctrl: "); + //Serial.println(shuffle_shoot_ctrl); + //Serial.print("last_shff: "); + //Serial.println(last_shff); + + last_shff = shff; + + // shuffle_shoot_ctrl helps keep track if we have shoot or not a note for the step space of ppqn/4 pulses if (mod_shuffle == 0 && shuffle_shoot_ctrl == true) { // keep track of next note shuffle for current note lenght control shuffle_length_ctrl = shuffle.step[(step_counter+1)%shuffle.size]; diff --git a/src/uClock.h b/src/uClock.h index f10e664..145fb3c 100755 --- a/src/uClock.h +++ b/src/uClock.h @@ -44,9 +44,8 @@ namespace umodular { namespace clock { // 48 PPQN (12 pulses per step) // 96 PPQN (24 pulses per step) -// min: 2 step, max: 16 steps -// adjust the size of you template if more than 16 needed -// step adjust goes min: -5, max: 5 +// min: -(ppqn/4)-1 step, max: (ppqn/4)-1 steps +// adjust the size of you template if more than 16 shuffle step info needed #define MAX_SHUFFLE_TEMPLATE_SIZE 16 typedef struct { bool active = false; @@ -198,13 +197,14 @@ class uClockClass { float tempo; uint32_t start_timer; - uint8_t mode; + SyncMode mode; volatile uint32_t ext_interval_buffer[EXT_INTERVAL_BUFFER_SIZE]; uint16_t ext_interval_idx; - // shuffle implementation that applies to 16PPQN callback + // shuffle implementation volatile SHUFFLE_TEMPLATE shuffle; + int8_t last_shff = 0; bool shuffle_shoot_ctrl = true; volatile int8_t shuffle_length_ctrl = 0; };