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

Safe HaskellNone

System.Midi

Contents

Description

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

Synopsis

Messages

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.

Streams

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.

Sending

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

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

Receiving

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)

Timer

currentTime :: Stream -> IO MidiTimeSource

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