Skip to content

D39: read the Sound Designer II loop from sdLL, verified by the Digidesign spec - #82

Merged
bmxcode merged 1 commit into
mainfrom
d39-sd2-loops
Sep 5, 2026
Merged

bmxcode merged 1 commit into
mainfrom
d39-sd2-loops

Conversation

@bmxcode

@bmxcode bmxcode commented Sep 5, 2026

Copy link
Copy Markdown
Owner

Closes #75. Deferred from D33/ADR-0040.

What this does

D33 converts the 24 Sd2f files on sonic-images-v2 to WAV but writes no loop, because ADR-0025 forbids decoding a loop without an oracle — an off-by-units or off-by-a-field loop opens, plays, and reports nothing wrong. This reads the loop from the resource fork's sdLL region resource and carries it into the WAV smpl chunk, once an oracle exists to verify the interpretation.

The oracle

The hunt succeeded on path #1 of the three #75 named: the primary-source Digidesign Sound Designer II specification (© Digidesign 1988–1990), recovered from the Wayback Machine copy of lim.di.unimi.it/IEEE/DGDES/SDII.HTM (the live page is gone). It gives sdLL's exact layout and, decisively, its units — sample frames:

  • 8-byte header: Version, HScale, VScale, NumLoops (Int each), then NumLoops × a 14-byte LoopRecord: LoopStart, LoopEnd (LongInt, sample frames), LoopIndex (Int, 1..NumLoops), LoopSense (Int, 117 forward / 118 alternating), Channel (Int, 0..NumChannels-1), all big-endian.

Confirmed three ways — a stronger basis than the E-mu loops shipped on, which had no spec at all:

  1. The specification states the field widths and the units.
  2. Structural self-consistency on 24/24. Every sdLL is exactly 22 bytes = 8 + 14×1 with zero trailing bytes, Version 1, NumLoops 1, LoopSense 117 on all 24, LoopIndex 1, Channel 0 or 1 (in range, and varying — a real field), every LoopStart < LoopEnd ≤ frameCount. A wrong field layout cannot land all of these at once.
  3. Content corroboration on the disc itself. emu3.md's forward shape/join oracle — the 256 frames at the loop start correlated with the recorded continuation past the loop end — confirms 21 of the 24 loops at r ≥ 0.9 (23 at r ≥ 0.6). The forward window has power here precisely because SDII samples keep audio past the loop end, unlike the near-whole-extent eiv-analogia loops that needed the period window (ADR-0044).

What it decodes, and what it deliberately does not

  • One loop per record, in per-channel sample frames. The frame index is identical across an interleaved stereo file, so one record is one WAV loop, not one per channel (ADR-0025's "one loop, listed once"). Channel records which channel it was authored on and does not change the index.
  • The three weak loops are emitted and named, not gated out. F#2 Gtr Str, E1 Gtr Str, Obiestack C2 — inharmonic guitar/stack loops — score below the confirm bar because a forward window has no power on that timbre, not because the loop is wrong (the spec confirms the interpretation identically for all 24). They are emitted and pinned by name in the suite, the same stance ADR-0044 takes for eiv-analogia's unscorable loops.
  • No root key. sdLL carries none, so pitch stays None and the smpl chunk keeps the neutral MIDIUnityNote 60, exactly as the E-mu path does.
  • The ≤1-frame end convention (inclusive vs exclusive LoopEnd) is below audio resolution — the splice scores identically at LoopEnd-1/LoopEnd/LoopEnd+1 — so it is documented, not guessed.

Changes

  • src/samplerdisc/sample/sd2.py — _loops() decodes sdLL into a range-gated, degrade-safe Sd2Loop tuple; extract._convert_sd2 was already passing loops=_wav_loops(sample), so the loop flows through unchanged.
  • docs/formats/hfs.md — the verified sdLL layout table, units, and the three-part oracle, with the recovered source.
  • docs/adr/0046-the-sd2-loop-is-decoded-from-sdll.md — new ADR in the 0025 family; rejects emitting only the content-confirmed subset, and deferring for want of a per-file render.
  • tests/test_discs.py — test_hfs_sd2_loops_decode_and_splice: decode + WAV-smpl write-path (parsed back out of the file) + the forward-shape measurement, gated on the disc like the other oracles.
  • docs/README.md, docs/adr/README.md, README.md, CHANGELOG.md — D39 recorded; the earlier "SDII loop is not read" caveats updated.

Verify

uv run ruff check . · uv run ruff format --check . · uv run pytest -q · uv tool install --editable . && samplerdisc --version — all pass. With SAMPLERDISC_TEST_DISCS set, the disc-gated sd2/hfs family passes and end-to-end extract writes all 24 SDII WAVs carrying a smpl loop. No audio or disc images in the tree; the machfs byte oracle still pins every fork, so audio digests do not move.

🤖 Generated with Claude Code

…esign spec

The 24 Sd2f files on sonic-images-v2 (D33) converted without a loop, for
want of an oracle to verify the sdLL region resource against (ADR-0025).
The oracle is the Digidesign Sound Designer II specification itself
(recovered from the Wayback Machine): sdLL is an 8-byte header plus one
14-byte LoopRecord per loop, positions in sample frames.

sample/sd2.py now decodes sdLL into the WAV smpl chunk (one loop per
record, per-channel frames; root key still None). Confirmed three ways:
the spec; the layout decoding all 24 resources with zero leftover bytes
and every field on a documented in-range value (LoopSense 117 on all 24);
and emu3.md's forward shape/join oracle corroborating 21 of 24, the three
inharmonic guitar/stack loops it has no power on emitted and named.

Adds the verified sdLL layout to docs/formats/hfs.md, ADR-0046, a
disc-gated test in tests/test_discs.py, and CHANGELOG/README/README-index
entries. Closes #75.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@bmxcode
bmxcode merged commit 12fd891 into main Sep 5, 2026
2 checks passed
@bmxcode
bmxcode deleted the d39-sd2-loops branch September 5, 2026 10:40
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.

SDII loop: read the sdLL/sdDD region resources once an oracle can verify one

1 participant