Module Music.Prim

Music primitives.

Primitives

type 'a t = [
  1. | `Note of dur * 'a
    (*

    Interpret note for given duration.

    *)
  2. | `Rest of dur
    (*

    Rest for given duration.

    *)
]

The type for music primitives. Either a note of type 'a or a rest (silence).

val note : dur -> 'a -> 'a t

note d n is `Note (d, n), interprets note n for duration d.

val rest : dur -> 'a t

rest d is `Rest d, rests for duration d.

Properties

val dur : 'a t -> dur

dur p is p's duration in whole notes units.

Traversals

val map : ('a -> 'b) -> 'a t -> 'b t

map f p maps the note of p with f.

val map_dur : (dur -> dur) -> 'a t -> 'a t

map_dur f p maps duration of p with f.

val fold : note:(dur -> 'a -> 'b) -> rest:(dur -> 'b) -> 'a t -> 'b

fold ~note ~rest p folds over p with note and rest.