Skip to content

sakeof-capy/chord_mapper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Chord Mapper

Brief Description

Chord Mapper is a Rust project that provides a command-line utility for parsing chord notations and mapping them to the individual musical notes they consist of.

  • parsing process: the parsing itself is delegated to the 'pest' crate. So the details about parsing process can be found here: https://docs.rs/pest/2.7.5/pest/

  • what exactly is being parsed: actually only strings representing chords in international chord notations, like "C#", "C#m" are being parsed.

  • how the results of the parsing will be used: the parsed string is converted to a program's chord representation which is then converted to the set of notes that make the chord up. Example: "Am" -> "A-C-E" (because A, C and E notes make up chord Am).

Grammar Rules

Chord Mapper uses a custom grammar to parse chord notations. The grammar rules are defined as follows:

root = { SOI ~ delimitor* ~ chord ~ delimitor* ~ EOI }
delimitor = { " "+ }

chord = { minor_chord | major_chord }
major_chord = { tonic }
minor_chord = { tonic ~ "m" }

tonic = { sharped_note | flatted_note | bare_note }
bare_note = { "A" | "B" | "C" | "D" | "E" | "F" | "G" | "H" }
sharped_note = { ("A" | "C" | "D" | "F" | "G") ~ "#" }
flatted_note = { ("D" | "E" | "G" | "A" | "B") ~ "b" }
  • root: Represents the root rule for parsing a chord notation.
  • delimitor: Matches any number of spaces used as delimiters.
  • chord: Defines the structure of a chord, which can be either a major_chord or a minor_chord.
  • major_chord: Represents a major chord consisting of a tonic.
  • minor_chord: Represents a minor chord consisting of a tonic followed by 'm'.
  • tonic: Specifies the core note of a chord, which can be a sharped_note, flatted_note, or bare_note.
  • bare_note: Matches bare note names, such as 'A', 'B', 'C', 'D', 'E', 'F', 'G', or 'H'.
  • sharped_note: Matches sharped note names, like 'A#', 'C#', 'D#', 'F#', or 'G#'.
  • flatted_note: Matches flatted note names, including 'Db', 'Eb', 'Gb', 'Ab', or 'Bb'.

Usage

The Chord Mapper project includes a command-line interface (CLI) that allows you to interact with the tool. Here are some available commands:

  • parse: Use this command to parse a chord notation and display its constituent notes.

    Example:

    chord_mapper parse Cm
  • help: Show information about how to use the Chord Mapper CLI.

    Example:

    chord_mapper help
  • credits: Show information about the project and its contributors.

    Example:

    chord_mapper credits

Chord Mapper is an essential tool for musicians and music enthusiasts, helping you understand chord notations and their underlying musical components.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages