Description
WaitBlock in js/blocks/ExtrasBlocks.js at line 402 computes bpmFactor using incorrect operator precedence:
const bpmFactor =
TONEBPM / tur.singer.bpm.length > 0 ? last(tur.singer.bpm) : Singer.masterBPM;
Due to JavaScript operator precedence, / binds tighter than >, so this evaluates as (TONEBPM / bpm.length) > 0 instead of checking whether the bpm stack is non-empty. Since TONEBPM is 240, the condition is always true. When the bpm stack is empty, last([]) returns undefined, making bpmFactor undefined and noteBeatValue NaN. The Wait block silently computes incorrect timing.
Expected Behavior
When no BPM block is active, bpmFactor should fall back to Singer.masterBPM. The correct pattern is already used in RhythmBlockPaletteBlocks.js:183 and turtle-singer.js:1380:
TONEBPM / (tur.singer.bpm.length > 0 ? last(tur.singer.bpm) : Singer.masterBPM)
How to Reproduce
- Open Music Blocks in the browser
- Place a Wait block with no Set BPM block wrapping it
- Run the program
- Open the console (Ctrl+Shift+J)
- noteBeatValue is NaN and wait duration is incorrect
Console log Errors
noteBeatValue evaluates to NaN when the bpm stack is empty.
Environment
- Operating System: Windows 11
- Browser: Chrome
- Version of Software/Project: master
Checklist
Description
WaitBlockinjs/blocks/ExtrasBlocks.jsat line 402 computesbpmFactorusing incorrect operator precedence:Due to JavaScript operator precedence, / binds tighter than >, so this evaluates as (TONEBPM / bpm.length) > 0 instead of checking whether the bpm stack is non-empty. Since TONEBPM is 240, the condition is always true. When the bpm stack is empty, last([]) returns undefined, making bpmFactor undefined and noteBeatValue NaN. The Wait block silently computes incorrect timing.
Expected Behavior
When no BPM block is active, bpmFactor should fall back to Singer.masterBPM. The correct pattern is already used in RhythmBlockPaletteBlocks.js:183 and turtle-singer.js:1380:
How to Reproduce
Console log Errors
noteBeatValue evaluates to NaN when the bpm stack is empty.
Environment
Checklist