pitchy
Minimalistic Rust library for working with musical notes, frequencies (Hz), MIDI numbers, and pitch operations like transposition and octave shifts.
✨ Features
- Parse note names like
"A4","C#3","Db5" - Convert to MIDI note number and frequency in Hz
- Transpose notes by semitones or octaves
- Lightweight and
no_stdcompatible (via feature flag)
🚀 Usage
Add to your Cargo.toml:
[]
= "0.1"
Or, to use in no_std mode:
[]
= "0.1"
= false
🔧 Example Usage
Parse and Analyze a Note
use Note;
use FromStr;
let note = from_str.unwrap;
assert_eq!;
assert_eq!;
Transpose a Note
let note = from_str.unwrap;
let up = note.transpose;
assert_eq!; // E4
Convert from MIDI Number
let note = try_from_midi_number.unwrap;
assert_eq!; // ≈ C4
Get Note Parts (no_std friendly)
let note = from_str.unwrap;
let = note.note_parts.unwrap;
assert_eq!; // F#
assert_eq!;
⚙️ Optional Features
std(enabled by default): enables note name formatting andDisplayimplslibm: enables thelibmmath backend used inno_stdmode
To build without std, use:
📄 License
MIT © paramako