pub enum Notation {
Chord(Chord),
Scale(Scale),
Mode(Mode),
}Expand description
A unified notation type that can represent a chord, scale, or mode.
This type attempts to parse input in the following order:
- Scale (most distinctive keywords like “major pentatonic”, “harmonic minor”)
- Mode (keywords like “dorian”, “lydian”)
- Chord (fallback, most flexible grammar)
§Examples
use klib::core::base::Parsable;
use klib::core::notation::Notation;
// Parses as a scale
let notation = Notation::parse("C major pentatonic").unwrap();
assert!(notation.is_scale());
// Parses as a mode
let notation = Notation::parse("D dorian").unwrap();
assert!(notation.is_mode());
// Parses as a chord
let notation = Notation::parse("Cmaj7").unwrap();
assert!(notation.is_chord());Variants§
Implementations§
Source§impl Notation
impl Notation
Sourcepub fn as_chord(&self) -> Option<&Chord>
pub fn as_chord(&self) -> Option<&Chord>
Returns a reference to the inner chord, if this is a chord.
Sourcepub fn as_scale(&self) -> Option<&Scale>
pub fn as_scale(&self) -> Option<&Scale>
Returns a reference to the inner scale, if this is a scale.
Sourcepub fn as_mode(&self) -> Option<&Mode>
pub fn as_mode(&self) -> Option<&Mode>
Returns a reference to the inner mode, if this is a mode.
Sourcepub fn into_chord(self) -> Option<Chord>
pub fn into_chord(self) -> Option<Chord>
Consumes the notation and returns the inner chord, if this is a chord.
Sourcepub fn into_scale(self) -> Option<Scale>
pub fn into_scale(self) -> Option<Scale>
Consumes the notation and returns the inner scale, if this is a scale.
Sourcepub fn into_mode(self) -> Option<Mode>
pub fn into_mode(self) -> Option<Mode>
Consumes the notation and returns the inner mode, if this is a mode.
Sourcepub fn notes(&self) -> Vec<Note>
pub fn notes(&self) -> Vec<Note>
Returns the notes of this notation.
For chords, this returns the chord voicing. For scales and modes, this returns the scale/mode degrees.
Sourcepub fn kind(&self) -> &'static str
pub fn kind(&self) -> &'static str
Returns a static string describing what kind of notation this is.
Sourcepub fn parse_with_type(symbol: &str, notation_type: Option<&str>) -> Res<Self>
pub fn parse_with_type(symbol: &str, notation_type: Option<&str>) -> Res<Self>
Parses a symbol into a Notation, optionally forcing a specific type.
If notation_type is Some, it must be one of "chord", "scale", or "mode".
If None, auto-detection is used (scale → mode → chord priority).
§Examples
use klib::core::notation::Notation;
// Auto-detect
let notation = Notation::parse_with_type("D dorian", None).unwrap();
assert!(notation.is_mode());
// Force chord interpretation
let notation = Notation::parse_with_type("C", Some("chord")).unwrap();
assert!(notation.is_chord());Sourcepub fn format_verbose(&self) -> String
pub fn format_verbose(&self) -> String
Returns a verbose string representation of this notation.
For chords, this includes recommended scales/modes.
For scales and modes, this is equivalent to Display.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Notation
impl<'de> Deserialize<'de> for Notation
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for Notation
Source§impl HasDescription for Notation
impl HasDescription for Notation
Source§fn description(&self) -> &'static str
fn description(&self) -> &'static str
Source§impl HasIntervals for Notation
impl HasIntervals for Notation
Source§impl HasPreciseName for Notation
impl HasPreciseName for Notation
Source§fn precise_name(&self) -> String
fn precise_name(&self) -> String
impl StructuralPartialEq for Notation
Auto Trait Implementations§
impl Freeze for Notation
impl RefUnwindSafe for Notation
impl Send for Notation
impl Sync for Notation
impl Unpin for Notation
impl UnsafeUnpin for Notation
impl UnwindSafe for Notation
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
impl<S, T> Duplex<S> for Twhere
T: FromSample<S> + ToSample<S>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.