Karya, built on Mon Jul 24 11:39:07 PDT 2017 (patch 33511aca01257b76b88de7c7a2763b7a965c084e)

Safe HaskellNone

Midi.Midi

Contents

Synopsis

Documentation

type WriteMessages = [WriteMessage] Source #

Declared abstract here so I can switch to a more compact representation later.

devices

constructors

program_change :: Int -> Program -> [ChannelMessage] Source #

Emit a program change with bank in [msb, lsb, pchange] order.

realtime_sysex :: ByteString.ByteString -> Message Source #

This is a special kind of sysex which is meant to be interpreted in real time.

rpn / nrpn

pitch_bend_range :: Double -> [ChannelMessage] Source #

Emit a pitch bend range RPN message for the given range.

nrpn_tuning :: [(Key, NoteNumber)] -> [ChannelMessage] Source #

This is an emulation of realtime_tuning for Kontakt KSP, which understands NRPNs, but not sysex.

Each key gets (50, 0) with the source key, (51, 0) with the destination, and (52, 0) with tenths of a cent as a 14-bit number. I have to put source and destination NoteNumbers into separate NRPN numbers because msb and lsb arrive separately, so they pretty much have to be used as msb and lsb of a single number.

modify

predicates

valid_msg :: Message -> Bool Source #

Check to make sure midi msg vals are all in range.

is_state :: Message -> Bool Source #

Is this a message that will change the channel state? These are the messages that will affect subsequent NoteOns.

is_pitched :: Message -> Bool Source #

True for messages with a pitch: NoteOn, NoteOff and PitchBend.

types

type Channel = Word4 Source #

type Velocity = Word7 Source #

type Program = Word7 Source #

type ControlValue = Word7 Source #

type PitchBendValue = Float Source #

This is converted to and from the -0x2000 and +0x2000 range by the parser.

type Manufacturer = Word7 Source #

newtype Key Source #

Constructors

Key Int 

Instances

Enum Key # 

Methods

succ :: Key -> Key #

pred :: Key -> Key #

toEnum :: Int -> Key #

fromEnum :: Key -> Int #

enumFrom :: Key -> [Key] #

enumFromThen :: Key -> Key -> [Key] #

enumFromTo :: Key -> Key -> [Key] #

enumFromThenTo :: Key -> Key -> Key -> [Key] #

Eq Key # 

Methods

(==) :: Key -> Key -> Bool #

(/=) :: Key -> Key -> Bool #

Num Key # 

Methods

(+) :: Key -> Key -> Key #

(-) :: Key -> Key -> Key #

(*) :: Key -> Key -> Key #

negate :: Key -> Key #

abs :: Key -> Key #

signum :: Key -> Key #

fromInteger :: Integer -> Key #

Ord Key # 

Methods

compare :: Key -> Key -> Ordering #

(<) :: Key -> Key -> Bool #

(<=) :: Key -> Key -> Bool #

(>) :: Key -> Key -> Bool #

(>=) :: Key -> Key -> Bool #

max :: Key -> Key -> Key #

min :: Key -> Key -> Key #

Read Key # 
Show Key # 

Methods

showsPrec :: Int -> Key -> ShowS #

show :: Key -> String #

showList :: [Key] -> ShowS #

Pretty.Pretty Key # 
Serialize.Serialize Key # 

from_key :: Num a => Key -> a Source #

to_key :: Integral a => a -> Key Source #

to_closest_key :: RealFrac a => a -> (Key, a) Source #

data ChannelMessage Source #

Constructors

NoteOff !Key !Velocity 
NoteOn !Key !Velocity 
Aftertouch !Key !ControlValue 
ControlChange !Control !ControlValue 
ProgramChange !Program 
ChannelPressure !ControlValue 
PitchBend !PitchBendValue 
PitchBendInt !Word7 !Word7

This is PitchBend, but with precise control over the bytes sent.

AllSoundOff

channel mode messages (special control values)

ResetAllControls 
LocalControl !Bool 
AllNotesOff 
UndefinedChannelMode !Word7 !Word7

There are a few values in the ChannelMode range left undefined.

MTC

data Mtc Source #

Constructors

Mtc !SmpteFragment !Word4 

Instances

Eq Mtc # 

Methods

(==) :: Mtc -> Mtc -> Bool #

(/=) :: Mtc -> Mtc -> Bool #

Ord Mtc # 

Methods

compare :: Mtc -> Mtc -> Ordering #

(<) :: Mtc -> Mtc -> Bool #

(<=) :: Mtc -> Mtc -> Bool #

(>) :: Mtc -> Mtc -> Bool #

(>=) :: Mtc -> Mtc -> Bool #

max :: Mtc -> Mtc -> Mtc #

min :: Mtc -> Mtc -> Mtc #

Read Mtc # 
Show Mtc # 

Methods

showsPrec :: Int -> Mtc -> ShowS #

show :: Mtc -> String #

showList :: [Mtc] -> ShowS #

data Smpte Source #

Instances

Eq Smpte # 

Methods

(==) :: Smpte -> Smpte -> Bool #

(/=) :: Smpte -> Smpte -> Bool #

Show Smpte # 

Methods

showsPrec :: Int -> Smpte -> ShowS #

show :: Smpte -> String #

showList :: [Smpte] -> ShowS #

seconds_to_frame :: FrameRate -> Seconds -> Frames Source #

frame_to_seconds :: FrameRate -> Frames -> Seconds Source #

generate_mtc :: FrameRate -> Frames -> [(Double, Message)] Source #

Generate MTC starting at the given time and going on until the well of time runs dry. Or 7 bits overflow.

Since MTC can only start on a frame, the first returned time might be slightly before the requested time.

One MtcQuarterFrame is transmitted per quarter frame. Since it takes 8 to make a complete SMPTE frame, you wind up getting every other frame.

mtc_sync :: FrameRate -> Smpte -> Message Source #

Send full MTC sync code. This is supposed to happen every time there is a time dicontinuity.

tuning

realtime_tuning :: [(Key, NoteNumber)] -> Message Source #

Create a realtime tuning msg. Few synthesizers support this.

Based on http://www.midi.org/techspecs/midituning.php

util

join14 :: Word7 -> Word7 -> Int Source #

Join (LSB, MSB) 7-bit words into an int.

split14 Source #

Arguments

:: Int 
-> (Word7, Word7)

(LSB, MSB)

Split an Int into two 7 bit words.

join4 :: Word4 -> Word4 -> Word7 Source #

Join msb and lsb into a Word7.

split4 :: Word8 -> (Word4, Word4) Source #

Split a Word8 into (msb, lsb) nibbles, and join back.

manufacturer