Module Portmidi


module Portmidi: sig .. end
* Bindings for the portmidi library. * *
Author(s): Niki Yoshiuchi


Exceptions



type error =
| PmHostError
| PmInvalidDeviceId
| PmInsufficientMemory
| PmBufferTooSmall
| PmBufferOverflow
| PmBadPtr
| PmBadData
| PmInternalError
| PmBufferMaxSize
| PmUnkown
Types of errors
exception Error of error
An error occured. Use string_of_error to get a description of the * error.
val string_of_error : error -> string
Get a description of an error.

General


val init : unit -> unit
Initialize the portmidi library. Call this before opening any streams
val terminate : unit -> unit
Close the library

Devices



type device_info = {
   struct_version : int;
   interf : string;
   name : string;
   input : bool;
   output : bool;
   opened : bool;
}
Device information type
val count_devices : unit -> int
count_devices () returns the number of MIDI devices available
val get_default_input_device_id : unit -> int
get_default_input_device_id () returns the default input MIDI device
val get_default_output_device_id : unit -> int
get_default_output_device_id () returns the default output MIDI device
val get_device_info : int -> device_info
get_device_info id returns a device_info record for device id

Streams


type stream 
Stream type
val open_input : ?time_proc:('a -> int) option ->
?time_info:'a option -> int -> int -> stream
open_input ?time_proc:(Some time_fun) ?time_info:(Some time_arg) device_id buffer_size * opens a MIDI stream ready for input on device device_id with a buffer of * buffer_size. time_fun is a function that returns a time stamp in * milliseconds, time_args is the argument passed to time_fun. If they are * set to None then the default time function is used.
val open_output : ?time_proc:('a -> int) option ->
?time_info:'a option -> int -> int -> int -> stream
open_input ?time_proc:(Some time_fun) ?time_info:(Some time_arg) device_id * buffer_size latency * opens a MIDI stream ready for ouput on device device_id with a buffer of * buffer_size. latency is the delay in milliseconds applied to the time * stamp.
val abort : stream -> unit
Abort a stream
val close : stream -> unit
Close a stream

Events



type event = {
   message : Int32.t;
   timestamp : Int32.t;
}
Event type
val message : int -> int -> int -> int32
message status data1 data2 creates a message
val message_status : int32 -> int
message_status msg returns the status of message msg
val message_data1 : int32 -> int
message_data1 msg returns the first data byte of message msg
val message_data2 : int32 -> int
message_data2 msg returns the second data byte of message msg
val message_contents : int32 -> int * int * int
message_contents msg returns the status and data bytes of message msg
val poll : stream -> bool
poll st returns true of the input stream st has any events
val read_stream : stream -> event array -> int -> int -> int
read_stream st events ofs len reads up to len events from stream st * and stores them in events starting at ofs. The return value is the * actual number of events read.
val write_stream : stream -> event array -> int -> int -> unit
write_stream st events ofs len writes len events to the stream st from * events starting at ofs.
val write_short : stream -> Int32.t -> Int32.t -> unit
write_short st when msg writes the event formed by message msg and * timestamp when to stream st
val write_sysex : stream -> Int32.t -> string -> unit
write_short st when msg writes the SysEx formed by message msg and * timestamp when to stream st
module Time: sig .. end