hamid-0.8: Binding to the OS level MIDI services (fork of system-midi).

Safe HaskellNone




A lowest common denominator interface to the Win32 and MacOSX MIDI bindings. Error handling is via fail-s in the IO monad.



Input and output

Sources and Destinations

data Source Source

The opaque data type representing a MIDI source.

sources :: IO [Source]Source

Enumerates the MIDI sources present in the system.

data Destination Source

The opaque data type representing a MIDI destination.

destinations :: IO [Destination]Source

Enumerates the MIDI destinations present in the system.


openSource :: Source -> Maybe (MidiTime -> Message -> IO ()) -> IO StreamSource

Opens a MIDI Source. There are two possibilites to receive MIDI messages. The user can either support a callback function, or get the messages from an asynchronous buffer. However, mixing the two approaches is not allowed.

openDestination :: Destination -> IO StreamSource

Opens a MIDI Destination.

data Stream Source

The opaque data type representing a MIDI connection.

close :: Stream -> IO ()Source

Closes a MIDI Stream.

start :: Stream -> IO ()Source

Starts a connection. This is required for receiving MIDI messages, and also for starting the clock.

stop :: Stream -> IO ()Source

Stops a connection.


send :: Stream -> Message -> IO ()Source

Sends a short message. The connection must be a Destination.


getNextEvent :: Stream -> IO (Maybe MidiEvent)Source

Gets the next event from a buffered connection (see also openSource)

getEvents :: Stream -> IO [MidiEvent]Source

Gets all the events from the buffer (see also openSource)


currentTime :: Stream -> IO MidiTimeSource

Returns the time elapsed since the last start call, in milisecs.