Safe Haskell | None |
---|---|
Language | Haskell98 |
- data Output = Output {
- cshape :: ControllerShape
- conn :: PMStream
- buffer :: MVar ([ParamMap], [MIDIEvent])
- bufferstate :: MVar OutputState
- midistart :: CULong
- rstart :: UTCTime
- type OutputState = (TickedConnectionCount, ConnectionCount, [ParamMap], OutputOnline)
- type MidiDeviceMap = Map String Output
- type TimedNote = (CLong, MIDIVelocity, MIDIDuration)
- makeConnection :: MVar MidiDeviceMap -> String -> Int -> ControllerShape -> IO (ToMessageFunc, Output)
- flushBackend :: Output -> Shape -> Tempo -> Int -> IO ()
- sendevents :: Output -> Shape -> Tempo -> Tick -> [MIDIEvent] -> [MIDIEvent] -> IO ([SentEvent], [MIDIEvent])
- store :: Output -> Int -> Tempo -> Tick -> Onset -> Offset -> MidiMap -> ParamMap -> IO ()
- mkStore :: Int -> Output -> IO ToMessageFunc
- storeParams :: Output -> Int -> ParamMap -> IO () -> IO ()
- scheduleTime :: (CULong, UTCTime) -> Double -> CULong
- toMidiValue :: ControllerShape -> Param -> Value -> Maybe Int
- cutShape :: Shape -> ParamMap -> Maybe ParamMap
- stripDefaults :: Maybe ParamMap -> Maybe ParamMap
- changeState :: (OutputState -> OutputState) -> Output -> IO ()
- readState :: (OutputState -> b) -> Output -> IO b
- useOutput :: MVar MidiDeviceMap -> String -> ControllerShape -> IO (Maybe Output)
- displayOutputDevices :: IO String
- outputDevice :: DeviceID -> Int -> ControllerShape -> IO (Either Output PMError)
- makeRawEvent :: MIDIMessage -> CULong -> PMEvent
- noteOn :: MIDIChannel -> MIDINote -> MIDIVelocity -> MIDITime -> [MIDIEvent]
- noteOff :: MIDIChannel -> MIDINote -> MIDITime -> [MIDIEvent]
- makeCtrl :: MIDIChannel -> ControlChange -> MIDIDatum -> MIDITime -> [MIDIEvent]
Types
An abstract definition of a physical MIDI Output.
Manages virtual streams to multiple channels of a single connection to a MIDI device.
Output | |
|
type OutputState = (TickedConnectionCount, ConnectionCount, [ParamMap], OutputOnline) Source #
Keep track of virtual streams
- Reflects the number of virtual streams that have already stored their events for this tick. Every time
TickedConnectionCount
cycles, MIDI events will be sent out. ConnectionCount
is increased on every new stream created viamidiSetters
- For each channel, currently used params and their values are kept.
- Output will only be scheduling, once online, i.e. when the first stream is initialized
type TimedNote = (CLong, MIDIVelocity, MIDIDuration) Source #
A Triplet of the deviation from the note a5
, velocity and duration
Initialization
:: MVar MidiDeviceMap | The current list of already connected devices |
-> String | The MIDI device name |
-> Int | The MIDI channel |
-> ControllerShape | The definition of useable |
-> IO (ToMessageFunc, Output) | A function to schedule MIDI events and the output that keeps track of connections |
Initialize a connection to the given MIDI device by Name
flushBackend :: Output -> Shape -> Tempo -> Int -> IO () Source #
Sends out MIDI events once all virtual streams have buffered their events.
This will be called after every tick
Scheduling
:: Output | The connection to be used |
-> Shape | The shape to be queried for latency |
-> Tempo | The current speed |
-> Tick | The number of ticks elapsed since start, may be reset when using |
-> [MIDIEvent] | A list of events potentially needed to be sent |
-> [MIDIEvent] | A list of reset events potentially needed to be sent |
-> IO ([SentEvent], [MIDIEvent]) | A list of events sent late and a list of events to send later |
Sends out MIDI events due for this tick.
store :: Output -> Int -> Tempo -> Tick -> Onset -> Offset -> MidiMap -> ParamMap -> IO () Source #
Buffer a single tick's MIDI events for a single channel of a single connection
mkStore :: Int -> Output -> IO ToMessageFunc Source #
Returns a function to be called on every tick,
splits the given ParamMap
into MIDI note information
and CCs.
storeParams :: Output -> Int -> ParamMap -> IO () -> IO () Source #
Union the currently stored paramstate for certain channel with the given one
Converters
toMidiValue :: ControllerShape -> Param -> Value -> Maybe Int Source #
Convert a Param
's Value
into a MIDI consumable datum.
Applies range mapping and scaling functions according to ControllerShape
cutShape :: Shape -> ParamMap -> Maybe ParamMap Source #
Keep only params that are in a given shape, replace missing with defaults
stripDefaults :: Maybe ParamMap -> Maybe ParamMap Source #
Keep only params that are explicitly set (i.e. not default)
State handling
changeState :: (OutputState -> OutputState) -> Output -> IO () Source #
Low-level functions
useOutput :: MVar MidiDeviceMap -> String -> ControllerShape -> IO (Maybe Output) Source #
open named MIDI output or use cached (PortMIDI doesn't like opening two connections to the same device!)
displayOutputDevices :: IO String Source #
Example usage:
>>>
putStrLn =<< displayOutputDevices
ID: Name 0: Midi Through Port-0 2: DSI Tetra MIDI 1
outputDevice :: DeviceID -> Int -> ControllerShape -> IO (Either Output PMError) Source #
Creates an Output
wrapping a PortMidi device
makeRawEvent :: MIDIMessage -> CULong -> PMEvent Source #
makeCtrl :: MIDIChannel -> ControlChange -> MIDIDatum -> MIDITime -> [MIDIEvent] Source #