Module Mu_midi.File

MIDI files (.mid).

MIDI files encoder.

Files

type type' =
  1. | Single_track
  2. | Multi_track
  3. | Multi_pattern

The type for MIDI file types.

type time_div =
  1. | Ticks_per_quarter_note of int
    (*

    [0;215-1]

    *)
  2. | Ticks_per_second of int * int

The type for specifying the unit for ticks in the file.

type track = event list

A track is a list of MIDI events. The tick of an event is expressed relative to the previous tick. Tracks need to end with Msg.t.Track_end event (XXX The codec could handle that).

type t

The type for MIDI files.

val v : type':type' -> time_div:time_div -> track list -> t

v ~type ~time_div ~tracks is a MIDI file with given parameters.

val type' : t -> type'

type' f is f's type.

val time_div : t -> time_div

time_div f is f's time division.

val tracks : t -> track list

tracks f is the list of tracks of f.

Encoding

val to_string : t -> string

to_string m is m as a MIDI file.

Converting

val of_performance : Mu.Performance.t -> t

of_performance p is a MIDI file for peformance p.

FIXME.

  • Do a proper error type and a result, for now this raises Failure _.
  • For now p is limited to use of 15 instruments (one is reserved for percussion). Each instrument gets assigned a different channel and lives in its own track. A few alternative strategies could be used here.