hmidi-0.1: Binding to the OS level MIDI services

System.MIDI

Description

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

Synopsis

Documentation

type Source = SourceSource

The opaque data type representing a MIDI source.

type Destination = DestinationSource

The opaque data type representing a MIDI destination.

type Connection = ConnectionSource

The opaque data type representing a MIDI connection.

enumerateSources :: IO [Source]Source

Enumerates the MIDI sources present in the system.

enumerateDestinations :: IO [Destination]Source

Enumerates the MIDI destinations present in the system.

getName :: MIDIHasName a => a -> IO StringSource

These functions return the name, model and manufacturer of a MIDI source / destination.

Note: On Win32, only getName returns a somewhat meaningful string at the moment.

getModel :: MIDIHasName a => a -> IO StringSource

getManufacturer :: MIDIHasName a => a -> IO StringSource

openSource :: Source -> Maybe ClientCallback -> IO ConnectionSource

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 ConnectionSource

Opens a MIDI Destination.

close :: Connection -> IO ()Source

Closes a MIDI Connection.

send :: Connection -> MidiMessage -> IO ()Source

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

sendSysEx :: Connection -> [Word8] -> IO ()Source

Sends a system exclusive message. You shouldn't include the starting / trailing bytes 0xF0 and 0xF7.

Note: On Win32, the connection must be a Destination

start :: Connection -> IO ()Source

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

stop :: Connection -> IO ()Source

Stops a connection.

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

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

getEvents :: Connection -> IO [MidiEvent]Source

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

currentTime :: Connection -> IO Word32Source

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