hmidi-0.2.1.0: Binding to the OS level MIDI services

Safe HaskellNone

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. .

Always link with the threaded runtime! (use the -threaded GHC option)

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.

class MIDIObject a => MIDIHasName a Source

MIDI objects which can have a name, model name and manufacturer

Instances

MIDIHasName Destination 
MIDIHasName Source 
MIDIHasName MIDIPortRef 
MIDIHasName MIDIEndpointRef 
MIDIHasName MIDIEntityRef 
MIDIHasName MIDIDeviceRef 

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.

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

Opens a MIDI Source. There are two possibilites to receive MIDI messages. The user can either supply 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 should not 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)

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

Checks the next event from a buffered connection, but does not remove it from the buffer.

getEvents :: Connection -> IO [MidiEvent]Source

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

getEventsUntil :: Connection -> TimeStamp -> IO [MidiEvent]Source

Gets all the events with timestamp less than the specified from the buffer.

currentTime :: Connection -> IO Word32Source

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

createDestination :: String -> Maybe ClientCallback -> IO ConnectionSource

Creates a new MIDI destination (which is a source for us), to which other programs can connect to. There are two possibilites to receive MIDI messages. The user can either supply a callback function, or get the messages from an asynchronous buffer. However, mixing the two approaches is not allowed.

createSource :: String -> IO ConnectionSource

Creates a new MIDI source (which is a destination for us), to which other programs can connect to.