Rust regular temperament library
February 19, 2026 ยท View on GitHub
This is a re-implementation of some of my Python temperament finding code in Rust.
Native-code application
The standard target finds regular temperaments and shows the results in a machine-readable format that is JSON-consistent, and works with the latest Python library: https://bitbucket.org/x31eq/regular Supply the number of results for each rank, the cangwu parameter (cents/octave), and the prime limit.
7-limit:
cargo run 5 1 7
2.3.7-limit:
cargo run 5 1 2 3 7
11-limit as inharmonic timbre:
cargo run 5 1 cents <<FIN 1200.0 1901.9550008653875 2786.3137138648344 3368.825906469125 4151.317942364757 FIN
For other build targets, this project includes a makefile, because I like makefiles. To do a faster calculation for a big limit (currently incomplete results):
make release && target/release/regular-cli 5 0.1 257
The standard executable is called "regular-cli" to avoid a name clash with the library.
WebAssembly (Wasm) application
You can also run the code in a web browser without Python or other server-side support. You need a matching version of wasm-bindgen-cli:
cargo install wasm-bindgen-cli --version 0.2.108
It's important that the version matches the one the build uses or you get a perplexing error. Check
cargo info wasm-bindgen
or whatever the tools tell you to do.
Once you have it,
make wasm
and run a web server from the project root. As an example, the "server" script runs a server on port 1578, assuming you have Python3 and a POSIX shell. So you can go to
in your web browser and it should all be working. 1578 is a good 31-limit equal temperament.
If you have wasm-opt, you can also try
make wasm-release
This should make the code smaller, and maybe faster, and put it in the root folder. If you don't have wasm-opt, you can get it from
https://github.com/webassembly/binaryen
To get documentation including the Wasm code:
./doc