Skip to main content

Crate klib

Crate klib 

Source
Expand description

A library to easily explore music theory principles.

§Examples

use klib::core::chord::*;
use klib::core::known_chord::KnownChord;
use klib::core::modifier::Degree;
use klib::core::note::*;

// Check to see what _kind_ of chord this is.
assert_eq!(
    Chord::new(C).augmented().seven().known_chord(),
    KnownChord::AugmentedDominant(Degree::Seven)
);
use klib::core::base::Parsable;
use klib::core::chord::*;
use klib::core::note::*;

// Parse a chord from a string, and inspect the scale.
assert_eq!(
    Chord::parse("Cm7b5").unwrap().scale(),
    vec![C, DFlat, EFlat, F, GFlat, AFlat, BFlat]
);
use klib::core::chord::*;
use klib::core::note::*;

// From a note, create a chord, and look at the chord tones.
assert_eq!(
    C.into_chord().augmented().major7().chord(),
    vec![C, E, GSharp, B]
);

§Scales and Modes

use klib::core::base::HasName;
use klib::core::mode::*;
use klib::core::mode_kind::*;
use klib::core::note::*;
use klib::core::scale::*;
use klib::core::scale_kind::*;

// Create a D Dorian mode
let mode = Mode::new(D, ModeKind::Dorian);
assert_eq!(mode.name(), "D dorian");

// Create an A harmonic minor scale
let scale = Scale::new(A, ScaleKind::HarmonicMinor);
assert_eq!(scale.name(), "A harmonic minor");

§Notation (Unified Parsing)

use klib::core::base::Parsable;
use klib::core::notation::Notation;

// Automatically detects and parses scales, modes, or chords
let scale = Notation::parse("C major pentatonic").unwrap();
assert!(scale.is_scale());

let mode = Notation::parse("D dorian").unwrap();
assert!(mode.is_mode());

let chord = Notation::parse("Cmaj7").unwrap();
assert!(chord.is_chord());

Re-exports§

pub use rodio;

Modules§

analyze
Analysis types and functions for the kord crate.
core
Core types and functions for the kord crate.
helpers
Helper functions for the project.
ml
The ml module contains the core ml logic for gathering, training, and inference.