Skip to main content
1 of 2
Lance Pollard
  • 682
  • 1
  • 7
  • 17

How to convert @tonicjs/tonic chord data to guitar chords?

I am looking at https://github.com/tonaljs/tonal/tree/main/packages/chord which has a lot of music theory I'm less familiar with. When I was playing the guitar for many years 20 years ago, I learned a bit about jazz music theory. In that, we learned how to play 3-string chords (3 notes each), along the fretboard. So if I remember correctly, on strings 3, 4, and 5, you could play the same chord in 3+ different ways, something like that.

So "C major" chord can be C E G on the piano, or like these 5 notes on the guitar.

In that guitar chord, it seems the 3 is a C, and the 1 is a C, so you have some duplication. The 3, 4, 5 strings are 2 0 1, E G C, so that is how my jazz teacher would have had us make the chord. Then move up the fretboard for another position, etc..

The question I have is, given I can do Chord.get("Cmaj").notes === ["C", "E", "G"] from that tonaljs library (you don't need to know code really for this question, it's mainly music theory), I get the basic set of notes for the chord.

The next task that I want to figure out is, how do I compute all possible chords, across all possible tunings, across all possible sets of strings?

Say we have a 6-stringed guitar (or 4-stringed bass), with tunings like these. Given a chord is a minimum of 3 notes, we can choose 3, 4, 5, or 6 strings to play the chord on. Given the hand can reach about let's say 6 frets, that gives us a range of what notes we can play.

How should I go about figuring out how to create a function something like this?

getPossibleStringedInstrumentChords(numStrings, notes, tuning, maxFretDistance)

That is, the tuning would have all the information of which fret has which notes, would that be how you'd do it? The notes is a list like ["C", "E", "G"]. The numStrings is 6 on the guitar. And maxFretDistance is 6 for the finger stretching.

It seems then I would just have to figure out how to create an algorithm which would find all combinations of notes, that is the hard part I will have to work on.

But will this approach work is my overall question? Does it make sense? I guess then I'd wonder what are the most important chords from the set, if that can be automatically figured out somehow... Or you just have to manually create the lists of chords for each tuning for each instrument. Not sure.

Is there something that does this already? Or any more information on the topic that would be helpful? Or does my algorithm sound like the ideal approach to finding all "chord layouts" for a given chord on stringed instruments? I keep seeing things like the "tonic" and the "bass" and "root" and "chroma" and "degree" and "interval" and the like in this library, all new concepts to me, and there's also some midi code dealing with chroma, so I'm not sure if there's a more appropriate conceptual way of getting guitar chords from the chord name or chord notes list.

Lance Pollard
  • 682
  • 1
  • 7
  • 17