Skip to content

Conversation

@vyagh
Copy link
Contributor

@vyagh vyagh commented Jan 29, 2026

Summary

This PR improves the rhythmic precision of MusicBlocks by integrating Tone.Transport into the runFromBlock execution flow. Previously, the engine relied solely on setTimeout for scheduling, which would cause audible timing drift and jitter during complex musical sequences.

The engine now checks if Tone.Transport is running. If so, it schedules block execution on the high-precision audio clock using scheduleOnce. It falls back to the standard setTimeout behavior when the transport is stopped or unavailable, maintaining backward compatibility.

Verification

Automated Tests:

  • Passed npm test, ensuring no regressions in existing logic.
  • New test suite js/tests/logo_timing.test.js passed, confirming the conditional logic for timer switching.

Manual Verification:

  • Verified in the browser that the usingToneTimer flag toggles to true when a block is executed while the audio transport is active.
  • Verified that execution halts correctly when using the Stop button for the cleanup logic

@github-actions
Copy link
Contributor

✅ All Jest tests passed! This PR is ready to merge.

@github-actions
Copy link
Contributor

✅ All Jest tests passed! This PR is ready to merge.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant