SonicWeave is a domain-specific language for working with musical frequencies, ratios, and equal temperaments.
It powers the Scale Workshop 3 language, ships with a command-line interface, exposes a TypeScript-friendly npm package, and includes template tags for embedding SonicWeave programs inside JavaScript and TypeScript.
Not to be confused with Sweave, the framework for mixing text and R code in literate programming workflows.
The sonic-weave package includes:
.swi files.8::16
tet(10)
sort(3^[-1..5] rdc 2)
"Japanese pentatonic koto scale, theoretical. Helmholtz/Ellis p.519, nr.110"
9/8 white "Major 2nd"
6/5 green "Minor 3rd"
3/2 white "Perfect 5th"
8/5 green "Minor 6th"
2 gray "Root & Octave"
Install dependencies (requires Node.js 20.0.0 or newer):
npm install
Run the test suite:
npm test
Start the CLI REPL:
npx sonic-weave
To exit the REPL, type .exit or press Ctrl+C twice.
SonicWeave looks a bit like JavaScript with Python-style semantics, borrows Haskell-like ranges, and shares some goals with xen-calc, with a little Zig sprinkled on top.