4 stable releases

1.1.1 Aug 18, 2023
1.1.0 Aug 15, 2023
1.0.1 Aug 13, 2023

#540 in Audio

MIT license

73KB
1.5K SLoC

Chord Parser

Parser for musical chord signatures. Successful outputs return a parsed chord with a built-in abstract representation for chords.

Features

  • Full chord parsing with additional support for unicode symbols! (i.e. Δ, °)
  • Ambiguous notation to concrete notes conversion (maj13 -> maj7 + 9 + 13, sus -> sus4, etc.)
  • Input normalization (space trimming, etc.)
  • Fully documented and convenient to use!

Usage

use chord_parser::*;

let mut parser = ChordParser::new();
 
let result = parser.parse("Cmaj9");
 
match result {
    ChordParseResult::Success(chord) => println!("{:?}", chord.alteraations.seventh),
    ChordParseResult::Failure(kind) => panic!("Expected successful parse!"),
};
 
let result = parser.parse("E7(b9,b13)");
 
// Do something else...

Advanced

For more, visit the official documentation.


lib.rs:

This cargo provides a parser for musical chord signatures. Successful outputs return a parsed chord using a built-in representation.

Simple Example

use chord_parser::*;

let mut parser = ChordParser::new();

let result = parser.parse("Cmaj9");

match result {
    ChordParseResult::Success(chord) => println!("{:?}", chord.alterations.seventh),
    ChordParseResult::Failure(kind) => panic!("Expected successful parse!"),
};

let result = parser.parse("E7(b9,b13)");

// Do something else...

Advanced

For everything you can do with parsing, visit ChordParser.

To examine the abstract representation of chord elements, visit chord.

No runtime deps