Commit 9227ccf
AMYboard: phase-lock sketch loop() to the sequencer downbeat
Sketch loop() callbacks fire on the AMY sequencer's absolute tick grid
(every 6 ticks = a 32nd note), the same clock AMYSequence events use --
but a sketch's own step counter starts at 0 whenever the sketch loads,
which is some arbitrary 32nd note inside the bar. Any pattern built on
that counter plays at a constant phase offset from AMY-sequenced
patterns (e.g. dx7_groove_128_bpm's bass/piano/arp vs. its drums).
Two changes in _start_sketch_loop:
- The first loop() call is held until the next bar boundary
(tick % 192 == 0 at 48 PPQ, 4/4), so existing sketches' counters
start on the downbeat, in phase with AMYSequence bars.
- If the sketch declares loop(step), it gets the global 32nd-note
index on the bar-locked grid (step % 32 == 0 is always a downbeat).
Deriving position from step instead of a local counter also can't
drift if a callback is ever dropped (mp_sched_schedule queue full).
Plain loop() still works via a one-time TypeError fallback.
The default sketch template (amyboard.py and both spss.js copies)
now uses loop(step) and documents the grid.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>1 parent 60d7b67 commit 9227ccf
2 files changed
Lines changed: 46 additions & 12 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
90 | 90 | | |
91 | 91 | | |
92 | 92 | | |
93 | | - | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
94 | 96 | | |
95 | | - | |
| 97 | + | |
96 | 98 | | |
97 | 99 | | |
98 | 100 | | |
| |||
5635 | 5637 | | |
5636 | 5638 | | |
5637 | 5639 | | |
5638 | | - | |
| 5640 | + | |
5639 | 5641 | | |
5640 | 5642 | | |
5641 | 5643 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
197 | 197 | | |
198 | 198 | | |
199 | 199 | | |
200 | | - | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
201 | 203 | | |
202 | 204 | | |
203 | | - | |
| 205 | + | |
204 | 206 | | |
205 | 207 | | |
206 | 208 | | |
| |||
726 | 728 | | |
727 | 729 | | |
728 | 730 | | |
729 | | - | |
| 731 | + | |
| 732 | + | |
| 733 | + | |
| 734 | + | |
| 735 | + | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
| 739 | + | |
| 740 | + | |
730 | 741 | | |
731 | 742 | | |
732 | | - | |
| 743 | + | |
| 744 | + | |
| 745 | + | |
| 746 | + | |
| 747 | + | |
733 | 748 | | |
734 | 749 | | |
735 | | - | |
736 | | - | |
| 750 | + | |
| 751 | + | |
737 | 752 | | |
738 | | - | |
| 753 | + | |
739 | 754 | | |
740 | | - | |
| 755 | + | |
| 756 | + | |
| 757 | + | |
| 758 | + | |
| 759 | + | |
| 760 | + | |
| 761 | + | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
741 | 773 | | |
742 | 774 | | |
743 | 775 | | |
744 | 776 | | |
745 | | - | |
| 777 | + | |
746 | 778 | | |
747 | 779 | | |
748 | 780 | | |
| |||
0 commit comments