Safe Haskell | None |
---|
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.
- type MidiTime = Word32
- type MidiMessage = Message
- type MidiEvent = (MidiTime, Message)
- class MidiHasName a where
- data Source
- sources :: IO [Source]
- data Destination
- destinations :: IO [Destination]
- openSource :: Source -> Maybe (MidiTime -> Message -> IO ()) -> IO Stream
- openDestination :: Destination -> IO Stream
- data Stream
- close :: Stream -> IO ()
- start :: Stream -> IO ()
- stop :: Stream -> IO ()
- send :: Stream -> Message -> IO ()
- getNextEvent :: Stream -> IO (Maybe MidiEvent)
- getEvents :: Stream -> IO [MidiEvent]
- currentTime :: Stream -> IO MidiTime
Messages
type MidiMessage = MessageSource
Input and output
class MidiHasName a whereSource
Instances
Sources and Destinations
The opaque data type representing a Midi source.
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.
start :: Stream -> IO ()Source
Starts a connection. This is required for receiving Midi messages, and also for starting the clock.
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
)