Reverse the order of clock mod options. (#16)

This now matches original Gravity behavior. Also, now when applying CV mod positive voltages increase clock mod instead of reducing it.

Also fix pulse out, which wasn't previously updated when CLOCK_MOD was moved to program mem.

Reviewed-on: https://git.pinkduck.xyz/awonak/libGravity/pulls/16
This commit is contained in:
2025-07-22 00:00:49 +00:00
parent 4f04137f67
commit 1c0fb86bc1
3 changed files with 15 additions and 19 deletions

View File

@ -50,9 +50,6 @@ class Clock {
void Init() { void Init() {
NeoSerial.begin(31250); NeoSerial.begin(31250);
// Static pin definition for pulse out.
pinMode(PULSE_OUT_PIN, OUTPUT);
// Initialize the clock library // Initialize the clock library
uClock.init(); uClock.init();
uClock.setClockMode(uClock.INTERNAL_CLOCK); uClock.setClockMode(uClock.INTERNAL_CLOCK);

View File

@ -135,13 +135,12 @@ void HandleIntClockTick(uint32_t tick) {
break; break;
} }
const uint32_t pulse_high_ticks = CLOCK_MOD_PULSES[clock_index]; const uint16_t pulse_high_ticks = pgm_read_word_near(&CLOCK_MOD_PULSES[clock_index]);
const uint32_t pulse_low_ticks = tick + max((pulse_high_ticks / 2), 1L); const uint32_t pulse_low_ticks = tick + max((pulse_high_ticks / 2), 1L);
if (tick % pulse_high_ticks == 0) { if (tick % pulse_high_ticks == 0) {
gravity.pulse.High(); gravity.pulse.High();
} } else if (pulse_low_ticks % pulse_high_ticks == 0) {
if (pulse_low_ticks % pulse_high_ticks == 0) {
gravity.pulse.Low(); gravity.pulse.Low();
} }
} }

View File

@ -34,28 +34,28 @@ static const byte MOD_CHOICE_SIZE = 25;
// Negative numbers are multipliers, positive are divisors. // Negative numbers are multipliers, positive are divisors.
static const int CLOCK_MOD[MOD_CHOICE_SIZE] PROGMEM = { static const int CLOCK_MOD[MOD_CHOICE_SIZE] PROGMEM = {
// Multipliers
-24, -16, -12, -8, -6, -4, -3, -2,
// Internal Clock Unity
1,
// Divisors // Divisors
2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 16, 24, 32, 64, 128}; 128, 64, 32, 24, 16, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2,
// Internal Clock Unity (quarter note)
1,
// Multipliers
-2, -3, -4, -6, -8, -12, -16, -24};
// 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. // that match the above div/mult mods.
static const int CLOCK_MOD_PULSES[MOD_CHOICE_SIZE] PROGMEM = { static const int CLOCK_MOD_PULSES[MOD_CHOICE_SIZE] PROGMEM = {
// Multiplier Pulses (96 / X) // Divisor Pulses (96 * X)
4, 6, 8, 12, 16, 24, 32, 48, 12288, 6144, 3072, 2304, 1536, 1152, 1056, 960, 864, 768, 672, 576, 480, 384, 288, 192,
// Internal Clock Pulses // Internal Clock Pulses
96, 96,
// Divisor Pulses (96 * X) // Multiplier Pulses (96 / X)
192, 288, 384, 480, 576, 672, 768, 864, 960, 1056, 1152, 1536, 2304, 3072, 6144, 12288}; 48, 32, 24, 16, 12, 8, 6, 4};
static const byte DEFAULT_CLOCK_MOD_INDEX = 8; // x1 or 96 PPQN. static const byte DEFAULT_CLOCK_MOD_INDEX = 16; // x1 or 96 PPQN.
static const byte PULSE_PPQN_24_CLOCK_MOD_INDEX = 0; static const byte PULSE_PPQN_24_CLOCK_MOD_INDEX = MOD_CHOICE_SIZE - 1;
static const byte PULSE_PPQN_4_CLOCK_MOD_INDEX = 4; static const byte PULSE_PPQN_4_CLOCK_MOD_INDEX = MOD_CHOICE_SIZE - 6;
static const byte PULSE_PPQN_1_CLOCK_MOD_INDEX = 8; static const byte PULSE_PPQN_1_CLOCK_MOD_INDEX = MOD_CHOICE_SIZE - 9;
class Channel { class Channel {
public: public: