Skip to content

The book: a long-form tutorial on the ASRC, complete#29

Merged
tap merged 16 commits into
mainfrom
claude/book-foundation
Jul 2, 2026
Merged

The book: a long-form tutorial on the ASRC, complete#29
tap merged 16 commits into
mainfrom
claude/book-foundation

Conversation

@tap

@tap tap commented Jul 1, 2026

Copy link
Copy Markdown
Owner

What this is

The complete book — an mdBook long-form tutorial that teaches C++, DSP, real-time
concurrency, and measurement discipline with this ASRC at the center. Every chapter
in book/src/SUMMARY.md is written: an introduction, 21 chapters across Parts 0–V,
and 3 appendices (~65,000 words), staged as one commit per authoring unit on this PR.

Contents

  • Part 0 — The problem: two crystals, one stream; the latency/quality/compute budgets (including the 8 ps phase-resolution derivation)
  • Part I — The machine, file by file: kaiser.hpp, the polyphase bank, sample_traits.hpp (with a fixed-point course), spsc_ring.hpp, pi_servo.hpp, the fractional resampler (Q0.64 centerpiece), and asrc.hpp composition (the feasibility-bug case study)
  • Part II — The proof system: tests as specifications, deterministic instruction counting, notebooks as calibrated instruments
  • Part III — Optimizing honestly: C1–C6 told as they happened, including the C5 revert and both C6 traps
  • Part IV — Portability: Hexagon (four lessons, incl. no-unwind exceptions), Cortex-M bare metal, the C ABI
  • Part V — Deployment: real-clock bridges and firmware; the channels/rates/blocks scaling rules
  • Appendices: the C++ decision log, glossary (~55 entries), annotated bibliography

Mechanisms

  • Live excerpts: chapters include code via {{#include ...:anchor}} against comment-only // ANCHOR: markers added to the headers, platform files, and test support — excerpts can never drift from the code. All anchor edits are comment-only; clang-format --dry-run --Werror clean; full host suite passes under -Werror (64/64).
  • Regenerable figures: six SVG figures produced by scripts/book_figures.py from the sources the text cites — the filter curves re-run kaiser.hpp's math formula-for-formula, and the servo and feasibility traces are measured by compiling scripts/book_figures_trace.cpp against the real headers (the feasibility "before" panel builds against the last pre-fix commit's tree via git archive, so both panels of the centerpiece bug figure are measurements, not models).
  • CI gate: a book job builds with pinned mdBook v0.4.40 (sha256-verified), fails on any warning (an orphaned anchor breaks the build), and verifies every image reference resolves.
  • Verify it yourself: every chapter ends with runnable commands reproducing its claims; all numbers trace to the repo record (PERFORMANCE.md, COMPARISON.md, tests, commit history).

One repo fix riding along

The proof-system chapter found that the docs truth sweep's claimed fix to the demo
notebook's summary cell was never actually applied — the "> 130 dB" overstatement was
still live. This PR applies it: the cell now reads the measured 126.4 dB (plus an
adjacent "dB dB" typo).

Build it

mdbook build book && open book/book/index.html

🤖 Generated with Claude Code

https://claude.ai/code/session_01HuAFfoeD5a5Xe5aGNA16M9

claude added 11 commits July 1, 2026 21:09
book/: mdBook project with the full 22-chapter outline (placeholders
build), the introduction, and the first complete chapter - the SPSC
ring concurrency deep-dive, written as the tone benchmark: algorithm
+ memory-model argument + rejected alternatives + the wraparound proof
+ what tests can and cannot certify, ending in verify-it-yourself
commands.

Code excerpts are included live from the headers via mdBook anchors
(ANCHOR comments added to spsc_ring.hpp; comment-only, format-clean).
New CI job builds the book with a pinned mdbook binary (v0.4.40,
sha256-verified) and treats warnings as errors, so a refactor that
orphans an excerpt fails CI - the same freshness contract as the
generated README tables.

https://claude.ai/code/session_01HuAFfoeD5a5Xe5aGNA16M9
Two Part I chapters: the Kaiser prototype design walk (Bessel series,
beta fit, harris length estimate, runtime-vs-constexpr decision) and the
polyphase bank (extra row L, tap-reversed rows, coefficient blending).
Adds comment-only kai_*/bank_* ANCHOR markers to kaiser.hpp and
polyphase_filter.hpp for the live excerpts.

https://claude.ai/code/session_01HuAFfoeD5a5Xe5aGNA16M9
Part I chapters for pi_servo.hpp (plant equation, PLL-matched gains,
three-stage machine, both tuning war stories) and the FractionalResampler
(Q0.64 phase, slip logic, dispatch, history management). Adds comment-only
sv_*/rs_* ANCHOR markers; rs_slip deliberately co-brackets the p0_phase_step
region since both chapters excerpt the same loop.

https://claude.ai/code/session_01HuAFfoeD5a5Xe5aGNA16M9
Part III told as it happened: C1-C2 profile-first and the restrict audit,
C3's Q0.64 phase with the M55 float regression accepted, C4's bounded win,
C5's implemented-then-reverted vrmpyh with disassembly evidence, and C6's
channel axis with both recorded traps. Adds comment-only opt_* ANCHOR
markers to polyphase_filter.hpp (opt_dot_rows co-brackets the rs_ region).

https://claude.ai/code/session_01HuAFfoeD5a5Xe5aGNA16M9
The traits/concept mechanism interleaved with a fixed-point course
(Q-format headroom, recomputed accumulation bounds, the blend-margin
audit correction) and the C-ABI shim chapter (opaque handles, C-linkage
overload workaround, null-guard audit history, no-unwind caveat). Adds
comment-only st_*/abi_* ANCHOR markers.

https://claude.ai/code/session_01HuAFfoeD5a5Xe5aGNA16M9
Part V chapters (real-clock bridges and firmware; the channels/rates/
blocks scaling rules with their measured evidence) plus the glossary
(~55 entries) and the annotated bibliography. No new anchors; snippets
are short hand-copies per the style contract.

https://claude.ai/code/session_01HuAFfoeD5a5Xe5aGNA16M9
Hexagon as the one-file cross+emulator port with its four lessons
(soft-double phase, restrict deltas, the C5 revert, no-unwind exceptions)
and the two Cortex-M bare-metal ports (startup anatomy, memory maps,
one-shot ctest protocol, Helium and SMLALD discoveries). Adds comment-only
pt_* ANCHOR markers to the startup file, both linker scripts, and the M55
toolchain file; the .ld C-style anchor comments resolve in mdBook.

https://claude.ai/code/session_01HuAFfoeD5a5Xe5aGNA16M9
Part II: tests-as-specifications (virtual-time simulator, sine-fit
metrology, bare-metal one-shot protocol), deterministic instruction
counting (plugin walk, two-sided ratchet, instructions-vs-cycles), and
notebooks as calibrated instruments with their five measurement traps.
Adds comment-only pf_* ANCHOR markers to two_clock_sim.hpp and
insn_count.c. Also fixes the demo notebook's summary cell to the measured
126.4 dB — the docs truth sweep claimed this fix but never applied it —
and an adjacent 'dB dB' typo.

https://claude.ai/code/session_01HuAFfoeD5a5Xe5aGNA16M9
@tap tap changed the title Book foundation: mdBook skeleton, live-excerpt CI gate, introduction + the SPSC ring chapter The book: a long-form tutorial on the ASRC, complete Jul 1, 2026
claude added 5 commits July 1, 2026 22:18
Six SVG figures wired into the chapters, all produced by
scripts/book_figures.py from the sources the text cites: the Kaiser
window and prototype responses re-run kaiser.hpp's math formula-for-
formula; the servo lock/dropout/re-lock trace and both feasibility
panels are measured by compiling scripts/book_figures_trace.cpp against
the real headers (the before panel against the pre-fix commit's tree via
git archive); the Q0.64 slip figure runs the actual mod-2^64 arithmetic;
the architecture diagram is drawn and labeled as such. The introduction
gains a third mechanical commitment describing this, and the book CI job
now verifies every image reference resolves (regeneration is not gated:
matplotlib SVG output is not byte-stable across versions).

https://claude.ai/code/session_01HuAFfoeD5a5Xe5aGNA16M9
The book is now 'SampleRateTap: The Story of an Asynchronous Sample Rate
Converter'. Each of the 24 pages opens with a quote matched to its theme
(Heraclitus for the two crystals, Maxwell's On Governors for the servo,
Kronecker for Q0.64, Dijkstra for the tests, the full Knuth quote for
C1-C2, Postel for the C ABI, ...). Uncertain attributions are marked
'attributed to'.

https://claude.ai/code/session_01HuAFfoeD5a5Xe5aGNA16M9
Notebooks gets 'lies, damned lies, and statistics' (its five traps are
that quote, measured); sample_traits gets the Heart Sutra (the primary
template is deliberately empty, the specializations are its form);
hardware trades the theory/practice aphorism for the Zen woodcutter.
Also resolves the double-Feynman.

https://claude.ai/code/session_01HuAFfoeD5a5Xe5aGNA16M9
New book-pages workflow: builds with the pinned mdBook and deploys
book/book to GitHub Pages (public site, deliberate) on pushes to main
that touch the book or any excerpt source, plus workflow_dispatch.
book.toml gains site-url for the /SampleRateTap/ path; README links the
published site.

https://claude.ai/code/session_01HuAFfoeD5a5Xe5aGNA16M9
@tap tap merged commit d7e03d3 into main Jul 2, 2026
28 checks passed
@tap tap deleted the claude/book-foundation branch July 2, 2026 01:02
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.

2 participants