Introduce basic Euclidean Rhythm (#9)

Each channel can define a euclidean rhythm by setting a number of steps (up to 16) and a number of hits to evenly distribute within those steps. CV Mod is available, however the cv mod acts as an override instead of a sum mix like the other parameters.

Refactor `applyCvMod()` so it is only called if cv mod is active for that channel. Now the setter methods will update the final output value if cv mod is not active.

Reviewed-on: https://git.pinkduck.xyz/adam/libGravity/pulls/9
Co-authored-by: Adam Wonak <adam.wonak@gmail.com>
Co-committed-by: Adam Wonak <adam.wonak@gmail.com>
This commit is contained in:
2025-06-30 17:23:56 +00:00
committed by adam
parent 6d0a9f9f7f
commit ceb01bf03f
7 changed files with 197 additions and 21 deletions

View File

@ -60,8 +60,23 @@ void loop() {
// Read CVs and call the update function for each channel.
int cv1 = gravity.cv1.Read();
int cv2 = gravity.cv2.Read();
for (int i = 0; i < Gravity::OUTPUT_COUNT; i++) {
app.channel[i].applyCvMod(cv1, cv2);
auto& ch = app.channel[i];
// Only apply CV to the channel when the current channel has cv
// mod configured.
if (ch.isCvModActive()) {
// hack -- do not apply mod to euclidean rhythm when editing.
bool editing_euc;
editing_euc |= ch.getCvDestination() == CV_DEST_EUC_STEPS;
editing_euc |= ch.getCvDestination() == CV_DEST_EUC_HITS;
editing_euc &= (app.selected_channel - 1) == i;
editing_euc &= app.editing_param;
if (editing_euc) {
continue;
}
ch.applyCvMod(cv1, cv2);
}
}
// Check for dirty state eligible to be saved.
@ -209,6 +224,12 @@ void editChannelParameter(int val) {
case PARAM_CH_SWING:
ch.setSwing(ch.getSwing() + val);
break;
case PARAM_CH_EUC_STEPS:
ch.setSteps(ch.getSteps() + val);
break;
case PARAM_CH_EUC_HITS:
ch.setHits(ch.getHits() + val);
break;
case PARAM_CH_CV_SRC: {
byte source = static_cast<int>(ch.getCvSource());
updateSelection(source, val, CV_LAST);