import Text.XHtml
import Music.Diatonic
import Music.Diatonic.Scale
import Music.Diatonic.Chord
import Music.Diatonic.Harmony
import Music.Diatonic.Key
import List (intersperse)
import System (getArgs)
import Maybe (fromJust)
import Control.Monad (mplus)
import DD.Html
head' c =
header <<
thetitle << ("Diatonic Dashboard: Chord of " ++ show c) +++
thelink ! [rel "stylesheet", thetype "text/css", href "dd.css"] << noHtml
notes' c =
table ! [theclass "center", cellspacing 2, cellpadding 4] <<
tr <<
cells
where cells = concatHtml . intersperse sep . map cell $ noteList
sep = td << ("|" +++ br +++ "|")
cell (d, n) = td << (concatHtml . intersperse br $ [displayMusicHTML . show $ d, linkNote n])
noteList = degrees c
{--
keys' c =
table ! [theclass "center", cellspacing 2, cellpadding 4] <<
tr <<
cells
where cells = concatHtml . intersperse sep . map cell $ kl
sep = td << ("|" +++ br +++ "|")
cell ks = td << (concatHtml . intersperse br $ ks)
kl = filter (not . null) . map (checkChord c) $ majorKeys
checkChord c k = concatMap check [k, relative k]
where check k =
case degree h c `mplus` degree h7 c of
Nothing -> []
Just d -> [lk d k c]
where h = harmony . scale $ k
h7 = harmony7 . scale $ k
lk d k c = linkKey k +++ " (" +++ (displayMusicHTML . showRoman c $ d) +++ ")"
--}
main = do
args <- getArgs
let c = read (head args) :: Chord
putStrLn . renderHtml $
head' c
+++ body ! [theclass "center"]
<< br +++ h2 << ("Diatonic Dashboard: Chord " ++ show c)
+++ br +++ h3 << "Notes"
+++ notes' c
+++ br +++ h3 << "Keys"
-- +++ keys' c
-- +++ br +++ h3 << "Chords (Harmony)"
-- +++ chords' k harmony
-- +++ br
-- +++ chords' k harmony7
-- +++ br +++ br +++ hotlink "index.html" (stringToHtml "[Home]")
+++ br +++ br +++ hotlink "index.html" (stringToHtml "[Home]")