# Desktop ↔ Web Comparison: e2e-04_sync_cue

- **Timestamp:** 2026-06-18T14:10:42.153Z
- **Capture window:** 20000 ms

## Code
```ruby
use_bpm 130
live_loop :drums do
 sample :bd_haus
 sleep 0.5
 cue :tick
 sample :drum_snare_hard, amp: 0.8
 sleep 0.5
end
live_loop :bass do
 sync :tick
 use_synth :tb303
 play :e2, release: 0.3, cutoff: 70
 sleep 0.5
end
live_loop :hats do
 sample :drum_cymbal_closed, amp: 0.5, rate: 2
 sleep 0.25
end
```

## Stats (Level 3 — observation, not inference)

| Metric | Desktop SP | SonicPi.js (web) | Δ (desk − web) |
|---------------|------------------------|-------------------------|----------------|
| Duration (s) | 21.371 | 19.712 | 1.659 |
| Peak | 0.3917 | 0.2912 | 0.1005 |
| RMS | 0.0775 | 0.0472 | 0.0303 |
| Clipping (%) | 0.00 | 0.00 | 0.00 |
| Sample rate (Hz) | 48000 | 48000 | 0 |
| Channels | 2 | 2 | — |

## Verdict
### ❌ EVENT-DIVERGE — per-synthdef `/s_new` onset-sequence/notes diverge from desktop : basic_mono_player: onset times match but per-tick NOTE multiset differs — wrong notes (transposition?). Real engine divergence (the audio verdict stands; the cos heuristic does not apply).

### Tier 0 — Validity gates
- ✓ 0.1 Sample rate consistent (48000 Hz)
- ⚠ 0.2 Capture-window misaligned (Δ 1.66s > 0.5s) — note-count / level aggregates unreliable **(SOFT — Tier 3 + 1.3 unreliable; Tier 1 pitch still valid)**
- ◦ 0.3 equal preconditions / 0.4 lossless capture / 0.5 routing sanity — not auto-checked; ensure SP.app reset + raw-float32 + FX-bus wired 

### Tier 1 — Musical correctness (THE verdict — energy/MFCC may never override)
- **1.1 Note progression:** ✗ PITCH DIVERGENCE at note 0 (desktop 56 vs web 40)
 - method: desktop `onset` (conf 1) · web `onset` (conf 1)
 - desktop: `56,40,40,40,40,40,40,56,56,40,40,40,40,56,56,40,40,40,40,40,56,56,40,40`
 - web&nbsp;&nbsp;&nbsp;: `40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40`
- **1.2 Tempo (inter-onset):** ✗ desktop 0.460s · web 0.240s/note
- **1.3 Onset count:** desktop 44 · web 64 (Δ explained by Tier-0 window misalignment)
- ◦ 1.4 note duration / 1.5 polyphony / 1.6 determinism — not auto-tracked here (unit tests cover determinism; see /)

### Tier 1.0 — Event parity (`/s_new` onset-sequence vs desktop — authoritative tiebreaker)
- **Structure (synthdef multiset):** STRUCTURE-MATCH — desktop 323 voice `/s_new`, web 315
- **Onset sequence (ε=15ms, prefix-compared, + per-tick NOTE multiset):** ✗ DIVERGE
 - ✗ `basic_mono_player` — onset times match within ε but per-tick NOTE multiset differs — wrong notes (transposition?)
 - ✓ `basic_stereo_player` — 45 onsets within ε (max Δ 1ms), notes match
 - ✓ `tb303` — 45 onsets within ε (max Δ 1ms), notes match
- ❌ **NOT event-match:** layers match but the onset sequence (timing or per-tick notes) diverges — a REAL engine bug (the audio DIVERGE stands).

### Tier 3 — Level / gain (reported; NOT a musical-correctness blocker — known ~0.5× web gain-staging)
> ⚠ Tier-0 SOFT failed — these ratios span misaligned windows; treat as indicative only.
- 3.1 RMS ratio web/desktop = 0.61× (within 0.5–2× band)
- 3.2 Peak ratio web/desktop = 0.74×
- 3.3 Clipping: desktop 0% · web 0% ✓ (< 1%)

### Tier 2 — Spectral / timbral (supporting only) · Tier 4 — FX/routing · Tier 5 — lifecycle
- Tier 2: see **Spectrogram comparison** section below (MFCC carries its mandatory caveat there).
- Tier 4 (FX accumulation/suppression 200ms scan, per-FX-scope energy): **not analysed** by this tool — use the FX-sweep / boundary-scan tools when FX is in scope.
- Tier 5 (Run/Stop/hot-swap, cold-start, long-run drift): **not analysed** — single capture; use `tools/test-run-stop-cycle.ts` for lifecycle.

## Source WAVs
- **Desktop:** /Users/mrityunjaybhardwaj/Documents/projects/sonicPiWeb/.captures/desktop-recordings/desktop_2026-06-18T14-09-46-993Z_e2e-04_sync_cue.wav
- **Web:** /Users/mrityunjaybhardwaj/Documents/projects/sonicPiWeb/.captures/2026-06-18T14-09-48-146Z_inline_audio.wav

## Spectrogram comparison
![spectrogram comparison](/Users/mrityunjaybhardwaj/Documents/projects/sonicPiWeb/.captures/compare_2026-06-18T14-10-14-133Z_e2e-04_sync_cue_spectrogram.png)

| Metric | Value | Reading |
|---|---|---|
| L2 distance (mel-dB) | 24.54 | < 10 = very close · 10–25 = similar shape · > 25 = divergent |
| MFCC distance (timbre) | 251.12 | < 30 = similar · 30–80 = noticeably different · > 80 = unrelated |
| ↳ MFCC caveat | — | **Tier-2 supporting only.** Confounded by the known ~0.5× web gain ratio + desktop reverb-tail length; **never overrides Tier 1** . A high MFCC with a Tier-1 PITCH-MATCH means timbre/gain, not wrong notes. |
| Frames compared | 1849 | overlapping window after length-aligning |
| Peak freq desktop | 56.3 Hz | dominant frequency |
| Peak freq web | 52.0 Hz | dominant frequency |
⚠ MFCC distance 251.12 is high — **check Tier 1 first**: if pitch-track matched, this is timbre/gain (the known 0.5× + reverb tail), NOT wrong notes. Only treat as "different synth/sample chain" when Tier 1 also diverges.

## Tool stdout (debug)
### Desktop
```
▶ Desktop capture (20000ms): e2e-04_sync_cue
✓ Report: /Users/mrityunjaybhardwaj/Documents/projects/sonicPiWeb/.captures/desktop_2026-06-18T14-09-46-993Z_e2e-04_sync_cue.md
✓ WAV: /Users/mrityunjaybhardwaj/Documents/projects/sonicPiWeb/.captures/desktop-recordings/desktop_2026-06-18T14-09-46-993Z_e2e-04_sync_cue.wav
 21.37s · peak 0.3917 · RMS 0.0775 · clip 0%
```
### Web
```
Launching Chromium (headed, audio capture)...
 Running: inline (20000ms)...

Capture saved: /Users/mrityunjaybhardwaj/Documents/projects/sonicPiWeb/.captures/inline.md
No errors detected.
```