Crates.io | chordparser |
lib.rs | chordparser |
version | 2.1.7 |
source | src |
created_at | 2024-08-02 23:08:28.788892 |
updated_at | 2024-11-27 16:51:34.677087 |
description | A parser library to generate Jazz/Pop/Rock chords from string inputs |
homepage | |
repository | https://github.com/PauSala/chordparser |
max_upload_size | |
id | 1323905 |
size | 167,045 |
See our playground here
ChordParser is a library for parsing musical chords from a human readable string representation.
It is inspired by chordSymbol: https://www.npmjs.com/package/chord-symbol.
Said that, it implements its own rules and conventions, which can change in the future since this it is a work in progress project.
For now, the scope of the library is to parse chords from Pop, Rock, and Jazz music in relatively standard English notation.
Classical notation, as well as Latin or German notation, is not supported yet.
Once parsed the Chord struct can be used to get information about the chord.
This includes:
The chord is also serializable into JSON, can generate MIDI codes for its notes, and allows transposition from one key to another.
Since there isn't a full consensus on how chords should be written, any chord parser is by definition opinionated.
We try to get a good balance between rejecting all invalid notations and accept any possible chord representation.
Check the test cases in the /test folder to have a grasp of what chords can and cannot be parsed.
The voicings module exposes a function to generate a set of MIDI notes from a Chord
representing a voicing for it.
The voicing is generated in a range from C1 to G4. The generator function accepts a lead note to generate the voicings around it, which allows chaining distinct chords smoothly.
B#9
chord will have C𝄪
as the ninth instead of D. Said that, triple flat/sharps are not suported since they add an unnecesasry complexity for very rare use cases.Checkout the example usage at the examples folder running:
cargo run --example parse-chord