{-# LANGUAGE OverloadedStrings #-}

-------------------------------------------------------------------------------------
-- |
-- Copyright   : (c) Hans Hoglund 2012
--
-- License     : BSD-style
--
-- Maintainer  : hans@hanshoglund.se
-- Stability   : experimental
-- Portability : GHC
--
-------------------------------------------------------------------------------------

module Music.Lilypond.Dynamics (
        Dynamics(..),
  ) where

import Text.Pretty hiding (Mode)
import Music.Dynamics.Literal
import qualified Data.Char as Char

data Dynamics 
    = PPPPP 
    | PPPP 
    | PPP 
    | PP 
    | P 
    | MP 
    | MF 
    | F 
    | FF 
    | FFF 
    | FFFF 
    | SF
    |SFF 
    | SP 
    | SPP
    | SFZ 
    | RFZ 
    deriving (Eq, Ord, Show, Enum, Bounded)

instance Pretty Dynamics where
    pretty = string . ("\\" ++) . fmap Char.toLower . show

instance IsDynamics Dynamics where
    fromDynamics (DynamicsL (Just x, Nothing)) = case x of
        (-5.5) -> PPPPP
        (-4.5) -> PPPP
        (-3.5) -> PPP
        (-2.5) -> PP
        (-1.5) -> P
        (-0.5) -> MP
        0.5    -> MF
        1.5    -> F
        2.5    -> FF
        3.5    -> FFF
        4.5    -> FFFF
    fromDynamics _ = error "fromDynamics: Unsupported literal for MusicXml.Dynamics"