Module Msynth.MIDI

Interfacing with MIDI keyboards and controllers.

type event = [
  1. | `Note_on of int * float
  2. | `Note_off of int
  3. | `Controller of int * float
  4. | `Pitch_bend of int * float
  5. | `Program_change of int * int
  6. | `Nop
    (*

    Do not do anything. This is useful to extend repeated patterns.

    *)
]
type stream = event list Stream.t

A stream of MIDI events.

type t = {
  1. mutex : Stdlib.Mutex.t;
  2. thread : Thread.t;
  3. map : int -> event -> int * event;
  4. handlers : (int -> event -> unit) list Stdlib.ref;
  5. send : int -> event -> unit;
}
val create : ?print:bool -> unit -> t
val register : t -> (int -> event -> unit) -> unit

Register a handler of midi events.

val map : t -> (int -> event -> int * event) -> t

Map a function on all events.

val events : ?channel:int -> t -> stream

Create a stream of midi events.

val send : t -> int -> event -> unit
val controller : t -> ?channel:int -> int -> ?mode:[< `Linear | `Logarithmic Linear ] -> ?min:float -> ?max:float -> float -> float Stream.t

The value of a specific controller.

val pitch_bend : t -> ?channel:int -> ?mode:[< `Linear | `Logarithmic Linear ] -> ?max:float -> unit -> float Stream.t
val toggle : t -> ?channel:int -> ?init:bool -> int -> float -> bool

The value of a toggle controller.