hmt-0.15: Haskell Music Theory

Safe HaskellSafe-Inferred
LanguageHaskell98

Music.Theory.Time.Duration

Synopsis

Documentation

data Duration Source

Duration stored as hours, minutes, seconds and milliseconds.

Constructors

Duration 

Fields

hours :: Int
 
minutes :: Int
 
seconds :: Int
 
milliseconds :: Int
 

s_sms :: (RealFrac n, Integral i) => n -> (i, i) Source

Convert fractional seconds to integral (seconds,milliseconds).

s_sms 1.75 == (1,750)

sms_s :: Integral i => (i, i) -> Double Source

Inverse of s_sms.

sms_s (1,750) == 1.75

read_duration_tuple :: String -> (Int, Int, Int, Int) Source

Read function for Duration tuple.

read_duration :: String -> Duration Source

Read function for Duration. Allows either H:M:S.MS or M:S.MS or S.MS.

read_duration "01:35:05.250" == Duration 1 35 5 250
read_duration    "35:05.250" == Duration 0 35 5 250
read_duration       "05.250" == Duration 0 0 5 250

show_duration :: Duration -> String Source

Show function for Duration.

show_duration (Duration 1 35 5 250) == "01:35:05.250"
show (Duration 1 15 0 000) == "01:15:00.000"

duration_to_tuple :: (Int -> a) -> Duration -> (a, a, a, a) Source

Extract Duration tuple applying filter function at each element

duration_tuple id (Duration 1 35 5 250) == (1,35,5,250)

tuple_to_duration :: (a -> Int) -> (a, a, a, a) -> Duration Source

Inverse of duration_to_tuple.