Skip to content

feat(math): lower DSP scalar functions statically - #146

Open
iplanwebsites wants to merge 1 commit into
vercel-labs:mainfrom
iplanwebsites:codex/static-dsp-math
Open

feat(math): lower DSP scalar functions statically#146
iplanwebsites wants to merge 1 commit into
vercel-labs:mainfrom
iplanwebsites:codex/static-dsp-math

Conversation

@iplanwebsites

@iplanwebsites iplanwebsites commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Why

ScriptC can compile a lot of JavaScript directly, but several common Math functions were still treated as calls that need a JavaScript runtime. That is a problem for small audio and signal-processing programs, where functions such as Math.sin and Math.sqrt are basic building blocks and the compiled program may not have a JavaScript engine available as a fallback.

We ran into this while prototyping a hybrid audio engine. The browser manages the audio graph, while a small compiled module handles sample processing. Even a simple oscillator needs sine, and common shaping and level calculations use square root, powers, exponentials, and logarithms.

This PR adds those small, general-purpose math building blocks to ScriptC. It does not add an audio engine or any Web Audio APIs.

What this adds

The C and LLVM backends can now compile these directly:

  • Math.sin
  • Math.cos
  • Math.sqrt
  • Math.exp
  • Math.log
  • Math.pow
  • Math.fround
  • Math.PI
  • Math.E

In other words, these operations become normal compiled math operations instead of unsupported dynamic calls.

The change also updates ScriptC surface coverage, diagnostics, manifests, and library profiles so the advertised support matches what the compiler can actually emit.

How it was tested

A differential corpus test runs the same DSP-style math program in Node and as compiled C and LLVM output, then checks that stdout, stderr, and exit status match.

I also ran:

  • the full workspace build
  • the focused C and LLVM differential test
  • the complete local plain test lane: 3,491 passed, 153 skipped
  • the complete local sanitized test lane: 3,491 passed, 153 skipped

Both full lanes used the repository-pinned Node 24.15.0. The Sandbox image was not configured locally, so I used the documented full local fallback from AGENTS.md.

I kept this PR intentionally focused: no audio application code, experimental reactor work, or project notes are included. Happy to adjust the supported set or implementation shape based on maintainer preference.

@vercel

vercel Bot commented Aug 13, 2026

Copy link
Copy Markdown

@iplanwebsites is attempting to deploy a commit to the Vercel Labs Team on Vercel.

A member of the Team first needs to authorize it.

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.

1 participant