Monorepo for Aesthetic.Computer aesthetic.computer
at main 67 lines 2.4 kB view raw view rendered
1# Clock Parallel Track Timing Fix 2 3## Problem Statement 4 5When running `clock *lene` (melody: `^f..afafa...efefef..bababa.fgg..b...agfededcd {noise-white}-^f.fffffff`): 6 7- **Track 1**: 31 notes, 13 beats (6500ms cycle) 8- **Track 2**: 9 notes (1 rest + 8 f's), 12 beats (6000ms cycle) 9 10**Expected**: Each track loops independently at its own duration. 11**Actual**: Track 2's first cycle shows "EARLY" because we skip leading rests on init. 12 13## Root Cause Analysis 14 15The `-` character creates a 4-beat rest at the start of Track 2. During initialization: 161. We skip leading rests by advancing `noteIndex` to the first audible note 172. **First cycle is shorter**: Only plays 8 beats (4000ms), not 12 beats (6000ms) 183. After loop 1, the rest offset (2000ms) is added, so subsequent cycles are correct 19 20## Fix Applied 21 22The expected duration calculation now accounts for the first cycle being shorter: 23 24```javascript 25const isFirstCycle = trackState.loopCount === 1; 26const expectedDuration = isFirstCycle 27 ? (trackState.expectedCycleDuration || 0) - (trackState.initialRestOffset || 0) 28 : (trackState.expectedCycleDuration || 0); 29``` 30 31## Console Output (Now Clean) 32 33Only cycle timing logs appear: 34``` 35⏱️ T1 INIT | 13 beats = 6500ms expected cycle 36⏱️ T2 INIT | 12 beats = 6000ms expected cycle (has leading rest) 37⏱️ T2 loop 1 @ ...ms | cycle: 4000ms (expected: 4000ms ✓) ← First cycle is 4000ms! 38⏱️ T1 loop 1 @ ...ms | cycle: 6500ms (expected: 6500ms ✓) 39⏱️ T2 loop 2 @ ...ms | cycle: 6000ms (expected: 6000ms ✓) ← Subsequent cycles are 6000ms 40⏱️ T1 loop 2 @ ...ms | cycle: 6500ms (expected: 6500ms ✓) 41``` 42 43## Verbose Logs Removed 44 45- `🎵 EARLY MELODY STATE SET` 46- `🎵 Fetching cached melody` 47- `🎵 Loaded cached melody` 48- `🎵 Clock author` 49- `🎵 About to process melody` 50- `🎵 Original/Converted` 51- `🎵 Parsed melodyTracks` 52- `🎵 SIM FIRST RUN` 53- `📐 RENDER GEOMETRY` (table) 54- `✅ No overlapping boxes` 55- `📱 HUD QR render check` 56- `⌨️📍 [bios pointerup]` 57- `⌨️🔴 [input blur event]` 58- `🔊 Synth created` (from speaker.mjs) 59- `🔊 process() call` (from speaker.mjs) 60- `🔊 #processAudio` (from speaker.mjs) 61 62## Files Changed 63 64- `clock.mjs`: Fixed first-cycle expected duration, disabled geometry/melody debug logs 65- `speaker.mjs`: Disabled synth creation and process() debug logs 66- `disk.mjs`: Disabled QR render debug log 67- `bios.mjs`: Disabled keyboard input debug logs