This crate contains common functions and helpers for working with music / audio in Rust.
Most of these are inspired by similar functions found in different computer music languages / environments like SuperCollider, PureData, MaxMSP, etc.
The goal is to provide safe and efficient implementations of these functions for use in Rust projects.
It features the following modules and functions:
midi
: Functions for converting between MIDI note numbers and frequencies, transposing, etc.get_midi_note_name
: Get the name of a MIDI note number.get_midinote_from_name
: Get the MIDI note number of a note name.note_name_to_octave_position
: Get the octave position of a note name, eg "D" = 2.octave_position_to_note_name
: Get the note name of an octave position, eg 2 = "D".to_frequency
: Convert a MIDI note number to a frequency.transpose
: Safely transpose a MIDI note number, making sure it is within range.
scaling
: Functions for scaling values between different ranges, among other things it includes conversions between db and amplitudes, linlin and linexp, etc.linlin
: Linearly scale a value from one range to another.linexp
: Linearly scale a value from one range to another, but with an exponential curve.dbamp
: Convert a decibel value to an amplitude value.ampdb
: Convert an amplitude value to a decibel value.
binaryops
:clip
: Clip a value between a min and max value.fold
: Fold a value between a min and max value.wrap
: Wrap a value between a min and max value.
See the documentation for more information.
Only requires just
to bootstrap all tools and configuration.
By installing this, you will set up a pre-commit hook that will run all tests and checks before committing work, it will auto-format code and generally not allow you to commit code that isn't documented or safe, among other things.
cargo install just
just init # setup repo, install hooks and all required tools
To run:
just run
To test:
just test
Before committing work:
just pre-commit
To see all available commands:
just list
This project is licensed under either of:
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.