A Rust music theory toolkit for note processing, MIDI conversion, chord/scale generation, and frequency analysis. Ported from the Python soundkit framework.
- Note Conversion — Convert between note names, MIDI numbers, and frequencies
- Chord Generation — Generate chord voicings with inversion support (22 chord types)
- Scale Generation — Generate scales across multiple octaves (14 scale types)
- Validation — Validate note names, MIDI range, frequencies, and octaves
- Converters — Frequency-to-cents, ratio-to-cents, semitone-to-ratio conversions
- CLI Tool — Full command-line interface for all operations
- Library — Clean API for embedding in other Rust projects
# Install from source
cargo install --path .
# Note conversion
soundkit note-to-midi C#4 # → 61
soundkit note-to-freq A4 # → 440.00 Hz
soundkit midi-to-note 60 # → C4
soundkit midi-to-note 70 flat # → Bb4
soundkit freq-to-midi 440 # → 69
# Chord generation (root, type, octave, inversion)
soundkit chord C maj 4 0 # → C major: C4 E4 G4
soundkit chord C min 4 1 # → C minor, first inversion
# Scale generation (root, type, octave, num_octaves)
soundkit scale C major 4 2 # → C major, 2 octaves
soundkit scale A minor 4 1 # → A natural minor
# Utilities
soundkit validate C#4 # → valid
soundkit validate H4 # → invalid
soundkit batch C4 D4 E4 F4 G4 # → batch table
soundkit convert freq-to-cents 440 444
soundkit list chords # → 22 chord types
soundkit list scales # → 14 scale types
# Full demonstration
soundkit demoAdd to your Cargo.toml:
[dependencies]
soundkit = "0.1"Then use in your code:
use soundkit::{
midi_key, midi_freq, midi_to_note_name, freq_to_midi,
get_chord_notes, get_scale_notes,
};
// Convert note to MIDI
let midi = midi_key("A4")?; // → 69
// Convert note to frequency
let freq = midi_freq("A4", 2, 440.0)?; // → 440.00 Hz
// Get C major chord notes
let chord = get_chord_notes("C", "maj", 4, 0)?; // → [60, 64, 67]
// Get C major scale
let scale = get_scale_notes("C", "major", 4, 2)?; // → 2 octavesmaj, major, min, minor, dim, diminished, aug, augmented, 7, dominant7, maj7, major7, min7, minor7, dim7, diminished7, half_dim7, m7b5, maj9, 9, sus2, sus4
major, minor, natural_minor, harmonic_minor, melodic_minor, dorian, phrygian, lydian, mixolydian, locrian, pentatonic_major, pentatonic_minor, blues, whole_tone
MIT