Skip to content

audiograph: a TANH node - #332

Merged
bdbarnett merged 1 commit into
mainfrom
feat/graph-tanh
Oct 29, 2026
Merged

bdbarnett merged 1 commit into
mainfrom
feat/graph-tanh

Conversation

@bdbarnett

@bdbarnett bdbarnett commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Adds a TANH graph node: TANH_LEVEL * tanh(TANH_DRIVE * x), x in units of UNIT, using the graph's own tanh (the one the clipping two-poles use) so MicroPython, CircuitPython and CPython render the same bytes. It's on every target, including CircuitPython. Exposed in the MicroPython and CircuitPython bindings, the CPython extension and audiograph.py, and documented in the audiograph reference.

Tests (tests/test_cpython_audiograph_nodes.py, Tanh) hold it to double-precision tanh within 1 count over drive and level settings, moving knobs and block sizes 32 to 256, and include a check that five wrong references (swapped gains, a clip, a rational approximation, drive off by 2 percent, level off by 1) fail the bar. CPython and MicroPython render the same 25,600 samples.

@bdbarnett
bdbarnett merged commit 159301d into main Oct 29, 2026
31 checks passed
@bdbarnett
bdbarnett deleted the feat/graph-tanh branch October 29, 2026 06:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant