# Desktop ↔ Web Comparison: comm-in-thread-forum__48_lullaby

- **Timestamp:** 2026-06-18T15:18:17.146Z
- **Capture window:** 30000 ms

## Code
```ruby
# Source: https://in-thread.sonic-pi.net/t/slaapliedje-lullaby/9339
# Author: R2L
# Title: Slaapliedje (Lullaby)
# Captured: 2026-04-24

freqs = [27.5, 28.122, 28.758, 29.408, 30.073, 30.753, 31.448, 32.159, 32.887, 33.63, 34.391, 35.168, 35.963, 36.777, 37.608, 38.459, 39.328, 40.217, 41.127, 42.057, 43.008, 43.98, 44.975, 45.991, 47.031, 48.095, 49.182, 50.294, 51.432, 52.595, 53.784, 55.0, 56.244, 57.515, 58.816, 60.146, 61.506, 62.897, 64.319, 65.773, 67.26, 68.781, 70.336, 71.927, 73.553, 75.216, 76.917, 78.656, 80.435, 82.253, 84.113, 86.015, 87.96, 89.949, 91.983, 94.063, 96.19, 98.365, 100.589, 102.863, 105.189, 107.568, 110.0, 112.487, 115.031, 117.632, 120.292, 123.012, 125.793, 128.637, 131.546, 134.521, 137.562, 140.673, 143.853, 147.106, 150.433, 153.834, 157.312, 160.869, 164.507, 168.227, 172.031, 175.92, 179.898, 183.966, 188.126, 192.38, 196.729, 201.178, 205.727, 210.379, 215.135, 220.0, 224.975, 230.062, 235.264, 240.583, 246.023, 251.586, 257.275, 263.092, 269.041, 275.124, 281.345, 287.707, 294.212, 300.865, 307.668, 314.625, 321.739, 329.014, 336.453, 344.061, 351.841, 359.796, 367.932, 376.251, 384.759, 393.459, 402.356, 411.453, 420.757, 430.271, 440.0, 449.949, 460.123, 470.527, 481.166, 492.046, 503.172, 514.55, 526.184, 538.082, 550.249, 562.691, 575.414, 588.425, 601.73, 615.336, 629.25, 643.478, 658.028, 672.907, 688.122, 703.682, 719.593, 735.864, 752.503, 769.518, 786.918, 804.711, 822.907, 841.514, 860.542, 880.0]
set :offset, 119

define :get_midi do |note|
 midi_note = hz_to_midi(freqs[get[:offset] + note])
 return midi_note
end

live_loop :basic_beat do
 cue :start7tellen
 2.times do
 cue :maatvan2
 sample :perc_bell, beat_stretch: 0.35
 sleep 0.5
 sample :perc_bell, beat_stretch: 0.15, amp: 0.5
 sleep 0.5
 end
 cue :maatvan3
 sample :perc_bell, beat_stretch: 0.3
 sleep 0.5
 sample :perc_bell, beat_stretch: 0.2, amp: 0.5
 sleep 0.5
 sample :perc_bell, beat_stretch: 0.25, amp: 0.4
 sleep 0.5
end

live_loop :ritme3tegen2 do
 sync :maatvan2
 3.times do
 sample :perc_bell, amp: 0.4, beat_stretch: 0.2
 sleep 1.0 / 3
 end
 sleep -0.2
end

live_loop :ritme5tegen3 do
 sync :maatvan3
 5.times do
 sample :perc_bell, amp: 0.4, beat_stretch: 0.2
 sleep 1.5 / 5
 end
 sleep -0.2
end

live_loop :ritme11tegen7 do
 sync :start7tellen
 use_synth :saw
 n1 = get_midi(31)
 n2 = get_midi(0)
 n3 = get_midi(18)
 n4 = get_midi(14)
 n5 = get_midi(8)
 n6 = get_midi(26)
 n7 = get_midi(21)
 with_fx :reverb, room: 0.99, damp: 0.3, mix: 0.6 do
 11.times do
 play [n1,n2,n3,n4,n5,n6,n7].pick + [0,31,62].pick, amp: 0.06, pan: rrand(-1,1), attack: 0.01, sustain: 0.05, decay: 0, release: 0.05 if one_in(1)
 sleep 3.5 / 11
 end
 end
 sleep -0.2
end

live_loop :lange_noot do
 sync :start7tellen
 use_synth :supersaw
 with_fx :reverb, room: 0.99, damp: 0.2, mix: 0.8 do
 n = [0, 0, 0, 8, 14, 21, 26, 31].choose
 play get_midi(n), amp: 0.04, attack: 1, sustain: 0, release: 9, pan: rrand(-0.7,0.7) if one_in(2)
 end
end
```

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

| Metric | Desktop SP | SonicPi.js (web) | Δ (desk − web) |
|---------------|------------------------|-------------------------|----------------|
| Duration (s) | 31.371 | 29.696 | 1.675 |
| Peak | 0.0617 | 0.1006 | -0.0389 |
| RMS | 0.0035 | 0.0036 | -0.0001 |
| Clipping (%) | 0.00 | 0.00 | 0.00 |
| Sample rate (Hz) | 48000 | 48000 | 0 |
| Channels | 2 | 2 | — |

## Verdict
### ✅ EVENT-MATCH — per-synthdef `/s_new` onset-sequence + note parity STRUCTURE-MATCHES desktop : the engine emitted the right notes at the right times. The audio Tier-1 said _"PITCH DIVERGENCE at note 2 (desktop 80 vs web 87)"_, but that measures stage-7+ scsynth DSP (WASM-vs-native rendering / pitch-tracker noise), not the engine. Authoritative cross-engine check passes. · ⚠ Tier-0 SOFT: level/count aggregates unreliable (Tier 1 pitch unaffected)

### Tier 0 — Validity gates
- ✓ 0.1 Sample rate consistent (48000 Hz)
- ⚠ 0.2 Capture-window misaligned (Δ 1.67s > 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 2 (desktop 80 vs web 87)
 - method: desktop `onset` (conf 1) · web `onset` (conf 1)
 - desktop: `80,86,80,81,86,81,83,81,90,88,81,73,77,77,67,67,67,67,86,86,86,86,86,67`
 - web&nbsp;&nbsp;&nbsp;: `80,86,87,81,86,81,83,81,90,88,81,73,77,77,75,70,70,70,75,67,74,67,79,75`
- **1.2 Tempo (inter-onset):** ✓ desktop 0.310s · web 0.310s/note
- **1.3 Onset count:** desktop 82 · web 101 (Δ 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 335 voice `/s_new`, web 328
- **Onset sequence (ε=15ms, prefix-compared, + per-tick NOTE multiset):** ✓ MATCH
 - ✓ `saw` — 172 onsets within ε (max Δ 1ms), notes match
 - ✓ `basic_stereo_player` — 156 onsets within ε (max Δ 1ms), notes match
- ✅ **EVENT-MATCH:** structure + onset sequences both match — the engine's deterministic output (stages 1-6, terminating at the OSC emission) is correct. The audio Tier-1 divergence is stage-7+ scsynth rendering or tracker noise, not an engine bug (; #453/#379/#378 class).

### 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 = 1.03× (within 0.5–2× band)
- 3.2 Peak ratio web/desktop = 1.63×
- 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-18T15-17-01-898Z_comm-in-thread-forum__48_lullaby.wav
- **Web:** /Users/mrityunjaybhardwaj/Documents/projects/sonicPiWeb/.captures/2026-06-18T15-17-03-082Z_inline_audio.wav

## Spectrogram comparison
![spectrogram comparison](/Users/mrityunjaybhardwaj/Documents/projects/sonicPiWeb/.captures/compare_2026-06-18T15-17-39-497Z_comm-in-thread-forum__48_lullaby_spectrogram.png)

| Metric | Value | Reading |
|---|---|---|
| L2 distance (mel-dB) | 15.55 | < 10 = very close · 10–25 = similar shape · > 25 = divergent |
| MFCC distance (timbre) | 177.24 | < 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 | 2785 | overlapping window after length-aligning |
| Peak freq desktop | 1180.4 Hz | dominant frequency |
| Peak freq web | 14635.0 Hz | dominant frequency |
⚠ MFCC distance 177.24 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 (30000ms): comm-in-thread-forum__48_lullaby
✓ Report: /Users/mrityunjaybhardwaj/Documents/projects/sonicPiWeb/.captures/desktop_2026-06-18T15-17-01-898Z_comm-in-thread-forum__48_lullaby.md
✓ WAV: /Users/mrityunjaybhardwaj/Documents/projects/sonicPiWeb/.captures/desktop-recordings/desktop_2026-06-18T15-17-01-898Z_comm-in-thread-forum__48_lullaby.wav
 31.37s · peak 0.0617 · RMS 0.0035 · clip 0%
```
### Web
```
Launching Chromium (headed, audio capture)...
 Running: inline (30000ms)...

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