Introduce Save/Load banks for storing different preset settings. (#11)

This also includes a lot of minor fixes.

Reviewed-on: https://git.pinkduck.xyz/adam/libGravity/pulls/11
Co-authored-by: Adam Wonak <adam.wonak@gmail.com>
Co-committed-by: Adam Wonak <adam.wonak@gmail.com>
This commit is contained in:
2025-07-04 17:33:57 +00:00
committed by adam
parent d2228af55f
commit 14aad8285d
7 changed files with 216 additions and 119 deletions

View File

@ -24,23 +24,23 @@ static const byte MOD_CHOICE_SIZE = 25;
// Negative numbers are multipliers, positive are divisors.
static const int CLOCK_MOD[MOD_CHOICE_SIZE] PROGMEM = {
// Multipliers
-24, -16, -12, -8, -6, -4, -3, -2,
-24, -16, -12, -8, -6, -4, -3, -2,
// Internal Clock Unity
1,
1,
// Divisors
2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 16, 24, 32, 64, 128
};
2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 16, 24, 32, 64, 128};
// This represents the number of clock pulses for a 96 PPQN clock source
// This represents the number of clock pulses for a 96 PPQN clock source
// that match the above div/mult mods.
static const int CLOCK_MOD_PULSES[MOD_CHOICE_SIZE] PROGMEM = {
// Multiplier Pulses (96 / X)
4, 6, 8, 12, 16, 24, 32, 48,
4, 6, 8, 12, 16, 24, 32, 48,
// Internal Clock Pulses
96,
96,
// Divisor Pulses (96 * X)
192, 288, 384, 480, 576, 672, 768, 864, 960, 1056, 1152, 1536, 2304, 3072, 6144, 12288
};
192, 288, 384, 480, 576, 672, 768, 864, 960, 1056, 1152, 1536, 2304, 3072, 6144, 12288};
static const byte DEFAULT_CLOCK_MOD_INDEX = 8; // x1 or 96 PPQN.
class Channel {
public:
@ -50,7 +50,7 @@ class Channel {
void Init() {
// Reset base values to their defaults
base_clock_mod_index = 7;
base_clock_mod_index = DEFAULT_CLOCK_MOD_INDEX;
base_probability = 100;
base_duty_cycle = 50;
base_offset = 0;
@ -64,6 +64,9 @@ class Channel {
cvmod_offset = base_offset;
cvmod_swing = base_swing;
cv1_dest = CV_DEST_NONE;
cv2_dest = CV_DEST_NONE;
pattern.Init(DEFAULT_PATTERN);
// Calcule the clock mod pulses on init.
@ -211,7 +214,7 @@ class Channel {
return;
}
int dest_mod = _calculateMod(CV_DEST_MOD, cv1_val, cv2_val, -(MOD_CHOICE_SIZE/2), MOD_CHOICE_SIZE/2);
int dest_mod = _calculateMod(CV_DEST_MOD, cv1_val, cv2_val, -(MOD_CHOICE_SIZE / 2), MOD_CHOICE_SIZE / 2);
cvmod_clock_mod_index = constrain(base_clock_mod_index + dest_mod, 0, 100);
int prob_mod = _calculateMod(CV_DEST_PROB, cv1_val, cv2_val, -50, 50);