Fixed Indexing on Bell Output Assignments

This commit is contained in:
2025-10-18 18:43:51 +03:00
parent cc0bec97b5
commit 470d7bfacc
5 changed files with 27 additions and 33 deletions

View File

@@ -224,7 +224,14 @@ void BellEngine::playbackLoop() {
// Activate note with MAXIMUM PRECISION
activateNote(note);
// Precise timing delay
// Precise timing delay - validate speed to prevent division by zero
if (_player.speed == 0) {
LOG_ERROR("❌ Invalid speed=0 detected, stopping playback");
_player.hardStop = true;
_engineRunning.store(false);
return;
}
uint32_t tempoMicros = _player.speed * 1000; // Convert ms to microseconds
preciseDelay(tempoMicros);
}
@@ -252,7 +259,7 @@ void BellEngine::activateNote(uint16_t note) {
if (bellConfig == 0) continue;
// Convert 1-indexed config to 0-indexed bellIndex
uint8_t bellIndex = bellConfig - 1;
uint8_t bellIndex = bellConfig-1;
// Additional safety check to prevent underflow crashes
if (bellIndex >= 255) {