module Sound.ALSA.Sequencer.Marshal.Port where
import qualified Sound.ALSA.Sequencer.Utility as U
import Foreign.C.Types (CInt, CUInt, )
import Foreign.Storable (Storable, )
import Data.Bits ((.|.), )
import Data.Word (Word8, )
newtype T = Cons Word8 deriving (Eq, Ord, Storable)
instance Show T where
showsPrec prec (Cons x) =
U.showsRecord prec "Port" [U.showsField x]
exp :: T -> CInt
exp (Cons p) = fromIntegral p
imp :: CInt -> T
imp p = Cons (fromIntegral p)
newtype Cap = Cap { unCap :: CUInt } deriving (Eq,Ord)
newtype Type = Type { unType :: CUInt } deriving (Eq,Ord)
systemTimer :: T
systemTimer = Cons 0
systemAnnounce :: T
systemAnnounce = Cons 1
unknown :: T
unknown = Cons 253
capRead :: Cap
capRead = Cap 1
capWrite :: Cap
capWrite = Cap 2
capSyncRead :: Cap
capSyncRead = Cap 4
capSyncWrite :: Cap
capSyncWrite = Cap 8
capDuplex :: Cap
capDuplex = Cap 16
capSubsRead :: Cap
capSubsRead = Cap 32
capSubsWrite :: Cap
capSubsWrite = Cap 64
capNoExport :: Cap
capNoExport = Cap 128
caps :: [Cap] -> Cap
caps cs = Cap (foldl (.|.) 0 (map unCap cs))
typeSpecific :: Type
typeSpecific = Type 1
typeMidiGeneric :: Type
typeMidiGeneric = Type 2
typeMidiGM :: Type
typeMidiGM = Type 4
typeMidiGS :: Type
typeMidiGS = Type 8
typeMidiXG :: Type
typeMidiXG = Type 16
typeMidiMT32 :: Type
typeMidiMT32 = Type 32
typeMidiGM2 :: Type
typeMidiGM2 = Type 64
typeSynth :: Type
typeSynth = Type 1024
typeDirectSample :: Type
typeDirectSample = Type 2048
typeSample :: Type
typeSample = Type 4096
typeHardware :: Type
typeHardware = Type 65536
typeSoftware :: Type
typeSoftware = Type 131072
typeSynthesizer :: Type
typeSynthesizer = Type 262144
typePort :: Type
typePort = Type 524288
typeApplication :: Type
typeApplication = Type 1048576
types :: [Type] -> Type
types cs = Type (foldl (.|.) 0 (map unType cs))