RFC: working on making chord naming/chordList more consistent

Hi all,
I apologise for a complete and utter lack of movement here - 2022 has been the wrong kind of exciting for me and I've simply had to let stuff slide, this included. @mrreason 's done some work in this area recently, so I figure an update is warranted.

I spent a bit of time discussing and working out how to recursively parse the chord modifiers, I came up with this code:

this is behaving as I would expect, you can pass it any combination of any number of chord modifiers, it will crash if you pass it an unknown option :

modsFunc :: [Float] -> [String] -> [Float]
modsFunc xs [] = xs
modsFunc xs ["o"] = if (length xs > 2)
                      then [ (xs !! 0 - 12), (xs !! 2 - 12), (xs !! 1) ] ++ reverse (take (length xs - 3) (reverse xs))
                    else xs
modsFunc xs ['i' : is] =  take (length xs) $ drop ((length is) + 1) $ concatMap (\x -> map (+ x) xs) [0,12..]
modsFunc xs [m] = if (length xs > (read m :: Int)
                    then take (read m :: Int) xs
                  else xs
modsFunc xs ms = modsFunc (modsFunc xs (init ms)) [(last ms)

you can call it as per: modsFunc [0,2,4,6] ["ii", "o", "12"] where the chord is the first list, and the modifiers sit in the second list, in any order

If you're interested in checking out the discussion that got to this point, please see:

@yaxu had some recommendations for parsing differently which I was planning to explore but have been unable to do so after more than a year :frowning:

If anyone would like to pick this up, be my guest!

2 Likes