hmt-0.16: Haskell Music Theory

Safe HaskellSafe
LanguageHaskell98

Music.Theory.Time.Notation

Contents

Synopsis

Documentation

type FSEC = Double Source #

Fractional seconds.

type MinSec n = (n, n) Source #

Minutes, seconds as (min,sec)

type MINSEC = (Int, Int) Source #

Type specialised.

type MinCsec n = (n, n, n) Source #

Minutes, seconds, centi-seconds as (min,sec,csec)

type MINCSEC = (Int, Int, Int) Source #

Type specialised.

sec_to_minsec :: Integral n => n -> MinSec n Source #

divMod by 60.

sec_to_minsec 123 == (2,3)

minsec_to_sec :: Num n => MinSec n -> n Source #

Inverse of sec_minsec.

minsec_to_sec (2,3) == 123

minsec_binop :: Integral t => (t -> t -> t) -> MinSec t -> MinSec t -> MinSec t Source #

minsec_sub :: Integral n => MinSec n -> MinSec n -> MinSec n Source #

minsec_binop -, assumes q precedes p.

minsec_sub (2,35) (1,59) == (0,36)

minsec_diff :: Integral n => MinSec n -> MinSec n -> MinSec n Source #

minsec_binop subtract, assumes p precedes q.

minsec_diff (1,59) (2,35) == (0,36)

minsec_add :: Integral n => MinSec n -> MinSec n -> MinSec n Source #

minsec_binop +.

minsec_add (1,59) (2,35) == (4,34)

minsec_sum :: Integral n => [MinSec n] -> MinSec n Source #

foldl of minsec_add

minsec_sum [(1,59),(2,35),(4,34)] == (9,08)

fsec_to_minsec :: FSEC -> MINSEC Source #

Fractional seconds to (min,sec).

map fsec_to_minsec [59.49,60,60.51] == [(0,59),(1,0),(1,1)]

minsec_pp :: MINSEC -> String Source #

MINSEC pretty printer.

map (minsec_pp . fsec_to_minsec) [59,61] == ["00:59","01:01"]

MinSec parser.

fsec_to_mincsec :: FSEC -> MINCSEC Source #

Fractional seconds to (min,sec,csec), csec value is rounded.

map fsec_to_mincsec [1,1.5,4/3] == [(0,1,0),(0,1,50),(0,1,33)]

mincsec_to_fsec :: Real n => MinCsec n -> FSEC Source #

Inverse of fsec_mincsec.

csec_to_mincsec :: Integral n => n -> MinCsec n Source #

Centi-seconds to MinCsec.

map csec_to_mincsec [123,12345] == [(0,1,23),(2,3,45)]

mincsec_pp_opt :: Bool -> MINCSEC -> String Source #

MINCSEC pretty printer, concise mode omits centiseconds when zero.

map (mincsec_pp_opt True . fsec_to_mincsec) [1,60.5] == ["00:01","01:00.50"]

mincsec_pp :: MINCSEC -> String Source #

MINCSEC pretty printer.

let r = ["00:01.00","00:06.67","02:03.45"]
map (mincsec_pp . fsec_to_mincsec) [1,6+2/3,123.45] == r

mincsec_binop :: Integral t => (t -> t -> t) -> MinCsec t -> MinCsec t -> MinCsec t Source #

span_pp :: (t -> String) -> (t, t) -> String Source #

Given printer, pretty print time span.