fix shuffle edge case for +5 tick

pull/32/head
midilab 7 months ago
parent 8711844a02
commit c9bb9c4d9f
  1. 59
      src/uClock.cpp
  2. 2
      src/uClock.h

@ -278,6 +278,36 @@ int8_t uClockClass::getShuffleLength()
return shuffle_length_ctrl;
}
int8_t inline uClockClass::processShuffle()
{
int8_t mod6_shuffle_counter;
if (!shuffle.active) {
mod6_shuffle_counter = mod6_counter;
} else {
// apply shuffle template to step
int8_t shff = shuffle.step[div16th_counter%shuffle.size];
// keep track of next note shuffle for current note lenght control
shuffle_length_ctrl = shuffle.step[(div16th_counter+1)%shuffle.size];
// prepare the next mod6 quantize to be called
if (shff == 0) {
mod6_shuffle_counter = mod6_counter;
} else if (shff > 0) {
if (shuffle_shoot_ctrl == false && mod6_counter > shff || (shff == 5 && mod6_counter == 0))
shuffle_shoot_ctrl = true;
mod6_shuffle_counter = shuffle_shoot_ctrl ? mod6_counter - shff : 1;
shuffle_length_ctrl -= shff;
} else if (shff < 0) {
if (shuffle_shoot_ctrl == false && mod6_counter == 0)
shuffle_shoot_ctrl = true;
mod6_shuffle_counter = shff - mod6_counter == -6 ? shuffle_shoot_ctrl ? 0 : 1 : 1;
shuffle_length_ctrl += shff;
}
}
if (shuffle_length_ctrl == 0)
shuffle_length_ctrl = 1;
return mod6_shuffle_counter;
}
void uClockClass::handleExternalClock()
{
@ -391,35 +421,6 @@ void uClockClass::handleTimerInt()
}
}
uint8_t inline uClockClass::processShuffle()
{
uint8_t mod6_shuffle_counter;
if (!shuffle.active) {
mod6_shuffle_counter = mod6_counter;
} else {
// apply shuffle template to step
int8_t shff = shuffle.step[div16th_counter%shuffle.size];
// keep track of next note shuffle for current note lenght control
shuffle_length_ctrl = shuffle.step[(div16th_counter+1)%shuffle.size];
// prepare the next mod6 quantize to be called
if (shff == 0) {
mod6_shuffle_counter = mod6_counter;
shuffle_length_ctrl += shff;
} else if (shff > 0) {
if (shuffle_shoot_ctrl == false && mod6_counter > shff)
shuffle_shoot_ctrl = true;
mod6_shuffle_counter = shuffle_shoot_ctrl ? mod6_counter - shff : 1;
shuffle_length_ctrl -= shff;
} else if (shff < 0) {
if (shuffle_shoot_ctrl == false && mod6_counter == 0)
shuffle_shoot_ctrl = true;
mod6_shuffle_counter = shff - mod6_counter == -6 ? shuffle_shoot_ctrl ? 0 : 1 : 1;
shuffle_length_ctrl += shff;
}
}
return mod6_shuffle_counter;
}
// elapsed time support
uint8_t uClockClass::getNumberOfSeconds(uint32_t time)
{

@ -66,7 +66,7 @@ private:
float inline freqToBpm(uint32_t freq);
// shuffle
uint8_t inline processShuffle();
int8_t inline processShuffle();
void (*onClock96PPQNCallback)(uint32_t tick);
void (*onClock32PPQNCallback)(uint32_t tick);

Loading…
Cancel
Save