diff --git a/CHANGELOG.md b/CHANGELOG.md
index 07c6e4e..cb98ac1 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -18,11 +18,15 @@ Notable changes to `samplerdisc`. Format-level findings live in [docs/formats/](
### Added
+- **Sound Designer II files now carry their loop points.** D33 converted the 24 `Sd2f` files on `sonic-images-v2` to WAV but wrote no loop: the resource fork carries a Digidesign `sdLL` loop resource, but decoding it without an oracle risks an off-by-units loop that plays and reports nothing wrong, the failure [ADR-0025](docs/adr/0025-the-loop-is-decoded-the-root-key-is-not.md) refuses. That oracle turned out to be the **Digidesign Sound Designer II specification itself** (© 1988–1990, recovered from the Wayback Machine — the live page is gone), which gives `sdLL`'s layout and, decisively, its units: an 8-byte header (a version and a loop count) then one 14-byte record per loop, each a start and end **sample frame**, an index, a sense (117 forward) and a channel. The loop now goes into the WAV's `smpl` chunk, one per record, in per-channel frames; the root key is still not read, because `sdLL` carries none. **If you extracted a SampleCell disc before this, extract it again for the Sound Designer II loops.** ([docs/formats/hfs.md](docs/formats/hfs.md), [ADR-0046](docs/adr/0046-the-sd2-loop-is-decoded-from-sdll.md), [#75](https://github.com/bmxcode/samplerdisc/issues/75))
+
+ **Confirmed three ways, a stronger basis than the E-mu loops shipped on.** The spec states the units. The layout decodes all 24 resources with **zero leftover bytes** and every field on a documented, in-range value — `LoopSense` reads the forward-loop constant `117` on all 24, `NumLoops` 1, the channel varying in range — which a wrong field layout cannot do at once. And [emu3.md](docs/formats/emu3.md)'s own forward shape/join oracle — the audio at the loop start correlated with the recorded continuation past the loop end — confirms **21 of the 24** (r ≥ 0.9). The three it cannot vouch for are inharmonic guitar/stack loops (`F#2 Gtr Str`, `E1 Gtr Str`, `Obiestack C2`) where a forward window has no power; they are emitted and named, not hidden, exactly as `eiv-analogia`'s unscorable loops are ([ADR-0044](docs/adr/0044-the-eiv-residual-loop-is-confirmed-by-its-period.md)). The disc-backed suite decodes all 24, checks each loop reaches the `smpl` chunk a DAW would read, and pins the weak set by name.
+
- **Loose E-mu `.ebl` sample banks convert without a disc image.** The `.EBL` decoder was verified for mono and stereo, but every command took a disc image, so the E-mu libraries archive.org ships as loose files in the clear — an `.exb` bank definition beside a `SamplePool/*.ebl`, with no ISO around them — had no way in. A new `extract-banks
` verb converts them, and `batch` now discovers loose-bank trees beside disc images. A directory of sample files is a **source**, not a container: the operating system's filesystem has already done what a container strips and an on-disc filesystem finds, so the tool walks the tree for `*.ebl` and hands each file's bytes to the same decode-and-write path the ISO 9660 backend uses — no synthetic container, no `Backend` ([ADR-0042](docs/adr/0042-loose-sample-banks-are-a-source-not-a-container.md)). This reverses the loose-bank refusal ADR-0033/0041 recorded, which was right when the loose banks were only test fixtures and wrong now they are content people hold. Only the `.ebl` are read; the `.exb` preset is left to [ConvertWithMoss](https://github.com/git-moss/ConvertWithMoss) as on a disc ([ADR-0011](docs/adr/0011-the-deliverable-is-daw-ready-wav.md)). Verified on the real Proteus 1/2/3 banks: **686 convert, 685 mono and one genuinely-stereo (`Snare w/Verb 28K`), none refused.** That one stereo file has no publisher render to check its interleave against — Proteus is not among the rendered banks — so it rests on the `V12`/end-anchored rules proven on 636 stereo files across four other banks, recorded as borrowed evidence rather than hidden ([docs/formats/emu-ebl.md](docs/formats/emu-ebl.md), [ADR-0042](docs/adr/0042-loose-sample-banks-are-a-source-not-a-container.md)). ([#57](https://github.com/bmxcode/samplerdisc/issues/57))
- **Stereo E-mu `.EBL` banks now convert to stereo WAV.** D33 shipped the mono `.EBL` reader and *refused* stereo — the format stores it non-interleaved (a whole left block then a whole right block, `LLLL…RRRR`), and with no stereo bank paired with a render to check an interleave against, converting one by an unverified rule would have written audio that plays as noise and reports nothing wrong ([ADR-0026](docs/adr/0026-the-record-declares-the-channel-count.md)). That oracle now exists: E-mu Classic Series Vol 13 Dance 2000 ships as loose `.ebl` and mattetti renders its 636 stereo files to FLAC. Each of a stereo record's two equal, contiguous blocks is `V3 − V2` bytes, so the audio is `2·(V3 − V2)` ending at the loop trailer or EOF, and the two blocks are interleaved to `LRLR` with the shared `stereo.interleave` — the same call the [EMU3](docs/formats/emu3.md) backend and the AKAI `-L`/`-R` joiner use — with no value altered, only reordered. The split is anchored from the **end** rather than the front: the mono path's `block + V2 − 4` start is two bytes early on the grand banks, a shift the render check exposed and the from-the-end anchor fixes. The loop and channel count come straight off the record, the loop in per-channel frames. **Verified byte-for-byte against the publisher's own render:** every uniquely-named stereo file on Dance 2000 (375) and mattetti's entirely-stereo grands — Giga Schimme (120), EW PS18 Steinberg Grand (441 rendered), Studio Grand (408) — every matched file PCM-exact. Vintage Pro is unaffected (all mono). ([docs/formats/emu-ebl.md](docs/formats/emu-ebl.md), [ADR-0041](docs/adr/0041-stereo-ebl-is-interleaved-and-verified-by-the-render.md), [#57](https://github.com/bmxcode/samplerdisc/issues/57))
-- **Sound Designer II (`Sd2f`) files on a SampleCell disc convert to WAV.** D32 read the SampleCell discs but skipped their 24 Sound Designer II files, on the belief that SDII keeps its audio in the HFS *resource* fork — a harder format left for later. That belief was wrong. Read against the disc and cross-checked with libsndfile, each `Sd2f` file keeps its audio in the **data fork** — plain big-endian PCM, which the backend already read — and only its rate, width and channel count in the resource fork, as three `STR ` resources. So `sonic-images-v2` now converts all **24** to stereo 44.1 kHz 16-bit WAV (the disc goes 288 → **312** sounds), the audio carried over by reversing byte order and nothing else, exactly as an AIFF is ([ADR-0011](docs/adr/0011-the-deliverable-is-daw-ready-wav.md)). The SDII **loop** is not read: the resource fork may carry one (`sdLL`), but there is no oracle to verify an interpretation against, so it is left rather than guessed ([ADR-0025](docs/adr/0025-the-loop-is-decoded-the-root-key-is-not.md)). **If you extracted a SampleCell disc before this, extract it again for the Sound Designer II files.** ([docs/formats/hfs.md](docs/formats/hfs.md), [ADR-0040](docs/adr/0040-sound-designer-ii-is-decoded-from-the-data-fork.md), [#72](https://github.com/bmxcode/samplerdisc/issues/72))
+- **Sound Designer II (`Sd2f`) files on a SampleCell disc convert to WAV.** D32 read the SampleCell discs but skipped their 24 Sound Designer II files, on the belief that SDII keeps its audio in the HFS *resource* fork — a harder format left for later. That belief was wrong. Read against the disc and cross-checked with libsndfile, each `Sd2f` file keeps its audio in the **data fork** — plain big-endian PCM, which the backend already read — and only its rate, width and channel count in the resource fork, as three `STR ` resources. So `sonic-images-v2` now converts all **24** to stereo 44.1 kHz 16-bit WAV (the disc goes 288 → **312** sounds), the audio carried over by reversing byte order and nothing else, exactly as an AIFF is ([ADR-0011](docs/adr/0011-the-deliverable-is-daw-ready-wav.md)). The SDII **loop** in the `sdLL` resource is read too — see the Sound Designer II loop entry above; it needed an oracle this deliverable did not yet have ([ADR-0025](docs/adr/0025-the-loop-is-decoded-the-root-key-is-not.md), [ADR-0046](docs/adr/0046-the-sd2-loop-is-decoded-from-sdll.md)). **If you extracted a SampleCell disc before this, extract it again for the Sound Designer II files.** ([docs/formats/hfs.md](docs/formats/hfs.md), [ADR-0040](docs/adr/0040-sound-designer-ii-is-decoded-from-the-data-fork.md), [#72](https://github.com/bmxcode/samplerdisc/issues/72))
**Verified byte for byte against the disc.** `machfs` now cross-checks *both* forks — every data fork and every resource fork, the 24 SDII resource forks included — and because the audio is a verbatim byte-swap of the data fork, our little-endian PCM swapped back to big-endian equals `machfs`'s data fork exactly, the "payload is the disc's own bytes" check AKAI uses. The corrected premise is recorded where the wrong one lived, in [docs/formats/hfs.md](docs/formats/hfs.md) and [ADR-0039](docs/adr/0039-samplecell-is-read-as-hfs-behind-an-apple-partition-map.md).
diff --git a/README.md b/README.md
index 006d0de..cb2affb 100644
--- a/README.md
+++ b/README.md
@@ -114,7 +114,7 @@ The other 23 are damage of a different kind, and 19 of them are not damage at al
**Eight of the 45 AKAI images are short of the disc they were made from.** Whole 32 KB blocks are missing from the file, so every partition after a gap sits that much nearer the front than the disk's own table says — and 39 of them are found there and read, carrying 17 180 files and 15 808 samples that nothing could reach before. `list` and the manifest say so per disc: *"11 partitions declared, 8 present in this image (7 of them displaced — this image is short of the disc it was made from)"*. 70 declared partitions are still unread, and 60 of those are refused rather than absent: a header is there, inside a partition already being read, and reading it would put one run of bytes under two partitions at once ([ADR-0028](docs/adr/0028-a-displaced-partition-is-anchored-quantised-and-floored.md)).
-The four that do not convert are accounted for: one S-550 disc present as both `.iso` and `.nrg` — a different format from the S-7xx and not yet read ([ADR-0014](docs/adr/0014-one-backend-per-on-disc-format.md)) — and one audio CD with no cue sheet present as both `.mdx` and `.cdr`. The two Digidesign SampleCell discs now convert: their AIFF (D32) and their Sound Designer II files (D33, [ADR-0040](docs/adr/0040-sound-designer-ii-is-decoded-from-the-data-fork.md)).
+The four that do not convert are accounted for: one S-550 disc present as both `.iso` and `.nrg` — a different format from the S-7xx and not yet read ([ADR-0014](docs/adr/0014-one-backend-per-on-disc-format.md)) — and one audio CD with no cue sheet present as both `.mdx` and `.cdr`. The two Digidesign SampleCell discs now convert: their AIFF (D32) and their Sound Designer II files (D33, [ADR-0040](docs/adr/0040-sound-designer-ii-is-decoded-from-the-data-fork.md)), the SDII loop carried into the WAV `smpl` chunk from the `sdLL` resource against the Digidesign spec (D39, [ADR-0046](docs/adr/0046-the-sd2-loop-is-decoded-from-sdll.md)).
### The E-mu EBL banks
diff --git a/docs/README.md b/docs/README.md
index 555b6cc..437a7f6 100644
--- a/docs/README.md
+++ b/docs/README.md
@@ -77,6 +77,7 @@ All of that vanishes into a working parser. Six months on, the code says *what*
| D36 | E-IV disc provenance read from the sample-free `Credits`/`E-mu Systems 96` text banks' `E4P1` name field — the credit line alone, never the preset — into a per-disc `Credits.txt` sidecar under `--metadata`; eight banks, 89 lines across five discs ([ADR-0043](adr/0043-eiv-credits-are-metadata-read-from-the-e4p1-name-field.md)) | done |
| D37 | `eiv-analogia`'s residual E-IV loops given the disc's own confirmation by a period / pre-start window — four of its six splice at their own period as a clear local maximum where the forward oracle had no power; the two that do not (`Conscience Call`, `Got Scratch?`) are named, not hidden. A measurement wired into the suite; no emission, loop count or digest moved ([ADR-0044](adr/0044-the-eiv-residual-loop-is-confirmed-by-its-period.md)) | done |
| D38 | An AKAI sample displaced by a run of blocks lost *inside* a partition the table calls complete is recovered — searched for backward in the container's unit for a header restating the entry's own name and word count, floored at the partition. 102 of the 104 refused across nine discs are written; the two that are not (`Loop Soup`'s mid-sample record, `Library.3`'s cross-partition namesake) are named. The chain cannot see the gap, so the payload check is the sole detector; ADR-0027's name test is the anchor, exercised on real data at last ([ADR-0045](adr/0045-a-displaced-sample-is-recovered-by-its-own-name-and-word-count.md)) | done |
+| D39 | The Sound Designer II loop is read from the resource fork's `sdLL` list resource and carried into the WAV `smpl` chunk — the layout is the Digidesign spec (an 8-byte header and a 14-byte `LoopRecord`, positions in sample frames), confirmed on all 24 `Sd2f` files structurally and by emu3's forward shape oracle (21 of 24; the three inharmonic guitar/stack loops it has no power on are emitted and named). One loop per record, root key still not read — reversing D33's loop deferral ([ADR-0046](adr/0046-the-sd2-loop-is-decoded-from-sdll.md)) | done |
Across the local collection, by listing: 96 of 104 images claimed, 4 270 volumes, 161 213 files, 126 361 of them samples. The AKAI discs are 45 of those images and 86 487 of those files, read across 318 partitions — 279 where the disk's table puts them and 39 displaced by blocks the rip lost. Before D15 they were 14 783 files, because only the partition at the origin was read.
@@ -100,6 +101,6 @@ Across the local collection, by listing: 96 of 104 images claimed, 4 270 volumes
- **AIFF-C is refused rather than read.** Its payload may be compressed, and compressed data written out as PCM opens, plays as noise and reports nothing wrong. No disc in the collection has one, so there is nothing to check a reader against ([ADR-0024](adr/0024-the-aiff-twin-is-converted-and-deduplicated.md)).
- **8-bit AIFF is refused.** AIFF stores 8-bit signed and WAV unsigned, so carrying one to the other changes every sample value rather than reordering its bytes. That is the line ADR-0024 draws; nothing in the collection is other than 16-bit.
-- **Sound Designer II on SampleCell discs is read (D33).** `sonic-images-v2`'s 24 `Sd2f` files now convert to stereo 44.1 kHz WAV. The premise D32 deferred them on was wrong: the audio is the **data fork** (big-endian PCM, which the backend already read), not the resource fork — only the rate/width/channels are in the resource fork, in three `STR ` resources ([ADR-0040](adr/0040-sound-designer-ii-is-decoded-from-the-data-fork.md), [formats/hfs.md](formats/hfs.md)). Verified byte-for-byte against `machfs` on both forks, and by the data-fork byte-swap self-check. What stays deferred is the SDII **loop**: `sdLL` may carry one, but there is no oracle to verify an interpretation against, so it is left rather than guessed ([ADR-0025](adr/0025-the-loop-is-decoded-the-root-key-is-not.md)). HFS+ (`drSigWord` `H+`) is still refused at the MDB signature; none is in hand.
+- **Sound Designer II on SampleCell discs is read (D33).** `sonic-images-v2`'s 24 `Sd2f` files now convert to stereo 44.1 kHz WAV. The premise D32 deferred them on was wrong: the audio is the **data fork** (big-endian PCM, which the backend already read), not the resource fork — only the rate/width/channels are in the resource fork, in three `STR ` resources ([ADR-0040](adr/0040-sound-designer-ii-is-decoded-from-the-data-fork.md), [formats/hfs.md](formats/hfs.md)). Verified byte-for-byte against `machfs` on both forks, and by the data-fork byte-swap self-check. The SDII **loop** is now read too (D39): the `sdLL` resource's layout is the Digidesign spec — an 8-byte header and a 14-byte `LoopRecord` with positions in sample frames — confirmed on all 24 files structurally and by emu3's forward shape oracle on 21 of them, the three it has no power on emitted and named ([ADR-0046](adr/0046-the-sd2-loop-is-decoded-from-sdll.md)). The root key is still not read: `sdLL` carries none. HFS+ (`drSigWord` `H+`) is still refused at the MDB signature; none is in hand.
- **A loose stereo `.ebl` outside a rendered bank rests on borrowed evidence.** Stereo `.EBL` converts (D34, [ADR-0041](adr/0041-stereo-ebl-is-interleaved-and-verified-by-the-render.md)) and loose banks convert (D35, [ADR-0042](adr/0042-loose-sample-banks-are-a-source-not-a-container.md)), verified byte-for-byte against the publisher's render wherever one exists — 636 files on Dance 2000 and the entirely-stereo grands. The Proteus banks D35 reads have no render, and one of their 686 files (`Snare w/Verb 28K`) is stereo: it is classified and interleaved by the `V12`/end-anchored rules proven on 636 files across four other banks, but that specific interleave is not checked against its own oracle. A Proteus render would settle it ([formats/emu-ebl.md](formats/emu-ebl.md)).
- **The E-mu `.exb` bank definition is not read.** Vintage Pro's `.exb` — and the loose Proteus `.exb` beside each `SamplePool` — holds the preset key ranges and zone mappings the same way an E-IV preset does; it is listed and, like EXS24 and `E4P1` presets, left to [ConvertWithMoss](https://github.com/git-moss/ConvertWithMoss) rather than converted ([ADR-0011](adr/0011-the-deliverable-is-daw-ready-wav.md)).
diff --git a/docs/adr/0046-the-sd2-loop-is-decoded-from-sdll.md b/docs/adr/0046-the-sd2-loop-is-decoded-from-sdll.md
new file mode 100644
index 0000000..eee20e1
--- /dev/null
+++ b/docs/adr/0046-the-sd2-loop-is-decoded-from-sdll.md
@@ -0,0 +1,49 @@
+# ADR-0046 · The Sound Designer II loop is decoded from `sdLL`, confirmed by the Digidesign spec and the disc's own splice
+
+**Status:** accepted · 2026-09-05
+
+## Context
+
+D33 read the 24 `Sd2f` files on `sonic-images-v2` — audio from the data fork, rate/width/channels from the resource fork's three `STR ` resources — but shipped **no loop** ([ADR-0040](0040-sound-designer-ii-is-decoded-from-the-data-fork.md), [issue #75](https://github.com/bmxcode/samplerdisc/issues/75)). The resource fork carries a Digidesign `sdLL` loop resource whose first file "even looks like a loop (two in-range frame values)", but [ADR-0025](0025-the-loop-is-decoded-the-root-key-is-not.md) forbids decoding a loop without an oracle: an off-by-units or off-by-a-field loop opens, plays, and reports nothing wrong. D33 had no oracle for `sdLL`, so it deferred it against "a specimen whose loop can be confirmed."
+
+That oracle now exists, and it is the first of the three the issue named: **a Digidesign specification for the `sdLL`/`sdDD` layout.** The Sound Designer II File Format document (© Digidesign 1988–1990), recovered from the Wayback Machine copy of `lim.di.unimi.it/IEEE/DGDES/SDII.HTM` (the live page is gone), gives every field, its width, and its units. `sdLL` is an 8-byte header — `Version` (Int, 1), `HScale` and `VScale` (Int, unused), `NumLoops` (Int) — followed by `NumLoops` × a 14-byte `LoopRecord`: `LoopStart` and `LoopEnd` (LongInt, "reference to start/end **sample frame** of this loop"), `LoopIndex` (Int, `1..NumLoops`), `LoopSense` (Int, `117` forward / `118` alternating), `Channel` (Int, `0..NumChannels-1`), all big-endian. `sdDD` is a `DocumentDataRecord` of display and session state (comments, zoom, cursor), carrying no audio loop.
+
+## Decision
+
+**Decode the loop from `sdLL` and carry it into the WAV `smpl` chunk. Do not decode a root key, because `sdLL` carries none.**
+
+`sample/sd2.py` reads the id-1000 `sdLL` body, takes `NumLoops` from the header and reads that many records, and keeps a loop only where it lies inside the audio (`0 <= LoopStart < LoopEnd <= frameCount`) — a truncated or out-of-range resource yields no loop rather than an invented one, the degrade-don't-crash stance the rest of the module already takes. The frame positions are **per-channel and identical across an interleaved stereo file**, so one record becomes one WAV loop, not one per channel — the same "one loop in the audio, listed once" ADR-0025 settled for E-mu's two pointer sets. `Channel` records which channel the loop was authored on and does not change the frame index. `pitch` stays `None` and the `smpl` chunk keeps `MIDIUnityNote` 60, exactly as the E-mu path does: the neutral value, not a finding. `extract._convert_sd2` already passed `loops=_wav_loops(sample)`, so once `sample.loops` is populated the loop flows through unchanged.
+
+### The interpretation is confirmed three ways
+
+This is a stronger basis than the E-mu loops shipped on, which had no spec at all — only content correlation.
+
+1. **The specification** states the field widths and, decisively, the **units: sample frames**, which is the exact ambiguity ADR-0025 exists to guard against.
+2. **Structural self-consistency on 24/24.** Read against the disc, 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, not a constant), and every `LoopStart < LoopEnd ≤ frameCount`. A wrong field layout cannot land all of these at once; that they all fall out at no cost is the same argument ADR-0025 made from the E-mu pointer block.
+3. **Content corroboration on the disc itself.** The [emu3.md](../formats/emu3.md) forward shape/join oracle — the 256 frames at the loop start correlated with the recorded continuation past the loop end, which for a periodic instrument tone is the same waveform one period-multiple later — 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](0044-the-eiv-residual-loop-is-confirmed-by-its-period.md)).
+
+### The few weak loops are emitted and named, not gated out
+
+Three loops — `F#2 Gtr Str`, `E1 Gtr Str`, `Obiestack C2`, inharmonic guitar and stack sounds whose start does not periodically predict their post-end audio — score below the *r* ≥ 0.9 confirm bar (only `F#2 Gtr Str` below *r* ≥ 0.6). All 24 are emitted anyway. The spec confirms the *interpretation* identically for all 24 — same version, same one-record structure, same forward sense — so a low forward-shape score is a **lack of power on that sample, not evidence of a wrong loop**, and refusing it would be refusing on tool power rather than on the disc. This is the stance ADR-0025 and ADR-0044 already take, still emitting `eiv-analogia`'s `Conscience Call` and `Got Scratch?`. The three are pinned by name in `tests/test_discs.py`, so a regression that drops a currently-confirmed loop below the bar breaks the set.
+
+### The end convention is documented, not guessed
+
+`LoopEnd` is the loop's inclusive end frame; the decoder stores it as an exclusive `end` and the WAV writer makes it inclusive again for RIFF. Whether the intended end is `LoopEnd`, `LoopEnd-1` or `LoopEnd+1` is **below audio resolution** — the forward splice scores identically at all three — so the ≤1-frame ambiguity is recorded here and in [formats/hfs.md](../formats/hfs.md) rather than pretended away.
+
+## Alternatives rejected
+
+**Emit only the content-confirmed subset** (ship ~21, refuse the rest), the way `esi32-gm` ships loops on a fraction of its samples ([ADR-0025](0025-the-loop-is-decoded-the-root-key-is-not.md)). Rejected: that refusal was on a *measurement that a clamped loop end was not a loop* — evidence the loop was wrong. Here the evidence runs the other way: the spec confirms the interpretation for all 24 identically, and the weak three differ only in how much power a forward window has on that timbre. Gating them out would ship a confusing split on one disc for no gain in correctness, and it contradicts ADR-0044's own precedent of emitting unscorable loops.
+
+**Defer for want of a per-file content oracle**, holding out for a published render of these exact loops (the EBL/KRZ pattern). Rejected: the issue names "a Digidesign spec for the `sdLL`/`sdDD` layout (field widths, units, the meaning of the leading count fields)" as acceptance path #1, and it is in hand and confirmed against the disc. No render of a 1990s SampleCell library's loops exists to wait for.
+
+**Read a root key from `sdDD` or the sample name.** Rejected: `sdDD` holds no root key (it is document/display state), and inferring pitch from the sample name is the labelled-text inference ADR-0025 rejected for E-mu — output indistinguishable from a decoded field.
+
+## Consequences
+
+**Good.** The 24 `sonic-images-v2` SDII WAVs now carry their loop points, which a DAW may honour and any may ignore ([ADR-0011](0011-the-deliverable-is-daw-ready-wav.md)). The loop was on the disc and is lost when the disc is. The `sdLL` layout is written down in [formats/hfs.md](../formats/hfs.md) with the recovered source, so the next session inherits the fact, not another hex-editor afternoon.
+
+**Good, and asserted.** The change is additive — `_convert_sd2` and the audio path are untouched — and the `machfs` byte oracle (D32/D33) still pins every fork byte-for-byte, so the audio digests do not move.
+
+**Bad, and named.** Three loops rest on the spec and structural consistency without their own forward-shape confirmation, because the instrument has no power on their timbre. They are emitted and pinned by name, the same residual ADR-0044 carries for `eiv-analogia`.
+
+**Watch for.** A SampleCell disc whose `sdLL` carries `NumLoops > 1`, an alternating (`118`) sense, or a non-`Sd2f` shape. The reader handles all three by construction (it reads the count, maps `118` to the RIFF alternating type, and range-gates each record), but only the single-forward-loop case is exercised on a real disc — the rest is synthetic until a second SDII specimen turns up.
diff --git a/docs/adr/README.md b/docs/adr/README.md
index 2ae103b..bcb5a70 100644
--- a/docs/adr/README.md
+++ b/docs/adr/README.md
@@ -51,3 +51,4 @@ If you find yourself writing an ADR with no rejected alternative, you are writin
| [0043](0043-eiv-credits-are-metadata-read-from-the-e4p1-name-field.md) | E-IV credits are metadata, read from the `E4P1` name field alone — a per-disc `Credits.txt` sidecar under `--metadata`, from the sample-free `Credits`/`E-mu Systems 96` text banks, never the preset | Reading the `TOC1` concatenation instead; dumping every disc's TOC and preset names; folding the sidecar into `--keep-originals`; always writing `Credits.txt`; carrying the credits in a WAV `LIST`/`INFO` chunk |
| [0044](0044-the-eiv-residual-loop-is-confirmed-by-its-period.md) | The E-IV residual loop is confirmed by its period — the pre-start window, which survives on a loop running to the last frame — not the forward window; wired into the suite as a disc-local oracle, not the parser | The forward window (no power on a near-whole-extent loop); a wrong-start control (a sustained tone self-correlates); dropping `Conscience Call`/`Got Scratch?` from emission; stating the borrowed evidence in docs only |
| [0045](0045-a-displaced-sample-is-recovered-by-its-own-name-and-word-count.md) | A sample displaced by blocks lost inside its partition is recovered by searching backward in the container's unit for a header restating this entry's name and word count, floored at the partition — 102 of 104, ADR-0027's name test the anchor at last | Leaving them refused; one displacement constant per volume; dropping or loosening the partition floor (the `Library.3` namesake); anchoring on name or word count alone; recovering programs; walking the map chain; searching forward |
+| [0046](0046-the-sd2-loop-is-decoded-from-sdll.md) | The SDII loop is decoded from `sdLL` — the Digidesign spec gives the layout and its units (sample frames), confirmed on 24/24 structurally and by emu3's forward shape oracle (21 of 24); one loop per record, root key still `None` | Emitting only the content-confirmed subset; deferring for want of a per-file render; reading a root key from `sdDD` or the sample name; one loop per channel |
diff --git a/docs/formats/hfs.md b/docs/formats/hfs.md
index c2102f5..b70643d 100644
--- a/docs/formats/hfs.md
+++ b/docs/formats/hfs.md
@@ -122,7 +122,28 @@ All 24 are uniformly 16-bit, 44 100 Hz, stereo. The audio is carried to WAV by r
**The resource fork container** is a standard Macintosh resource map: a 16-byte header (`dataOffset`, `mapOffset`, `dataLength`, `mapLength`, all big-endian), a data section where each resource is `[4-byte length][body]`, and a map whose type list (`typeListOffset` at `mapOffset + 24`) points to per-type reference lists (12-byte entries: id, name offset, a 3-byte data offset into the data section). The decoder enumerates the `STR ` type and reads ids 1000/1001/1002.
-**Loop points and a root key are not read.** The fork also carries Digidesign region/loop resources (`sdLL`, `sdDD`), but there is no open decoder or a render to verify one against, so the loop is left out rather than guessed ([ADR-0025](../adr/0025-the-loop-is-decoded-the-root-key-is-not.md)) — `sdLL` on the first file even looks like a loop (two in-range frame values), which is exactly why it is left for a specimen that can confirm it.
+**The loop is read from the `sdLL` resource; a root key still is not.** The fork carries a Digidesign `sdLL` loop-list resource (id 1000), whose layout is the 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). The resource is an 8-byte header followed by `NumLoops` loop records, all big-endian:
+
+| Field | Offset | Width | Meaning |
+|---|---|---|---|
+| `Version` | 0 | 2 | resource version (1) |
+| `HScale` | 2 | 2 | unused (0) |
+| `VScale` | 4 | 2 | unused (0) |
+| `NumLoops` | 6 | 2 | number of `LoopRecord`s to follow |
+
+Then `NumLoops` × a 14-byte `LoopRecord`:
+
+| Field | Offset | Width | Meaning |
+|---|---|---|---|
+| `LoopStart` | 0 | 4 | start **sample frame** of the loop |
+| `LoopEnd` | 4 | 4 | end **sample frame** of the loop (inclusive) |
+| `LoopIndex` | 8 | 2 | which loop this is (`1..NumLoops`) |
+| `LoopSense` | 10 | 2 | `117` forward, `118` alternating |
+| `Channel` | 12 | 2 | channel the loop was authored on (`0..channels-1`) |
+
+The positions are **sample frames**, per-channel — identical across an interleaved stereo file — so one record becomes one WAV loop, not one per channel. On `sonic-images-v2` every one of the 24 files carries exactly one `sdLL` of 22 bytes (`8 + 14×1`, no trailing bytes), `Version` 1, `NumLoops` 1, `LoopSense` 117 (forward), `LoopIndex` 1, `Channel` 0 or 1, and `0 <= LoopStart < LoopEnd <= frameCount`. `LoopEnd` is the loop's inclusive end frame; the decoder carries it as an exclusive end and the WAV writer makes it inclusive again for the RIFF `smpl` chunk. The ≤1-frame end ambiguity (inclusive vs exclusive) is below audio resolution — a splice at `LoopEnd-1`, `LoopEnd` and `LoopEnd+1` scores identically — and is recorded rather than hidden.
+
+This is the oracle [ADR-0025](../adr/0025-the-loop-is-decoded-the-root-key-is-not.md) asks for, confirmed three ways ([ADR-0046](../adr/0046-the-sd2-loop-is-decoded-from-sdll.md)): the Digidesign specification; the layout decoding all 24 resources with zero leftover bytes and every field on a documented, in-range value; and the [emu3.md](emu3.md) forward shape/join oracle corroborating 21 of the 24 loops (correlation of the waveform at the loop start against the recorded continuation past the loop end, *r* ≥ 0.9; 23 at *r* ≥ 0.6). The weak ones are inharmonic guitar/stack loops (`F#2 Gtr Str`, `E1 Gtr Str`, `Obiestack C2`) where a forward window has less power — a lack of power, not a refutation, and they are emitted and named rather than hidden. A **root key** is still not read: `sdLL` carries none, so the WAV keeps the neutral `MIDIUnityNote` 60, exactly as the E-mu path does. The `sdDD` document record (id 1000, 420 bytes on this disc) and the other `sd`/`dd` resources are display and session state, not audio loops, and are ignored.
## The oracle
diff --git a/src/samplerdisc/sample/sd2.py b/src/samplerdisc/sample/sd2.py
index 0a028f1..1f5970d 100644
--- a/src/samplerdisc/sample/sd2.py
+++ b/src/samplerdisc/sample/sd2.py
@@ -20,11 +20,20 @@
ADR-0024). SD2 stereo is already interleaved in the data fork, so unlike the
E-mu backends no channel de-planing is needed.
-Loop points and a root key are not read. The resource fork can carry Digidesign
-region/loop resources (``sdLL``, ``sdDD``), but there is no open decoder or a
-render to verify one against, so the loop is left out rather than guessed
-(ADR-0025). The numbers above are verified against ``sonic-images-v2``, whose 24
-``Sd2f`` files are uniformly 16-bit, 44 100 Hz, stereo.
+The **loop** is read from the resource fork's ``sdLL`` list resource, whose
+layout is the Digidesign Sound Designer II specification (© Digidesign
+1988-1990): an 8-byte header -- a version, two unused scale fields and a loop
+count -- followed by one 14-byte ``LoopRecord`` per loop, each a start and end
+**sample frame**, a loop index, a sense (117 forward, 118 alternating) and the
+channel it was authored on, all big-endian. The frame indices are per-channel
+and identical across an interleaved stereo file, so one record is one WAV loop,
+not one per channel (ADR-0025, ADR-0046). A root key is still not read: ``sdLL``
+carries none, so ``pitch`` stays ``None`` and the smpl chunk keeps the neutral
+root key, exactly as the E-mu path does. The ``sdDD`` document record and the
+other ``sd``/``dd`` resources are display and session state, not audio loops,
+and are ignored. The numbers above and the loop layout are verified against
+``sonic-images-v2``, whose 24 ``Sd2f`` files are uniformly 16-bit, 44 100 Hz,
+stereo and each carry one forward loop (docs/formats/hfs.md).
"""
from __future__ import annotations
@@ -34,6 +43,7 @@
from samplerdisc.sample import NotASample as _NotASample
from samplerdisc.sample.aiff import _swap
+from samplerdisc.wav import LOOP_ALTERNATING, LOOP_FORWARD
#: Resource type carrying the SD2 parameters, and the three ids within it. The
#: trailing space is part of the four-character type.
@@ -50,11 +60,40 @@
#: attributes (1) + a 3-byte data offset, reserved (4).
_REF_LEN = 12
+#: The ``sdLL`` loop-list resource (Digidesign SDII spec). Its header is a
+#: version, two unused scale fields and a loop count -- four 16-bit big-endian
+#: integers -- then one 14-byte ``LoopRecord`` per loop: a start and end sample
+#: frame (32-bit), then a loop index, a sense and a channel (16-bit each).
+SDLL_TYPE = b"sdLL"
+SDLL_ID = 1000
+_SDLL_HEADER = ">hhhh" # version, hscale, vscale, num_loops
+_SDLL_HEADER_LEN = 8
+_LOOP_REC = ">iihhh" # loop_start, loop_end, loop_index, loop_sense, channel
+_LOOP_REC_LEN = 14
+
+#: ``LoopSense`` values from the spec: a plain forward loop, or one that
+#: alternates direction. Mapped to the RIFF smpl loop types the WAV writer uses.
+LOOP_FORWARD_SENSE = 117
+LOOP_ALTERNATE_SENSE = 118
+_SENSE_TO_WAV = {LOOP_FORWARD_SENSE: LOOP_FORWARD, LOOP_ALTERNATE_SENSE: LOOP_ALTERNATING}
+
class NotASample(_NotASample):
"""The forks are not a Sound Designer II sample we can carry to WAV."""
+@dataclass(frozen=True)
+class Sd2Loop:
+ """One SDII loop, in sample frames. ``end`` is **exclusive** here, as it is
+ for the AKAI and E-mu carriers; ``extract._wav_loops`` reads ``start``,
+ ``end`` and ``loop_type`` straight off this and makes the end inclusive for
+ the RIFF smpl chunk (ADR-0046)."""
+
+ start: int
+ end: int
+ loop_type: int = LOOP_FORWARD
+
+
@dataclass(frozen=True)
class Sd2Sample:
name: str
@@ -67,7 +106,7 @@ class Sd2Sample:
#: written without an invented one (ADR-0025), as ``aiff`` does with no INST.
pitch: int | None = None
cents: float = 0.0
- loops: tuple = ()
+ loops: tuple[Sd2Loop, ...] = ()
@property
def duration(self) -> float:
@@ -118,6 +157,35 @@ def _resources(rsrc: bytes, want_type: bytes) -> dict[int, bytes]:
return found
+def _loops(rsrc: bytes, frames: int) -> tuple[Sd2Loop, ...]:
+ """The loops in the ``sdLL`` resource, in sample frames.
+
+ Reads the id-1000 ``sdLL`` body: an 8-byte header whose fourth field is the
+ loop count, then that many 14-byte ``LoopRecord``s. A loop is kept only when
+ it lies inside the audio (``0 <= start < end <= frames``); anything that
+ does not -- a truncated resource, a value past the payload -- is dropped, so
+ a damaged fork yields no loop rather than an invented one, the same stance
+ ``_resources`` takes (ADR-0025). ``LoopEnd`` is the loop's inclusive end
+ frame, so it is stored as an exclusive ``end`` (``LoopEnd + 1``) for the WAV
+ writer to turn back into an inclusive RIFF end.
+ """
+ body = _resources(rsrc, SDLL_TYPE).get(SDLL_ID)
+ if not body or len(body) < _SDLL_HEADER_LEN:
+ return ()
+ _version, _hscale, _vscale, num_loops = struct.unpack_from(_SDLL_HEADER, body, 0)
+ loops: list[Sd2Loop] = []
+ for i in range(num_loops):
+ off = _SDLL_HEADER_LEN + i * _LOOP_REC_LEN
+ if off + _LOOP_REC_LEN > len(body):
+ break
+ start, end, _index, sense, _channel = struct.unpack_from(_LOOP_REC, body, off)
+ if not (0 <= start < end <= frames):
+ continue
+ loop_type = _SENSE_TO_WAV.get(sense, LOOP_FORWARD)
+ loops.append(Sd2Loop(start=start, end=end + 1, loop_type=loop_type))
+ return tuple(loops)
+
+
def _pascal_number(body: bytes) -> str:
"""The ASCII text of a Pascal string: one length byte, then the digits."""
if not body:
@@ -159,4 +227,5 @@ def parse(data_fork: bytes, rsrc_fork: bytes, fallback_name: str = "") -> Sd2Sam
channels=channels,
width=width,
pcm=pcm,
+ loops=_loops(rsrc_fork, frames),
)
diff --git a/tests/test_discs.py b/tests/test_discs.py
index c20e5a6..e972c2e 100644
--- a/tests/test_discs.py
+++ b/tests/test_discs.py
@@ -14,6 +14,7 @@
import math
import os
import struct
+import tempfile
from array import array
from dataclasses import dataclass
from functools import lru_cache
@@ -28,7 +29,7 @@
from samplerdisc.extract import Extracted
from samplerdisc.fs.probe import find_origin
from samplerdisc.sample import aiff, emu_ebl
-from samplerdisc.wav import read_header
+from samplerdisc.wav import LOOP_FORWARD, read_header, write_wav
#: ``.mds`` and not ``.mdf``: the pair is reached through the descriptor, the
#: member that is actually opened, so listing both would open the disc twice.
@@ -2719,6 +2720,147 @@ def count_sd2(folder) -> int:
assert count_sd2(reference) == 24
+#: The forward shape/join oracle (emu3.md, ADR-0025) scored on the 24 SDII
+#: loops: a 256-frame window at the loop start correlated with the recorded
+#: continuation past the loop end -- for a periodic instrument tone the audio
+#: after the end is one period-multiple of the audio at the start, so a real
+#: loop scores high and a wrong one near zero. ``confirm`` is r >= 0.9.
+_SD2_SHAPE_WINDOW = 256
+_SD2_SHAPE_CONFIRM = 0.9
+_SD2_SHAPE_SCORABLE = 0.6
+
+#: The loops the forward window has less power on -- inharmonic guitar/stack
+#: loops whose start does not periodically predict the post-end audio. They are
+#: emitted like every other (the spec confirms the interpretation for all 24;
+#: this is a lack of power, not a refutation) and named rather than hidden
+#: (ADR-0046). Pinned so a currently-confirmed loop falling below the bar breaks
+#: the set. On this disc only ``F#2 Gtr Str`` is below the r >= 0.6 scorable bar.
+_SD2_WEAK_LOOPS = {"F#2 Gtr Str", "E1 Gtr Str", "Obiestack C2"}
+
+
+def _first_smpl_loop(payload: bytes) -> tuple[int, int, int] | None:
+ """The first smpl loop's ``(type, start, end)`` from a WAV, or ``None``.
+
+ The write path is what a DAW reads; this parses it back rather than trusting
+ ``write_wav``. The smpl body is nine leading u32s, then 6-u32 loop records
+ (id, type, start, end, fraction, playCount).
+ """
+ pos = 12
+ while pos + 8 <= len(payload):
+ tag = payload[pos : pos + 4]
+ size = struct.unpack_from(" None:
+ """The SDII loop is read from ``sdLL`` and reaches the WAV, and the disc's
+ own audio corroborates it (ADR-0046).
+
+ Three checks, gated on the disc like the rest of the SDII family. **Decode:**
+ all 24 ``Sd2f`` files carry exactly one in-range forward loop from the
+ ``sdLL`` resource, the layout the Digidesign spec gives. **Write path:** each
+ loop reaches the WAV ``smpl`` chunk with the frames the decoder read, its end
+ made inclusive as the RIFF spec wants -- parsed back out of the file a DAW
+ would open, not trusted. **Content:** the emu3.md forward shape/join oracle
+ -- the 256 frames at the loop start correlated with the recorded continuation
+ past the loop end -- confirms the loop on the great majority of the 24, the
+ same instrument that establishes the E-mu loops. The few it cannot vouch for
+ are inharmonic guitar/stack loops where the forward window has no power; they
+ are emitted and pinned by name (``_SD2_WEAK_LOOPS``), not hidden, exactly as
+ ADR-0044 emits ``eiv-analogia``'s unscorable loops. Nothing here changes what
+ ships -- ``sample.loops`` is what the extractor already emits.
+ """
+ np = pytest.importorskip("numpy")
+ from samplerdisc.extract import _wav_loops
+ from samplerdisc.sample import sd2
+
+ def pearson(u, v):
+ u = u - u.mean()
+ v = v - v.mean()
+ d = math.sqrt(float((u * u).sum()) * float((v * v).sum()))
+ return float((u * v).sum() / d) if d > 0 else 0.0
+
+ def shape(pcm: bytes, channels: int, ch: int, start: int, end: int) -> float | None:
+ """Forward shape r for a loop of (start, end) inclusive frames on ``ch``."""
+ frames = np.frombuffer(pcm, dtype=" 1 else frames
+ w = _SD2_SHAPE_WINDOW
+ if start < 0 or start + w > x.size or end + w > x.size:
+ return None
+ return pearson(x[start : start + w], x[end : end + w])
+
+ v2_size = _HFS["sonic-images-v2"][0]
+ path = _pinned_disc("sonic-images-v2", v2_size)
+
+ decoded = confirmed = scorable = 0
+ below_confirm: set[str] = set()
+ with open_image(path) as image:
+ origin = find_origin(image)
+ assert origin is not None and origin.backend.name == "hfs"
+ entries = [
+ entry
+ for volume in origin.backend.volumes(image, origin.offset)
+ for entry in volume.files
+ if entry.kind == "sd2"
+ ]
+ assert len(entries) == 24
+ with tempfile.TemporaryDirectory() as tmp:
+ for entry in entries:
+ data_fork = origin.backend.read_file(image, origin.offset, entry)
+ rsrc_fork = origin.backend.read_resource_fork(image, origin.offset, entry)
+ sample = sd2.parse(data_fork, rsrc_fork, fallback_name=entry.name)
+ assert len(sample.loops) == 1, entry.name
+ loop = sample.loops[0]
+ assert 0 <= loop.start < loop.end <= sample.frames + 1
+ assert loop.loop_type == LOOP_FORWARD
+ decoded += 1
+
+ # Write path: the loop reaches the smpl chunk, end made inclusive.
+ out = os.path.join(tmp, "sd2.wav")
+ write_wav(
+ out,
+ sample.pcm,
+ rate=sample.rate,
+ channels=sample.channels,
+ sample_width=sample.width,
+ loops=_wav_loops(sample),
+ )
+ payload = Path(out).read_bytes()
+ assert read_header(payload).has_smpl
+ written = _first_smpl_loop(payload)
+ assert written == (LOOP_FORWARD, loop.start, loop.end - 1), entry.name
+
+ # Content: the forward shape oracle on the loop's own channel.
+ body = sd2._resources(rsrc_fork, sd2.SDLL_TYPE)[sd2.SDLL_ID]
+ channel = struct.unpack_from(sd2._LOOP_REC, body, sd2._SDLL_HEADER_LEN)[4]
+ r = shape(sample.pcm, sample.channels, channel, loop.start, loop.end - 1)
+ if r is None:
+ continue
+ scorable += r >= _SD2_SHAPE_SCORABLE
+ if r >= _SD2_SHAPE_CONFIRM:
+ confirmed += 1
+ else:
+ below_confirm.add(os.path.basename(entry.name).strip())
+
+ assert decoded == 24
+ # Observed on sonic-images-v2: 21 confirm, 23 scorable; floors leave headroom.
+ assert confirmed >= 18, f"forward oracle confirmed only {confirmed} of 24 SDII loops"
+ assert scorable >= 20, f"only {scorable} of 24 SDII loops splice at r >= 0.6"
+ # A currently-confirmed loop dropping below the bar must show up here.
+ assert below_confirm <= _SD2_WEAK_LOOPS, (
+ f"an SDII loop stopped confirming under the forward oracle: {below_confirm}"
+ )
+
+
def test_hfs_v1_has_no_sd2_files() -> None:
"""``sonic-images-v1`` carries no Sd2f, so nothing new is claimed there."""
v1_size = _HFS["sonic-images-v1"][0]