Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save MervinPraison/3c0c67b56ebfaf9d284b3e1000757857 to your computer and use it in GitHub Desktop.

Select an option

Save MervinPraison/3c0c67b56ebfaf9d284b3e1000757857 to your computer and use it in GitHub Desktop.
Find Guitar notes using an Iterator

Mapping Notes on a Guitar Fretboard

Writing a music notation app has many challenges. Finding notes and formatting chords for Piano is somewhat straightforward. Doing so for a Guitar fretboard presents many difficult challenges.

One such challenge is given a set of notes from a known music chord, write some code which will take those notes as input and iterate over the guitar fretboard to locate a reasonable set of guitar string/fret locations for each note. The string/fret locations may then be used to display a guitar 'Fret Diagram' of the given chord.

Since this is code we would like it to be flexible, ideally taking in some additional information beyond the music chord.

  • Given a music chord find all the string/fret locations for each note
  • Utilize 'Range' information to limit the Iterator to a fretboard section
  • Rely upon a listing that maps all 88 piano midi codes to their notes/octaves
    • (this will be needed to 'tune' the six strings on a guitar)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment