Add per-channel Swing configuration (#7)

Select swing amount from a percentage range of the beat starting a 50% (unchanged) to a max swing amount of 95% (about 1/32nd note before end of period). Swing percentage shows an indicator marker when the percentage lines up with a quantized note on the grid.

This is probably going to be the last feature because it is pushing up against the limits of available dynamic memory.

Out of scope changes:
- selecting parameters / values no longer wraps
- reduce dynamic memory used in processClockTick
- various readability formatting

Reviewed-on: https://git.pinkduck.xyz/adam/libGravity/pulls/7
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-22 18:38:51 +00:00
committed by adam
parent c8e42c7448
commit 973c13b8ef
6 changed files with 95 additions and 32 deletions

View File

@ -21,8 +21,8 @@
#include "app_state.h"
#include "channel.h"
#include "save_state.h"
#include "display.h"
#include "save_state.h"
AppState app;
StateManager stateManager;
@ -210,6 +210,9 @@ void editChannelParameter(int val) {
case PARAM_CH_OFFSET:
ch.setOffset(ch.getOffset() + val);
break;
case PARAM_CH_SWING:
ch.setSwing(ch.getSwing() + val);
break;
case PARAM_CH_CV_SRC: {
int source = static_cast<int>(ch.getCvSource());
updateSelection(source, val, CV_LAST);
@ -226,8 +229,7 @@ void editChannelParameter(int val) {
}
void updateSelection(int& param, int change, int maxValue) {
// This formula correctly handles positive and negative wrapping.
param = (param + change % maxValue + maxValue) % maxValue;
param = constrain(param + change, 0, maxValue - 1);
}
//