Clean baseline: skip tick-0 flash, first flash at tick 24 (first beat boundary)
This commit is contained in:
+3
-12
@@ -27,9 +27,8 @@ void midi_task(void* parameter) {
|
|||||||
Serial.println("[TASK] MIDI task started on core 0");
|
Serial.println("[TASK] MIDI task started on core 0");
|
||||||
|
|
||||||
// Beat timing fixes for precise beat alignment - sync to real MIDI time, not hardcoded tempo
|
// Beat timing fixes for precise beat alignment - sync to real MIDI time, not hardcoded tempo
|
||||||
uint32_t last_beat = UINT32_MAX;
|
uint32_t last_beat = 0;
|
||||||
uint32_t flash_start = 0;
|
uint32_t flash_start = 0;
|
||||||
uint8_t flash_peak = 255;
|
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
midi_transport.update();
|
midi_transport.update();
|
||||||
@@ -42,18 +41,10 @@ void midi_task(void* parameter) {
|
|||||||
uint32_t current_beat = tick / 24;
|
uint32_t current_beat = tick / 24;
|
||||||
|
|
||||||
// Check if we've crossed a beat boundary.
|
// Check if we've crossed a beat boundary.
|
||||||
// last_beat starts as UINT32_MAX so tick 0 (START) always triggers
|
|
||||||
if (current_beat != last_beat) {
|
if (current_beat != last_beat) {
|
||||||
last_beat = current_beat;
|
last_beat = current_beat;
|
||||||
flash_start = now;
|
flash_start = now;
|
||||||
// First beat after each START is beat 1 (downbeat) — full white
|
mux.set_led_color(6, 255, 255, 255);
|
||||||
// Loopy Pro sends START at bar boundaries so this is always beat 1
|
|
||||||
if (current_beat == 0) {
|
|
||||||
flash_peak = 255;
|
|
||||||
} else {
|
|
||||||
flash_peak = 64;
|
|
||||||
}
|
|
||||||
mux.set_led_color(6, flash_peak, flash_peak, flash_peak);
|
|
||||||
mux.show();
|
mux.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -66,7 +57,7 @@ void midi_task(void* parameter) {
|
|||||||
flash_start = 0;
|
flash_start = 0;
|
||||||
} else {
|
} else {
|
||||||
float b = 1.0f - (float)elapsed / 80.0f;
|
float b = 1.0f - (float)elapsed / 80.0f;
|
||||||
uint8_t v = (uint8_t)((float)flash_peak * b * b);
|
uint8_t v = (uint8_t)(255 * b * b);
|
||||||
mux.set_led_color(6, v, v, v);
|
mux.set_led_color(6, v, v, v);
|
||||||
mux.show();
|
mux.show();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user