3 releases
Uses new Rust 2024
0.0.5 | Jun 20, 2025 |
---|---|
0.0.4 | Jun 6, 2025 |
0.0.3 | Jun 6, 2025 |
#179 in Math
455 downloads per month
Used in 7 crates
(via rstmt)
200KB
5K
SLoC
rstmt
_Warning: expect heavy changes to the API as the library is currently in the early stages of development and is not yet ready for production use.
rstmt
is a generalize music-theory toolkit written in Rust.
Features
- American Standard Pitch Notation (ASPN)
- The Neo-Riemannian Theory
Getting Started
Prerequisites
Ensure you have the latest version of Rust installed. You can install Rust using rustup.
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
After installation, I always recommend ensuring that rustup is updated to the latest version:
rustup update
Setting up for WebAssembly
If you plan to compile this library for WebAssembly, ensure you have the appropriate targets installed. You can check your current targets with:
rustup target list --installed
If necessary, add the wasm32-*
target(s) if you plan to compile for WebAssembly:
rustup target add wasm32-unknown-unknown wasm32-wasip1 wasm32-wasip2
Building from the source
Start by cloning the repository
git clone https://github.com/FL03/rstmt.git -b main --depth 1
Then, navigate to the project directory:
cd rstmt
Once you're in the project directory, you can build the project using cargo
:
cargo build -r --workspace --all-features
Or, if you want to run the tests, you can use:
cargo test -r --workspace --all-features
Usage
Add this to your Cargo.toml
:
[dependencies.rstmt]
features = [
"nrt",
]
version = "0.0.x"
Examples
Example #1: Basic Usage
extern crate rstmt;
use rstmt::Note;
use rstmt::nrt::Triad;
fn main() -> Result<(), Box<dyn core::error::Error + Send + Sync + 'static>> {
let root = Note::from_pitch(0);
// initialize a c-major triad
let triad = dbg!(Triad::major(root));
// test the root of the triad
assert_eq!(triad.root(), root);
// test the parallel transformation
assert_eq!(triad.parallel(), Triad::minor(root));
// assert the invertibility of the transformations
assert_eq!(triad.parallel().parallel(), triad);
Ok(())
}
Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.
Dependencies
~1.4–5.5MB
~112K SLoC