Repository navigation
rational: Q15 and Q31 in the C ABI - #66
Merged
Merged
Conversation
The C ABI now carries the fixed-point profiles beside float, for FFI consumers on the M33 / M55-class deployments the profiles exist for: - tap_sr_rational_create_format(chain, profile, format, channels) and tap_sr_rational_create_stage_format(...), with TAP_SR_RATIONAL_FORMAT_ FLOAT / _Q15 / _Q31 (stable values 0 / 1 / 2). The existing create functions are the float case, unchanged. - tap_sr_rational_format(c), tap_sr_rational_process_q15 / _q31 and tap_sr_rational_flush_q15 / _q31. - A process or flush call in another format than the converter's returns 0 and consumes and writes nothing. The engine behind the ABI is templated on the sample type, and each format is the same basic_chain / basic_stage C++. The library exports exactly 23 symbols (16 plus seven), still with hidden visibility. The tests check every chain constant bit for bit against its named basic_chain in float, Q15 and Q31 (outputs, flush, accounting, latency, MACs). The stage constructor is checked in Q15 and Q31. Wrong-format calls must be refused and leave the converter untouched, and unknown formats return NULL. The ctypes binding takes fmt="q15" / "q31" (int16 / int32 arrays). The notebooks still measure float and are unaffected. The family's other C ABIs (async, bridge) remain float-only by their stated convention; this one departs from it deliberately, and its header says so. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015VR1VC4SDGxHZQQsQvPBaA
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.
What this changes
TAP_SR_RATIONAL_FORMAT_FLOAT/_Q15/_Q31, stable values 0 / 1 / 2.tap_sr_rational_create_format(chain, profile, format, channels)tap_sr_rational_create_stage_format(L, M, profile, divisor_num, divisor_den, format, channels)tap_sr_rational_format(c)tap_sr_rational_process_q15/_q31, taking interleavedint16_t(Q0.15) andint32_t(Q0.31)tap_sr_rational_flush_q15/_q31createandcreate_stageare the float case.basic_chain/basic_stageC++. The library exports exactly 23 symbols (16 before), still with hidden visibility.Chain(name, fmt="q15")andStage(..., fmt="q31")take int16 and int32 numpy arrays.Why
You picked this from the post-M6 list. The fixed-point profiles exist for M33 / M55-class deployments, and an FFI consumer there needs them without wrapping the C++ itself.
Verification
test_capi.cppnow checks every one of the 28 chain constants against its namedbasic_chain, bit for bit, in float, Q15 and Q31. It compares outputs, flush, accounting, latency and MACs.-Werrorand the C ABI on. gcc-Werrorpasses the rational label (113/113). clang-tidy and clang-format are clean.nm -Dlists exactly the 23tap_sr_rational_*functions.down_2within 1.5e-5 of the float converter on the same tone, and Q31 3/4 reporting its exact ratio and MACs.Notes for the reviewer
🤖 Generated with Claude Code
https://claude.ai/code/session_015VR1VC4SDGxHZQQsQvPBaA
Generated by Claude Code