Repository navigation
Add ctypes demo notebook and C ABI shared library - #6
Merged
Merged
Conversation
tools/capi/ is an ~80-line extern "C" shim over the float converter (create/destroy/push/pull/status/latency/reset), built as a shared library behind SRT_BUILD_CAPI for FFI consumers. notebooks/asrc_demo.ipynb loads it with ctypes and walks through the library visually, committed with executed outputs (7 figures): the naive-FIFO failure mode at +200 ppm (waveform discontinuity and spur spectrum), servo lock acquisition with state shading, the transparency comparison (126 dB measured vs 29 dB naive on this run), side-by-side sweep spectrograms, impulse latency vs designedLatencySeconds (1.50 ms both), a 0->300 ppm drift ramp tracked while streaming, and dropout recovery where the fade-in's max sample step equals the tone's own slope. Every demo cell carries an assertion, so re-executing the notebook doubles as an end-to-end FFI validation.
The setup cell hard-coded libsrt_capi.so; on macOS CMake produces libsrt_capi.dylib (and srt_capi.dll under Release/ on Windows), so the auto-build succeeded and the dlopen then failed on a path that never exists there. Search for all three names recursively, pass --config Release for multi-config generators, and print the build output on failure instead of swallowing it.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A visual demo/validation notebook driving the real compiled library through
ctypes, plus the C ABI it needs.tools/capi/— C ABI shim (SRT_BUILD_CAPI=ON)~80 lines of
extern "C"over the float converter:srt_create/destroy/push/pull/status/designed_latency_seconds/reset_from_consumer. Opaque handle, errors as null/zero, hot path stays noexcept. Usable from any FFI host (ctypes today; cffi/Julia/Rust trivially).notebooks/asrc_demo.ipynb— committed with executed outputs (7 figures)Walks the library's story end to end, every section plot-first and assertion-backed:
designedLatencySeconds()exactly.Because every demo cell asserts its measurement, re-executing the notebook is an end-to-end FFI + quality validation, not just a slideshow. Notes for reviewers: the first cell auto-builds the DSO if missing; the quality demo runs a 30 s virtual stream because the servo's Quiet stage (lowest noise floor) takes ~20 s to engage — earlier sampling reads the Track stage at ~92 dB, which is itself documented behavior.
Also: the clang-format CI check now covers
bench/andtools/capi/(previously only the original directories were globbed).https://claude.ai/code/session_01HuAFfoeD5a5Xe5aGNA16M9
Generated by Claude Code