module Sound.SC3.UGen.Rate where
import Data.Char
import Data.Function
data Rate = IR | KR | AR | DR
deriving (Eq,Enum,Bounded,Show,Read)
instance Ord Rate where
compare = compare `on` rate_ord
rateId :: Rate -> Int
rateId = fromEnum
rate_ord :: Rate -> Int
rate_ord r =
case r of
IR -> 0
KR -> 1
AR -> 2
DR -> 3
rate_color :: Rate -> String
rate_color r =
case r of
AR -> "black"
KR -> "blue"
IR -> "yellow"
DR -> "red"
all_rates :: [Rate]
all_rates = [minBound .. maxBound]
rate_parse :: String -> Maybe Rate
rate_parse r =
case map toUpper r of
"AR" -> Just AR
"KR" -> Just KR
"IR" -> Just IR
"DR" -> Just DR
_ -> Nothing
data K_Type = K_IR | K_KR | K_TR | K_AR
deriving (Eq,Show,Ord)
ktype :: Rate -> Bool -> K_Type
ktype r tr =
if tr
then case r of
KR -> K_TR
_ -> error "ktype: non KR trigger control"
else case r of
IR -> K_IR
KR -> K_KR
AR -> K_AR
DR -> error "ktype: DR control"