Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions .github/workflows/compare.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,13 @@ on:
jobs:
compare-icount:
name: Comparison instruction counts (${{ matrix.engine }})
runs-on: ubuntu-latest
# Pinned image, as ci.yml's ratchet is: the counts are a function of the
# apt toolchain, the plugin build and QEMU. The plugin is built against
# QEMU 8.2.2's header (plugin API 1), which ubuntu-24.04's qemu-system-arm
# loads; ubuntu-latest moved to 26.04, whose QEMU 10.2 needs API 2 or
# later and refused the plugin (run 45528691636). The recorded counts
# (bench/compare_counts.json) were measured on 24.04 as well.
runs-on: ubuntu-24.04
timeout-minutes: 120
strategy:
fail-fast: false
Expand Down Expand Up @@ -100,9 +106,12 @@ jobs:
# remainder construction (async/bench/icount/cmp_main.cpp,
# bridge/bench/icount/cmp_main.cpp).
for bin in $(scripts/compare_binaries.sh ${{ matrix.engine }}); do
# || true: a QEMU that exits non-zero (a refused plugin, a
# crashed guest) reaches the check below, which prints why,
# instead of ending the step silently under bash -e.
out=$(qemu-system-arm -M $machine -nographic -semihosting \
-d plugin -plugin /tmp/libinsncount.so \
-kernel build-$tgt/$bin 2>&1)
-kernel build-$tgt/$bin 2>&1) || true
echo "$out" | grep -q 'ICOUNT_DONE ok=1' || {
echo "$out"; echo "::error::$tgt $bin did not complete"; exit 1; }
n=$(echo "$out" | grep -o 'TAP_SR_INSN_COUNT [0-9]*' | cut -d' ' -f2)
Expand Down Expand Up @@ -159,7 +168,7 @@ jobs:
cmake --build build-hex -j 4
for bin in $(scripts/compare_binaries.sh ${{ matrix.engine }}); do
out=$(qemu-hexagon -d plugin -plugin /tmp/libinsncount.so \
build-hex/$bin 2>&1)
build-hex/$bin 2>&1) || true
echo "$out" | grep -q 'ICOUNT_DONE ok=1' || {
echo "$out"; echo "::error::hexagon $bin did not complete"; exit 1; }
n=$(echo "$out" | grep -o 'TAP_SR_INSN_COUNT [0-9]*' | cut -d' ' -f2)
Expand Down
68 changes: 34 additions & 34 deletions async/bench/compare_counts.json
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
{
"provenance": {
"sha": "667934a2d10d73b5017e5eb85c1c2325073115d8",
"dsptap": "d7ebe4bc5dc9db5d9aef306795c709f034de6cf7",
"run_id": "38013347369",
"run_url": "https://github.com/tap/SampleRateTap/actions/runs/38013347369",
"date": "2026-10-10",
"toolchains": "arm-none-eabi-gcc 15:13.2.rel1-2, qemu-system-arm 1:8.2.2+ds-0ubuntu1.18 (ubuntu24 20261004.327.1), hexagon-clang 19.1.5 and qemu-hexagon 8.2.2 at the pinned digests"
"sha": "f1816cc957e7c2763144a6975c02d5909c76a278",
"dsptap": "4b30a02a15c25568b9931ab6385012fa147dc835",
"run_id": "45540985569",
"run_url": "https://github.com/tap/SampleRateTap/actions/runs/45540985569",
"date": "2026-11-25",
"toolchains": "arm-none-eabi-gcc 15:13.2.rel1-2, qemu-system-arm 1:8.2.2+ds-0ubuntu1.18 (ubuntu24 20261116.133.1), hexagon-clang 19.1.5 and qemu-hexagon 8.2.2 at the pinned digests"
},
"counts": {
"hexagon": {
"cmp_icount_lsr_best": 2588013392,
"cmp_icount_lsr_best_4s": 5171981607,
"cmp_icount_lsr_medium": 873790422,
"cmp_icount_lsr_medium_4s": 1740191532,
"cmp_icount_r8b_120": 593058685,
"cmp_icount_r8b_120_4s": 1174818893,
"cmp_icount_r8b_120_tb8": 532925916,
"cmp_icount_r8b_120_tb8_4s": 1053228490,
"cmp_icount_speex_fixed_q10": 206348956,
"cmp_icount_speex_fixed_q10_4s": 386139052,
"cmp_icount_speex_fixed_q4": 67031791,
"cmp_icount_speex_fixed_q4_4s": 124308454,
"cmp_icount_speex_float_q10": 2979838469,
"cmp_icount_speex_float_q10_4s": 5933851540,
"cmp_icount_speex_float_q4": 72267855,
"cmp_icount_speex_float_q4_4s": 135577688,
"cmp_icount_srt_float": 397694085,
"cmp_icount_srt_float_4s": 662088538,
"cmp_icount_srt_q15": 179697127,
"cmp_icount_srt_q15_4s": 223575034
"cmp_icount_lsr_best": 2588013417,
"cmp_icount_lsr_best_4s": 5171981632,
"cmp_icount_lsr_medium": 873790447,
"cmp_icount_lsr_medium_4s": 1740191557,
"cmp_icount_r8b_120": 593058710,
"cmp_icount_r8b_120_4s": 1174818918,
"cmp_icount_r8b_120_tb8": 532925941,
"cmp_icount_r8b_120_tb8_4s": 1053228515,
"cmp_icount_speex_fixed_q10": 206348981,
"cmp_icount_speex_fixed_q10_4s": 386139077,
"cmp_icount_speex_fixed_q4": 67031816,
"cmp_icount_speex_fixed_q4_4s": 124308479,
"cmp_icount_speex_float_q10": 2979838494,
"cmp_icount_speex_float_q10_4s": 5933851565,
"cmp_icount_speex_float_q4": 72267880,
"cmp_icount_speex_float_q4_4s": 135577713,
"cmp_icount_srt_float": 396922412,
"cmp_icount_srt_float_4s": 660547594,
"cmp_icount_srt_q15": 178629893,
"cmp_icount_srt_q15_4s": 221443052
},
"m33": {
"cmp_icount_lsr_best": 14344956886,
Expand All @@ -47,10 +47,10 @@
"cmp_icount_speex_float_q10_4s": 34662634874,
"cmp_icount_speex_float_q4": 240159001,
"cmp_icount_speex_float_q4_4s": 452503354,
"cmp_icount_srt_float": 2339059866,
"cmp_icount_srt_float_4s": 3808080433,
"cmp_icount_srt_q15": 967845318,
"cmp_icount_srt_q15_4s": 1052206578
"cmp_icount_srt_float": 2337375075,
"cmp_icount_srt_float_4s": 3804711631,
"cmp_icount_srt_q15": 965010010,
"cmp_icount_srt_q15_4s": 1046536866
},
"m55": {
"cmp_icount_lsr_best": 614379291,
Expand All @@ -69,10 +69,10 @@
"cmp_icount_speex_float_q10_4s": 1906047107,
"cmp_icount_speex_float_q4": 152220021,
"cmp_icount_speex_float_q4_4s": 302783168,
"cmp_icount_srt_float": 96150559,
"cmp_icount_srt_float_4s": 174960038,
"cmp_icount_srt_q15": 101050856,
"cmp_icount_srt_q15_4s": 183677221
"cmp_icount_srt_float": 94455147,
"cmp_icount_srt_float_4s": 171570287,
"cmp_icount_srt_q15": 97931890,
"cmp_icount_srt_q15_4s": 177440339
}
}
}
44 changes: 22 additions & 22 deletions async/docs/COMPARISON.md
Original file line number Diff line number Diff line change
Expand Up @@ -215,9 +215,9 @@ old metric reproduce the previous table exactly (2,218 / 6,400 on M55, 49,424

<!-- COMPARE:BEGIN -->
Measured in `compare.yml` run
[38013347369](https://github.com/tap/SampleRateTap/actions/runs/38013347369)
on `667934a` (DspTap `d7ebe4b`), 2026-10-10; arm-none-eabi-gcc 15:13.2.rel1-2,
qemu-system-arm 1:8.2.2+ds-0ubuntu1.18 (ubuntu24 20261004.327.1),
[45540985569](https://github.com/tap/SampleRateTap/actions/runs/45540985569)
on `f1816cc` (DspTap `4b30a02`), 2026-11-25; arm-none-eabi-gcc 15:13.2.rel1-2,
qemu-system-arm 1:8.2.2+ds-0ubuntu1.18 (ubuntu24 20261116.133.1),
hexagon-clang 19.1.5 and qemu-hexagon 8.2.2 at the pinned digests.

Steady state, instructions per stereo output frame (× = vs. SampleRateTap
Expand All @@ -226,16 +226,16 @@ SampleRateTap row per target in bold):

| Engine | Cortex-M55 | Cortex-M33 (Pico 2 class) | Hexagon |
|---|---:|---:|---:|
| **SampleRateTap** balanced, float | **821** | 15,302 | 2,754 |
| **SampleRateTap** balanced, Q15 | 861 | **879** | **457** |
| **SampleRateTap** balanced, float | **803** | 15,285 | 2,746 |
| **SampleRateTap** balanced, Q15 | 828 | **849** | **446** |
| r8brain 120 dB, default 2 % band³ | 1,002 (1.2×) | 30,004 (2.0×) | 6,060 (2.2×) |
| r8brain 120 dB, 8 % band (flat to 20 kHz)³ | 934 (1.1×) | 26,619 (1.7×) | 5,420 (2.0×) |
| r8brain 120 dB, 8 % band (flat to 20 kHz)³ | 934 (1.2×) | 26,619 (1.7×) | 5,420 (2.0×) |
| libsamplerate `MEDIUM` | 2,203 (2.7×) | 49,206 (3.2×) | 9,025 (3.3×) |
| libsamplerate `BEST` | 6,392 (7.8×) | 149,420 (9.8×) | 26,916 (9.8×) |
| SpeexDSP float, quality 10 (~100 dB) | 9,903 (12.1×) | 180,098 (11.8×) | 30,771 (11.2×) |
| SpeexDSP float, quality 4 (its passband knee) | 1,568 (1.9×) | 2,212 (0.1×) | 659 (0.2×) |
| SpeexDSP fixed-point, quality 10 (× vs. Q15) | 5,902 (6.9×) | 6,430 (7.3×) | 1,873 (4.1×) |
| SpeexDSP fixed-point, quality 4 (× vs. Q15) | 1,673 (1.9×) | 1,797 (2.0×) | 597 (1.3×) |
| libsamplerate `BEST` | 6,392 (8.0×) | 149,420 (9.8×) | 26,916 (9.8×) |
| SpeexDSP float, quality 10 (~100 dB) | 9,903 (12.3×) | 180,098 (11.8×) | 30,771 (11.2×) |
| SpeexDSP float, quality 4 (its passband knee) | 1,568 (2.0×) | 2,212 (0.1×) | 659 (0.2×) |
| SpeexDSP fixed-point, quality 10 (× vs. Q15) | 5,902 (7.1×) | 6,430 (7.6×) | 1,873 (4.2×) |
| SpeexDSP fixed-point, quality 4 (× vs. Q15) | 1,673 (2.0×) | 1,797 (2.1×) | 597 (1.3×) |

One-time construction, millions of instructions:

Expand All @@ -252,10 +252,10 @@ One-time construction, millions of instructions:
| SpeexDSP fixed-point, quality 10 | 5.2 | 98.8 | 26.6 |
| SpeexDSP fixed-point, quality 4 | 2.0 | 33.6 | 9.8 |

Key figures: on the M33 the Q15 datapath costs **879 instructions/frame** in
steady state, libsamplerate `MEDIUM` **~56×** that and r8brain at 8 %
**~30×**, SpeexDSP's fixed-point build at quality 4 **2.0×**; on the M55 the
float datapath (821) is cheaper than Q15 (861) by 5%.
Key figures: on the M33 the Q15 datapath costs **849 instructions/frame** in
steady state, libsamplerate `MEDIUM` **~58×** that and r8brain at 8 %
**~31×**, SpeexDSP's fixed-point build at quality 4 **2.1×**; on the M55 the
float datapath (803) is cheaper than Q15 (828) by 3%.
<!-- COMPARE:END -->

² The float datapath is soft-double-bound on the FP64-less M33 and
Expand All @@ -272,16 +272,16 @@ much); before it, Q15 cost 42 % more than float there.
**SpeexDSP's rows read per target.** On the M55, the one target where
SampleRateTap's float datapath is its cheaper row, SpeexDSP's cheapest
setting (quality 4, the row that matches `balanced`'s latency class at
−0.42 dB by 20 kHz) costs ~1.9× `balanced` in either build, and its quality
−0.42 dB by 20 kHz) costs ~2.0× `balanced` in either build, and its quality
10 ~7× (fixed-point) to ~12× (float). On the M33 and Hexagon the Q15 row is
the one that runs (footnote ²: the float datapath accumulates in double,
soft-float on both FP64-less cores), and Speex's float build is
single-precision throughout, so its float rows undercut that float row by
an order of magnitude; against the Q15 datapath its quality 4 costs 1.3×
(Hexagon) to 2.0× (M33) fixed-point and 1.4× to 2.5× float, its quality 10
4× to 7× fixed-point and 70× to 200× float. The one row a Q15 caller
would weigh is its fixed-point build at quality 4: within 2× of the Q15
datapath on every target, at a third more latency (32 frames against 24)
(Hexagon) to 2.1× (M33) fixed-point and 1.5× to 2.6× float, its quality 10
4× to 8× fixed-point and 70× to 210× float. The one row a Q15 caller
would weigh is its fixed-point build at quality 4: 1.3–2.1× the Q15
datapath across the targets, at a third more latency (32 frames against 24)
and a −0.42 dB shelf at 20 kHz. Its construction is cheap, as the other
libraries' is (under 100 M instructions on the M33, under 27 M elsewhere).

Expand All @@ -307,12 +307,12 @@ cost for devices that construct at boot.

| | Type | Clock recovery | Ratio range | Quality | Latency | Footprint / targets | License & form |
|---|---|---|---|---|---|---|---|
| **SampleRateTap** | software ASRC | built-in (PI servo on FIFO occupancy) | near-unity (±~1000 ppm) | −134 dB THD+N / 149 dB DR measured above; Q15/Q31 paths for FPU-less DSPs | **1.5 ms default** (0.5 ms filter); sub-ms with `fast()` | 308× RT/core x86; Q15 datapath 457 insn/frame stereo steady-state on Hexagon, 879 on M33 (above), CI-gated | MIT, header-only C++20 |
| **SampleRateTap** | software ASRC | built-in (PI servo on FIFO occupancy) | near-unity (±~1000 ppm) | −134 dB THD+N / 149 dB DR measured above; Q15/Q31 paths for FPU-less DSPs | **1.5 ms default** (0.5 ms filter); sub-ms with `fast()` | 308× RT/core x86; Q15 datapath 446 insn/frame stereo steady-state on Hexagon, 849 on M33 (above), CI-gated | MIT, header-only C++20 |
| [AD1896][ad1896] (ADI) | hardware ASRC | built-in | 1:8 up / 7.75:1 down | THD+N −117 dB min / −133 dB best; 142 dB DNR (datasheet) | sub-ms–ms, mode dependent | dedicated chip, one stereo pair | proprietary |
| [SRC4392][src4392] (TI) | hardware ASRC | built-in (automatic) | 1:16–16:1 | THD+N −140 dB typ; 144 dB DR (datasheet) | selectable filter delay | dedicated chip + DIR/DIT | proprietary |
| [libsamplerate][lsr] | resampler library | **no** — caller supplies ratio | 1/256–256 | measured above (near-unity); 97 dB worst-case across ratios (own docs) | filter-dependent, offline-friendly | portable C, float | BSD-2 |
| [soxr][soxr] | resampler library | no (fixed ratio + bounded VR mode) | wide | measured above (near-unity) | quality-dependent | portable C, SIMD | LGPL |
| [r8brain-free-src][r8b] | resampler library | no — caller supplies ratio | arbitrary | measured above (near-unity, 24-bit preset at the format ceilings); stopband user-set 49–218 dB | transition-band dependent: 16 ms default at 120 dB here, 4.2 ms flat to 20 kHz, ~1 ms only with a 13 kHz-class roll-off | double precision, no fixed-point path; SSE2/AVX/NEON; ~1.1–2.2× SampleRateTap's float steady state on the embedded targets above | MIT, header-only C++ |
| [r8brain-free-src][r8b] | resampler library | no — caller supplies ratio | arbitrary | measured above (near-unity, 24-bit preset at the format ceilings); stopband user-set 49–218 dB | transition-band dependent: 16 ms default at 120 dB here, 4.2 ms flat to 20 kHz, ~1 ms only with a 13 kHz-class roll-off | double precision, no fixed-point path; SSE2/AVX/NEON; ~1.2–2.2× SampleRateTap's float steady state on the embedded targets above | MIT, header-only C++ |
| [SpeexDSP resampler][speex] | resampler library | no — caller supplies ratio (`set_rate_frac`) | arbitrary | measured above: float build at `balanced`'s level, fixed-point build at the 16-bit floor beside the Q15 row; "~100 dB" at best by its own table, and never flat to 20 kHz (−0.42 dB from quality 4 up) | quality-set: 32 frames (0.67 ms) at quality 4, 128 (2.7 ms) at 10 | portable C; **the one competitor with a fixed-point build** (Q15 I/O); its cost against the Q15 datapath on the embedded targets is in the tables above | BSD-3, C |
| zita-resampler + zita-ajbridge | resampler + DLL servo | ajbridge adds a delay-locked loop | near-unity (bridge) | designed for 24-bit transparency; no published CI-verified figures | several ms (period-driven) | Linux/JACK, float | GPL |
| OS engines (CoreAudio, WASAPI shared, PipeWire) | system ASRC | built-in, opaque | device-dependent | unpublished; generally well below the above | typically 5–20 ms | bundled | n/a |
Expand Down
4 changes: 2 additions & 2 deletions book/src/part0/two-crystals.md
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,8 @@ and the comparison document names its mechanism exactly: a 48-tap window
with a creeping phase, instead of general-ratio machinery. On targets
without floating-point hardware the dividend compounds — the Q15
fixed-point datapath has no libsamplerate analog at all, and on a
Pico-class Cortex-M33 the cheapest libsamplerate option costs about 56×
the Q15 datapath's steady-state cost of 879 instructions per frame. (An
Pico-class Cortex-M33 the cheapest libsamplerate option costs about 58×
the Q15 datapath's steady-state cost of 849 instructions per frame. (An
earlier revision said 9.8×, from a per-frame figure that folded the
converter's one-time construction into a 2 s workload; the comparison
document now reports steady state and construction separately.)
Expand Down
Loading
Loading