shuffle positive restored, missing negative review

pull/32/head
midilab 11 months ago
parent 51b03d55b6
commit c5f126a90b
  1. 84
      src/uClock.cpp
  2. 4
      src/uClock.h

@ -279,9 +279,9 @@ void uClockClass::setShuffleData(uint8_t step, int8_t tick)
ATOMIC(shuffle.step[step] = tick) ATOMIC(shuffle.step[step] = tick)
} }
void uClockClass::setShuffleTemplate(int8_t * shuff) void uClockClass::setShuffleTemplate(int8_t * shuff, uint8_t size)
{ {
uint8_t size = sizeof(shuff) / sizeof(shuff[0]); //uint8_t size = sizeof(shuff) / sizeof(shuff[0]);
if (size > MAX_SHUFFLE_TEMPLATE_SIZE) if (size > MAX_SHUFFLE_TEMPLATE_SIZE)
size = MAX_SHUFFLE_TEMPLATE_SIZE; size = MAX_SHUFFLE_TEMPLATE_SIZE;
ATOMIC(shuffle.size = size) ATOMIC(shuffle.size = size)
@ -294,40 +294,43 @@ int8_t uClockClass::getShuffleLength()
{ {
return shuffle_length_ctrl; return shuffle_length_ctrl;
} }
/*
int8_t inline uClockClass::processShuffle() bool inline uClockClass::processShuffle()
{ {
// mod6_counter will become mod_step_counter
int8_t mod6_shuffle_counter;
if (!shuffle.active) { if (!shuffle.active) {
mod6_shuffle_counter = mod6_counter; return mod_step_counter == 0;
} else { }
// apply shuffle template to step
int8_t shff = shuffle.step[div16th_counter%shuffle.size]; // internal reference for mod_counter
uint8_t mod_counter = mod_step_ref - (mod_step_counter == 0 ? mod_step_ref : mod_step_counter);
int8_t mod_shuffle = 0;
// check shuffle template to step
int8_t shff = shuffle.step[step_counter%shuffle.size];
if (shuffle_shoot_ctrl == false && mod_counter == 0)
shuffle_shoot_ctrl = true;
if (shff >= 0) {
mod_shuffle = mod_counter - shff;
} else if (shff < 0) {
mod_shuffle = mod_counter - (mod_step_ref + shff);
}
if (mod_shuffle == 0 && shuffle_shoot_ctrl == true) {
// keep track of next note shuffle for current note lenght control // keep track of next note shuffle for current note lenght control
shuffle_length_ctrl = shuffle.step[(div16th_counter+1)%shuffle.size]; shuffle_length_ctrl = shuffle.step[(step_counter+1)%shuffle.size];
// prepare the next mod6 quantize to be called if (shff > 0)
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; shuffle_length_ctrl -= shff;
if (shuffle_length_ctrl == 0) if (shff < 0)
shuffle_length_ctrl = 1;
} 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; shuffle_length_ctrl += shff;
if (shuffle_length_ctrl == 0) shuffle_shoot_ctrl = false;
shuffle_length_ctrl = -1; return true;
}
} }
return mod6_shuffle_counter;
return false;
} }
*/
// it is expected to be called in 24PPQN // it is expected to be called in 24PPQN
void uClockClass::handleExternalClock() void uClockClass::handleExternalClock()
{ {
@ -421,26 +424,21 @@ void uClockClass::handleTimerInt()
onPPQNCallback(tick); onPPQNCallback(tick);
} }
// step callback to support 16th old school style sequencers
// with builtin shuffle for this callback only
if (onStepCallback) { if (onStepCallback) {
// we can add a time signature here for call setup based on mod_step_ref // processShufle make use of mod_step_counter
// basic will be 16ths, but let the option to handle unusual sequences if (processShuffle()) {
if (mod_step_counter == 0) {
onStepCallback(step_counter); onStepCallback(step_counter);
// reset counter reference
mod_step_counter = mod_step_ref;
// going forward to the next step call // going forward to the next step call
++step_counter; ++step_counter;
} }
} // keep track of mod_step_counter
if (mod_step_counter == 0) {
/* // TODO: port it from 24PPQN to ppqn set // reset counter reference
if (processShuffle() == 0) { mod_step_counter = mod_step_ref;
//if (mod_step_counter == signature) {
if (onStepCallback) {
onStepCallback(mod_step_counter);
} }
shuffle_shoot_ctrl = false; }
} */
// tick me! // tick me!
++tick; ++tick;

@ -145,7 +145,7 @@ class uClockClass {
bool isShuffled(); bool isShuffled();
void setShuffleSize(uint8_t size); void setShuffleSize(uint8_t size);
void setShuffleData(uint8_t step, int8_t tick); void setShuffleData(uint8_t step, int8_t tick);
void setShuffleTemplate(int8_t * shuff); void setShuffleTemplate(int8_t * shuff, uint8_t size);
// use this to know how many positive or negative ticks to add to current note length // use this to know how many positive or negative ticks to add to current note length
int8_t getShuffleLength(); int8_t getShuffleLength();
@ -166,7 +166,7 @@ class uClockClass {
float inline freqToBpm(uint32_t freq); float inline freqToBpm(uint32_t freq);
// shuffle // shuffle
//int8_t inline processShuffle(); bool inline processShuffle();
void (*onPPQNCallback)(uint32_t tick); void (*onPPQNCallback)(uint32_t tick);
void (*onStepCallback)(uint32_t step); void (*onStepCallback)(uint32_t step);

Loading…
Cancel
Save