@@ -22,7 +22,10 @@ import Data.Maybe
2222
2323import Sound.Tidal.Pattern
2424
25- -- major chords
25+ -- * Chord definitions
26+
27+ -- ** Major chords
28+
2629major :: Num a => [a ]
2730major = [0 ,4 ,7 ]
2831aug :: Num a => [a ]
@@ -45,7 +48,9 @@ major13 :: Num a => [a]
4548major13 = [0 ,4 ,7 ,11 ,14 ,21 ]
4649add13 :: Num a => [a ]
4750add13 = [0 ,4 ,7 ,21 ]
48- -- dominant chords
51+
52+ -- ** Dominant chords
53+
4954dom7 :: Num a => [a ]
5055dom7 = [0 ,4 ,7 ,10 ]
5156dom9 :: Num a => [a ]
@@ -66,7 +71,9 @@ eleven :: Num a => [a]
6671eleven = [0 ,4 ,7 ,10 ,14 ,17 ]
6772thirteen :: Num a => [a ]
6873thirteen = [0 ,4 ,7 ,10 ,14 ,17 ,21 ]
69- -- minor chords
74+
75+ -- ** Minor chords
76+
7077minor :: Num a => [a ]
7178minor = [0 ,3 ,7 ]
7279diminished :: Num a => [a ]
@@ -97,7 +104,9 @@ minor13 :: Num a => [a]
97104minor13 = [0 ,3 ,7 ,10 ,14 ,17 ,21 ]
98105minorMajor7 :: Num a => [a ]
99106minorMajor7 = [0 ,3 ,7 ,11 ]
100- -- other chords
107+
108+ -- ** Other chords
109+
101110one :: Num a => [a ]
102111one = [0 ]
103112five :: Num a => [a ]
@@ -112,7 +121,9 @@ sevenSus4 :: Num a => [a]
112121sevenSus4 = [0 ,5 ,7 ,10 ]
113122nineSus4 :: Num a => [a ]
114123nineSus4 = [0 ,5 ,7 ,10 ,14 ]
115- -- questionable chords
124+
125+ -- ** Questionable chords
126+
116127sevenFlat10 :: Num a => [a ]
117128sevenFlat10 = [0 ,4 ,7 ,10 ,15 ]
118129nineSharp5 :: Num a => [a ]
@@ -128,6 +139,8 @@ elevenSharp = [0,4,7,10,14,18]
128139minor11sharp :: Num a => [a ]
129140minor11sharp = [0 ,3 ,7 ,10 ,14 ,18 ]
130141
142+ -- * Chord functions
143+
131144-- | @chordate cs m n@ selects the @n@th "chord" (a chord is a list of Ints)
132145-- from a list of chords @cs@ and transposes it by @m@
133146-- chordate :: Num b => [[b]] -> b -> Int -> [b]
@@ -140,6 +153,22 @@ minor11sharp = [0,3,7,10,14,18]
140153-- enchord :: Num a => [[a]] -> Pattern a -> Pattern Int -> Pattern a
141154-- enchord chords pn pc = flatpat $ (chordate chords) <$> pn <*> pc
142155
156+ {-|
157+ The @chordTable@ function outputs a list of all available chords and their
158+ corresponding notes. For example, its first entry is @("major",[0,4,7])@ which
159+ means that a major triad is formed by the root (0), the major third (4 semitones
160+ above the root), and the perfect fifth (7 semitones above the root).
161+
162+ As the list is big, you can use the function 'chordL'.
163+
164+ If you know the notes from a chord, but can’t find the name of it, you can use this Haskell code to do a reverse look up into the table:
165+
166+ > filter (\(_,x)->x==[0,4,7,10]) chordTable
167+
168+ This will output @[("dom7",[0,4,7,10])]@
169+
170+ (You’ll need to run @import Sound.Tidal.Chords@ before using this function.)
171+ -}
143172chordTable :: Num a => [(String , [a ])]
144173chordTable = [(" major" , major),
145174 (" maj" , major),
@@ -273,9 +302,31 @@ chordTable = [("major", major),
273302 (" m11s" , minor11sharp)
274303 ]
275304
305+ -- | Look up a specific chord: @chordL "minor7"@ returns @(0>1)|[0,3,7,10]@.
276306chordL :: Num a => Pattern String -> Pattern [a ]
277307chordL p = (\ name -> fromMaybe [] $ lookup name chordTable) <$> p
278308
309+ {-|
310+ Outputs all the available chords:
311+
312+ @
313+ major maj M aug plus sharp5 six 6 sixNine six9 sixby9 6by9 major7 maj7
314+ major9 maj9 add9 major11 maj11 add11 major13 maj13 add13 dom7 dom9 dom11
315+ dom13 sevenFlat5 7f5 sevenSharp5 7s5 sevenFlat9 7f9 nine eleven 11 thirteen 13
316+ minor min m diminished dim minorSharp5 msharp5 mS5 minor6 min6 m6 minorSixNine
317+ minor69 min69 minSixNine m69 mSixNine m6by9 minor7flat5 minor7f5 min7flat5
318+ min7f5 m7flat5 m7f5 minor7 min7 m7 minor7sharp5 minor7s5 min7sharp5 min7s5
319+ m7sharp5 m7s5 minor7flat9 minor7f9 min7flat9 min7f9 m7flat9 m7f9 minor7sharp9
320+ minor7s9 min7sharp9 min7s9 m7sharp9 m7s9 diminished7 dim7 minor9 min9 m9
321+ minor11 min11 m11 minor13 min13 m13 minorMajor7 minMaj7 mmaj7 one 1 five 5
322+ sus2 sus4 sevenSus2 7sus2 sevenSus4 7sus4 nineSus4 ninesus4 9sus4 sevenFlat10
323+ 7f10 nineSharp5 9sharp5 9s5 minor9sharp5 minor9s5 min9sharp5 min9s5 m9sharp5
324+ m9s5 sevenSharp5flat9 7s5f9 minor7sharp5flat9 m7sharp5flat9 elevenSharp 11s
325+ minor11sharp m11sharp m11s
326+ @
327+
328+ (You’ll need to run @import Sound.Tidal.Chords@ before using this function.)
329+ -}
279330chordList :: String
280331chordList = unwords $ map fst (chordTable :: [(String , [Int ])])
281332
@@ -317,6 +368,7 @@ chordToPatSeq f noteP nameP modsP = uncollect $ do
317368 let ch = map (+ n) (fromMaybe [0 ] $ lookup name chordTable)
318369 applyModifierPatSeq f (return ch) modsP
319370
320- -- | turns a given pattern of some Num type, a pattern of chord names and a list of patterns of modifiers into a chord pattern
371+ -- | Turns a given pattern of some 'Num' type, a pattern of chord names, and a
372+ -- list of patterns of modifiers into a chord pattern
321373chord :: (Num a , Enum a ) => Pattern a -> Pattern String -> [Pattern [Modifier ]] -> Pattern a
322374chord = chordToPatSeq id
0 commit comments