Fixed Indexing on Bell Output Assignments
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user