{-# INCLUDE <alsa/asoundlib.h> #-} {-# LINE 1 "Sound/Alsa/Sequencer/Marshal.hsc" #-} -------------------------------------------------------------------------------- {-# LINE 2 "Sound/Alsa/Sequencer/Marshal.hsc" #-} -- | -- Module : Sound.Alsa.Sequencer.Marshal -- Copyright : (c) Iavor S. Diatchki, 2007 -- License : BSD3 -- -- Maintainer: Iavor S. Diatchki -- Stability : provisional -- -- PRIVATE MODULE. -- -- Here we have the various types used by the library, -- and how they are imported\/exported to C. -- -- NOTE: In the translations bellow we make the following assumptions -- about the sizes of C types. -- CChar = 8 bits -- CShort = 16 bit -- CInt = 32 bits -------------------------------------------------------------------------------- module Sound.Alsa.Sequencer.Marshal where {-# LINE 25 "Sound/Alsa/Sequencer/Marshal.hsc" #-} import Foreign import Foreign.C.Types import Data.Word import Data.Array -- | Read\/Write permissions for the sequencer device. newtype OpenMode = OpenMode CInt deriving (Show,Eq,Ord,Storable) open_output :: OpenMode open_output = OpenMode 1 open_input :: OpenMode open_input = OpenMode 2 open_duplex :: OpenMode open_duplex = OpenMode 3 {-# LINE 39 "Sound/Alsa/Sequencer/Marshal.hsc" #-} exp_OpenMode :: OpenMode -> CInt exp_OpenMode (OpenMode x) = x -- | Blocking behavior of the sequencer device. data BlockMode = Block -- ^ Operations may block. | Nonblock -- ^ Throw exceptions instead of blocking. deriving (Show,Eq) exp_BlockMode :: BlockMode -> CInt exp_BlockMode x = case x of Block -> 0 Nonblock -> 1 {-# LINE 52 "Sound/Alsa/Sequencer/Marshal.hsc" #-} -- | The type of sequencer handles. newtype SndSeq = SndSeq (Ptr SndSeq_) deriving Eq data SndSeq_ -- | The type of client identifiers. newtype Client = Client Word8 deriving (Show,Eq,Ord,Storable) client_system :: Client client_system = Client 0 client_subscribers :: Client client_subscribers = Client 254 client_broadcast :: Client client_broadcast = Client 255 client_unknown :: Client client_unknown = Client 253 {-# LINE 69 "Sound/Alsa/Sequencer/Marshal.hsc" #-} exp_Client :: Client -> CInt exp_Client (Client c) = fromIntegral c imp_Client :: Word -> Client imp_Client p = Client (fromIntegral p) -- | The different types of clients. data ClientType = UserClient | KernelClient imp_ClientType :: CInt -> ClientType imp_ClientType x = if x == 1 then UserClient {-# LINE 83 "Sound/Alsa/Sequencer/Marshal.hsc" #-} else KernelClient -- | Port capabilities. newtype PortCap = PortCap { unPortCap :: CUInt } deriving (Eq,Ord) -- | Port types. newtype PortType = PortType { unPortType :: CUInt } deriving (Eq,Ord) port_system_timer :: Port port_system_timer = Port 0 port_system_announce :: Port port_system_announce = Port 1 port_unknown :: Port port_unknown = Port 253 {-# LINE 96 "Sound/Alsa/Sequencer/Marshal.hsc" #-} cap_read :: PortCap cap_read = PortCap 1 cap_write :: PortCap cap_write = PortCap 2 cap_sync_read :: PortCap cap_sync_read = PortCap 4 cap_sync_write :: PortCap cap_sync_write = PortCap 8 cap_duplex :: PortCap cap_duplex = PortCap 16 cap_subs_read :: PortCap cap_subs_read = PortCap 32 cap_subs_write :: PortCap cap_subs_write = PortCap 64 cap_no_export :: PortCap cap_no_export = PortCap 128 {-# LINE 107 "Sound/Alsa/Sequencer/Marshal.hsc" #-} caps :: [PortCap] -> PortCap caps cs = PortCap (foldl (.|.) 0 (map unPortCap cs)) type_specific :: PortType type_specific = PortType 1 type_midi_generic :: PortType type_midi_generic = PortType 2 type_midi_gm :: PortType type_midi_gm = PortType 4 type_midi_gs :: PortType type_midi_gs = PortType 8 type_midi_xg :: PortType type_midi_xg = PortType 16 type_midi_mt32 :: PortType type_midi_mt32 = PortType 32 type_midi_gm2 :: PortType type_midi_gm2 = PortType 64 type_synth :: PortType type_synth = PortType 1024 type_direct_sample :: PortType type_direct_sample = PortType 2048 type_sample :: PortType type_sample = PortType 4096 type_hardware :: PortType type_hardware = PortType 65536 type_software :: PortType type_software = PortType 131072 type_synthesizer :: PortType type_synthesizer = PortType 262144 type_port :: PortType type_port = PortType 524288 type_application :: PortType type_application = PortType 1048576 {-# LINE 130 "Sound/Alsa/Sequencer/Marshal.hsc" #-} types :: [PortType] -> PortType types cs = PortType (foldl (.|.) 0 (map unPortType cs)) -- The type of queue identifiers. newtype Queue = Queue Word8 deriving (Show,Eq,Ord,Storable) imp_Queue :: Word -> Queue imp_Queue x = Queue (fromIntegral x) exp_Queue :: Queue -> CInt exp_Queue (Queue x) = fromIntegral x queue_direct :: Queue queue_direct = Queue 253 {-# LINE 150 "Sound/Alsa/Sequencer/Marshal.hsc" #-} data QueueTimerType = TimerAlsa | TimerMidiClock | TimerMidiTick exp_QueueTimerType :: QueueTimerType -> CInt exp_QueueTimerType t = case t of TimerAlsa -> 0 {-# LINE 158 "Sound/Alsa/Sequencer/Marshal.hsc" #-} TimerMidiClock -> 1 {-# LINE 159 "Sound/Alsa/Sequencer/Marshal.hsc" #-} TimerMidiTick -> 2 {-# LINE 160 "Sound/Alsa/Sequencer/Marshal.hsc" #-} imp_QueueTimerType :: CInt -> QueueTimerType imp_QueueTimerType t = case t of 0 -> TimerAlsa {-# LINE 164 "Sound/Alsa/Sequencer/Marshal.hsc" #-} 1 -> TimerMidiClock {-# LINE 165 "Sound/Alsa/Sequencer/Marshal.hsc" #-} 2 -> TimerMidiTick {-# LINE 166 "Sound/Alsa/Sequencer/Marshal.hsc" #-} _ -> error ("imp_QueueTimerType: unknown timer type (" ++ show t ++ ")") -- The type of client ports. newtype Port = Port Word8 deriving (Show,Eq,Ord,Storable) exp_Port :: Port -> CInt exp_Port (Port p) = fromIntegral p imp_Port :: Word -> Port imp_Port p = Port (fromIntegral p) data Addr = Addr { addr_client :: !Client , addr_port :: !Port } deriving (Show,Eq,Ord) exp_Addr :: Addr -> (CInt,CInt) exp_Addr a = (exp_Client (addr_client a), exp_Port (addr_port a)) instance Storable Addr where sizeOf _ = (8) {-# LINE 189 "Sound/Alsa/Sequencer/Marshal.hsc" #-} alignment _ = 4 -- XXX peek p = do cl <- (\hsc_ptr -> peekByteOff hsc_ptr 0) p {-# LINE 191 "Sound/Alsa/Sequencer/Marshal.hsc" #-} po <- (\hsc_ptr -> peekByteOff hsc_ptr 1) p {-# LINE 192 "Sound/Alsa/Sequencer/Marshal.hsc" #-} return Addr { addr_client = cl, addr_port = po } poke p v = (\hsc_ptr -> pokeByteOff hsc_ptr 0) p (addr_client v) {-# LINE 194 "Sound/Alsa/Sequencer/Marshal.hsc" #-} >> (\hsc_ptr -> pokeByteOff hsc_ptr 1) p (addr_port v) {-# LINE 195 "Sound/Alsa/Sequencer/Marshal.hsc" #-} data Connect = Connect { conn_source :: !Addr , conn_dest :: !Addr } deriving (Show,Eq,Ord) instance Storable Connect where sizeOf _ = (4) {-# LINE 203 "Sound/Alsa/Sequencer/Marshal.hsc" #-} alignment _ = 4 -- XXX peek p = do s <- (\hsc_ptr -> peekByteOff hsc_ptr 0) p {-# LINE 205 "Sound/Alsa/Sequencer/Marshal.hsc" #-} d <- (\hsc_ptr -> peekByteOff hsc_ptr 2) p {-# LINE 206 "Sound/Alsa/Sequencer/Marshal.hsc" #-} return Connect { conn_source = s, conn_dest = d } poke p v = (\hsc_ptr -> pokeByteOff hsc_ptr 0) p (conn_source v) {-# LINE 208 "Sound/Alsa/Sequencer/Marshal.hsc" #-} >> (\hsc_ptr -> pokeByteOff hsc_ptr 2) p (conn_dest v) {-# LINE 209 "Sound/Alsa/Sequencer/Marshal.hsc" #-} -- XXX: to compare these we should first normalize them data RealTime = RT { rt_secs :: !Word32 , rt_nano :: !Word32 } deriving (Show) instance Storable RealTime where sizeOf _ = (8) {-# LINE 218 "Sound/Alsa/Sequencer/Marshal.hsc" #-} alignment _ = 4 -- XXX peek p = do s <- (\hsc_ptr -> peekByteOff hsc_ptr 0) p {-# LINE 220 "Sound/Alsa/Sequencer/Marshal.hsc" #-} n <- (\hsc_ptr -> peekByteOff hsc_ptr 4) p {-# LINE 221 "Sound/Alsa/Sequencer/Marshal.hsc" #-} return RT { rt_secs = s, rt_nano = n } poke p v = (\hsc_ptr -> pokeByteOff hsc_ptr 0) p (rt_secs v) {-# LINE 223 "Sound/Alsa/Sequencer/Marshal.hsc" #-} >> (\hsc_ptr -> pokeByteOff hsc_ptr 4) p (rt_nano v) {-# LINE 224 "Sound/Alsa/Sequencer/Marshal.hsc" #-} data TimeStamp = TickTime !Word32 | RealTime !RealTime deriving Show peek_timestamp :: Word8 -> Ptr TimeStamp -> IO TimeStamp peek_timestamp flags p = case flags .&. 1 of {-# LINE 233 "Sound/Alsa/Sequencer/Marshal.hsc" #-} { 0 -> TickTime `fmap` peek (castPtr p) {-# LINE 234 "Sound/Alsa/Sequencer/Marshal.hsc" #-} ; _ -> RealTime `fmap` peek (castPtr p) } poke_timestamp :: Ptr TimeStamp -> TimeStamp -> IO Word8 poke_timestamp p ts = case ts of TickTime t -> poke (castPtr p) t >> return 0 {-# LINE 240 "Sound/Alsa/Sequencer/Marshal.hsc" #-} RealTime t -> poke (castPtr p) t >> return 1 {-# LINE 241 "Sound/Alsa/Sequencer/Marshal.hsc" #-} newtype InstrCluster = InstrCluster CUInt deriving (Show,Eq,Ord,Num,Enum,Storable) data Instr = Instr { instr_cluster :: !InstrCluster -- XXX: perhaps use Smaple? , instr_std :: !Word32 , instr_bank :: !Word16 , instr_prg :: !Word16 } deriving (Show) {- instance Storable Instr where sizeOf _ = #{size snd_seq_instr_t} alignment _ = 4 -- XXX peek p = do cl <- #{peek snd_seq_instr_t, cluster} p st <- #{peek snd_seq_instr_t, std} p ba <- #{peek snd_seq_instr_t, bank} p pr <- #{peek snd_seq_instr_t, prg} p return Instr { instr_cluster = cl , instr_std = st , instr_bank = ba , instr_prg = pr } poke p v = #{poke snd_seq_instr_t, cluster} p (instr_cluster v) >> #{poke snd_seq_instr_t, std} p (instr_std v) >> #{poke snd_seq_instr_t, bank} p (instr_bank v) >> #{poke snd_seq_instr_t, prg} p (instr_prg v) -} data Note = Note { note_channel :: !Word8 , note_note :: !Word8 , note_velocity :: !Word8 , note_off_velocity :: !Word8 , note_duration :: !Word32 } deriving (Show) instance Storable Note where sizeOf _ = (8) {-# LINE 284 "Sound/Alsa/Sequencer/Marshal.hsc" #-} alignment _ = 4 -- XXX peek p = do c <- (\hsc_ptr -> peekByteOff hsc_ptr 0) p {-# LINE 286 "Sound/Alsa/Sequencer/Marshal.hsc" #-} n <- (\hsc_ptr -> peekByteOff hsc_ptr 1) p {-# LINE 287 "Sound/Alsa/Sequencer/Marshal.hsc" #-} v <- (\hsc_ptr -> peekByteOff hsc_ptr 2) p {-# LINE 288 "Sound/Alsa/Sequencer/Marshal.hsc" #-} ov <- (\hsc_ptr -> peekByteOff hsc_ptr 3) p {-# LINE 289 "Sound/Alsa/Sequencer/Marshal.hsc" #-} d <- (\hsc_ptr -> peekByteOff hsc_ptr 4) p {-# LINE 290 "Sound/Alsa/Sequencer/Marshal.hsc" #-} return Note { note_channel = c , note_note = n , note_velocity = v , note_off_velocity = ov , note_duration = d } poke p v = (\hsc_ptr -> pokeByteOff hsc_ptr 0) p (note_channel v) {-# LINE 297 "Sound/Alsa/Sequencer/Marshal.hsc" #-} >> (\hsc_ptr -> pokeByteOff hsc_ptr 1) p (note_note v) {-# LINE 298 "Sound/Alsa/Sequencer/Marshal.hsc" #-} >> (\hsc_ptr -> pokeByteOff hsc_ptr 2) p (note_velocity v) {-# LINE 299 "Sound/Alsa/Sequencer/Marshal.hsc" #-} >> (\hsc_ptr -> pokeByteOff hsc_ptr 3) p (note_off_velocity v) {-# LINE 300 "Sound/Alsa/Sequencer/Marshal.hsc" #-} >> (\hsc_ptr -> pokeByteOff hsc_ptr 4) p (note_duration v) {-# LINE 301 "Sound/Alsa/Sequencer/Marshal.hsc" #-} data Ctrl = Ctrl { ctrl_channel :: !Word8 , ctrl_param :: !Word32 , ctrl_value :: !Int32 } deriving (Show) instance Storable Ctrl where sizeOf _ = (12) {-# LINE 310 "Sound/Alsa/Sequencer/Marshal.hsc" #-} alignment _ = 4 -- XXX peek p = do ct <- (\hsc_ptr -> peekByteOff hsc_ptr 0) p {-# LINE 312 "Sound/Alsa/Sequencer/Marshal.hsc" #-} pa <- (\hsc_ptr -> peekByteOff hsc_ptr 4) p {-# LINE 313 "Sound/Alsa/Sequencer/Marshal.hsc" #-} va <- (\hsc_ptr -> peekByteOff hsc_ptr 8) p {-# LINE 314 "Sound/Alsa/Sequencer/Marshal.hsc" #-} return Ctrl { ctrl_channel = ct , ctrl_param = pa , ctrl_value = va } poke p v = (\hsc_ptr -> pokeByteOff hsc_ptr 0) p (ctrl_channel v) {-# LINE 319 "Sound/Alsa/Sequencer/Marshal.hsc" #-} >> (\hsc_ptr -> pokeByteOff hsc_ptr 4) p (ctrl_param v) {-# LINE 320 "Sound/Alsa/Sequencer/Marshal.hsc" #-} >> (\hsc_ptr -> pokeByteOff hsc_ptr 8) p (ctrl_value v) {-# LINE 321 "Sound/Alsa/Sequencer/Marshal.hsc" #-} data Sample = Sample { sample_std :: !Word32 , sample_bank :: !Word16 , sample_prg :: !Word16 } deriving (Show) {- instance Storable Sample where sizeOf _ = #{size snd_seq_ev_sample_t} alignment _ = 4 -- XXX peek p = do st <- #{peek snd_seq_ev_sample_t, std} p ba <- #{peek snd_seq_ev_sample_t, bank} p pr <- #{peek snd_seq_ev_sample_t, prg} p return Sample { sample_std = st , sample_bank = ba , sample_prg = pr } poke p v = #{poke snd_seq_ev_sample_t, std} p (sample_std v) >> #{poke snd_seq_ev_sample_t, bank} p (sample_bank v) >> #{poke snd_seq_ev_sample_t, prg} p (sample_prg v) -} newtype Cluster = Cluster { cluster_cluster :: InstrCluster } deriving (Show,Eq,Storable) -- | These are all 14 bit values. data Volume = Volume { volume_volume :: !Int16 , volume_lr :: !Int16 , volume_fr :: !Int16 , volume_du :: !Int16 } deriving (Show) {- instance Storable Volume where sizeOf _ = #{size snd_seq_ev_volume_t} alignment _ = 4 -- XXX peek p = do v <- #{peek snd_seq_ev_volume_t, volume} p l <- #{peek snd_seq_ev_volume_t, lr} p f <- #{peek snd_seq_ev_volume_t, fr} p d <- #{peek snd_seq_ev_volume_t, du} p return Volume { volume_volume = v , volume_lr = l , volume_fr = f , volume_du = d } poke p v = #{poke snd_seq_ev_volume_t, volume} p (volume_volume v) >> #{poke snd_seq_ev_volume_t, lr} p (volume_lr v) >> #{poke snd_seq_ev_volume_t, fr} p (volume_fr v) >> #{poke snd_seq_ev_volume_t, du} p (volume_du v) -} data Event = Event { ev_high_priority :: !Bool , ev_tag :: !Word8 , ev_queue :: !Queue , ev_timestamp :: !TimeStamp , ev_source :: !Addr , ev_dest :: !Addr , ev_data :: !EventData } deriving Show instance Storable Event where sizeOf _ = (28) {-# LINE 388 "Sound/Alsa/Sequencer/Marshal.hsc" #-} alignment _ = 4 -- XXX peek p = do ty <- (\hsc_ptr -> peekByteOff hsc_ptr 0) p {-# LINE 391 "Sound/Alsa/Sequencer/Marshal.hsc" #-} flags <- (\hsc_ptr -> peekByteOff hsc_ptr 1) p {-# LINE 392 "Sound/Alsa/Sequencer/Marshal.hsc" #-} tag <- (\hsc_ptr -> peekByteOff hsc_ptr 2) p {-# LINE 393 "Sound/Alsa/Sequencer/Marshal.hsc" #-} q <- (\hsc_ptr -> peekByteOff hsc_ptr 3) p {-# LINE 394 "Sound/Alsa/Sequencer/Marshal.hsc" #-} time <- peek_timestamp flags ((\hsc_ptr -> hsc_ptr `plusPtr` 4) p) {-# LINE 395 "Sound/Alsa/Sequencer/Marshal.hsc" #-} src <- (\hsc_ptr -> peekByteOff hsc_ptr 12) p {-# LINE 396 "Sound/Alsa/Sequencer/Marshal.hsc" #-} dest <- (\hsc_ptr -> peekByteOff hsc_ptr 14) p {-# LINE 397 "Sound/Alsa/Sequencer/Marshal.hsc" #-} d <- (peek_event_data ! ty) ((\hsc_ptr -> hsc_ptr `plusPtr` 16) p) {-# LINE 398 "Sound/Alsa/Sequencer/Marshal.hsc" #-} return Event { ev_high_priority = (flags .&. 16) /= 0 {-# LINE 400 "Sound/Alsa/Sequencer/Marshal.hsc" #-} , ev_tag = tag , ev_queue = q , ev_timestamp = time , ev_source = src , ev_dest = dest , ev_data = d } poke p e = do { ty <- poke_event_data ((\hsc_ptr -> hsc_ptr `plusPtr` 16) p) (ev_data e) {-# LINE 409 "Sound/Alsa/Sequencer/Marshal.hsc" #-} ; (\hsc_ptr -> pokeByteOff hsc_ptr 0) p ty {-# LINE 410 "Sound/Alsa/Sequencer/Marshal.hsc" #-} ; (\hsc_ptr -> pokeByteOff hsc_ptr 2) p (ev_tag e) {-# LINE 411 "Sound/Alsa/Sequencer/Marshal.hsc" #-} ; (\hsc_ptr -> pokeByteOff hsc_ptr 3) p (ev_queue e) {-# LINE 412 "Sound/Alsa/Sequencer/Marshal.hsc" #-} ; real <- poke_timestamp ((\hsc_ptr -> hsc_ptr `plusPtr` 4) p) (ev_timestamp e) {-# LINE 413 "Sound/Alsa/Sequencer/Marshal.hsc" #-} ; (\hsc_ptr -> pokeByteOff hsc_ptr 12) p (ev_source e) {-# LINE 414 "Sound/Alsa/Sequencer/Marshal.hsc" #-} ; (\hsc_ptr -> pokeByteOff hsc_ptr 14) p (ev_dest e) {-# LINE 415 "Sound/Alsa/Sequencer/Marshal.hsc" #-} ; let flags = (if ev_high_priority e then 16 {-# LINE 417 "Sound/Alsa/Sequencer/Marshal.hsc" #-} else 0) {-# LINE 418 "Sound/Alsa/Sequencer/Marshal.hsc" #-} .|. real .|. 0 -- XXX {-# LINE 420 "Sound/Alsa/Sequencer/Marshal.hsc" #-} ; (\hsc_ptr -> pokeByteOff hsc_ptr 1) p flags {-# LINE 421 "Sound/Alsa/Sequencer/Marshal.hsc" #-} } alloca_ev :: Event -> (Ptr Event -> IO a) -> IO a alloca_ev e h = alloca (\p -> poke p e >> h p) poke_event_data :: Ptr EventData -> EventData -> IO Word8 poke_event_data p dt = case dt of NoteEv e d -> poke (castPtr p) d >> return (exp_note_ev e) CtrlEv e d -> poke (castPtr p) d >> return (exp_ctrl_ev e) AddrEv e d -> poke (castPtr p) d >> return (exp_addr_ev e) ConnEv e d -> poke (castPtr p) d >> return (exp_conn_ev e) EmptyEv e -> return (exp_empty_ev e) peek_event_data :: Array Word8 (Ptr EventData -> IO EventData) peek_event_data = accumArray (const id) unknown (0,255) [ -- result events (2) (0, unknown) {-# LINE 439 "Sound/Alsa/Sequencer/Marshal.hsc" #-} , (1, unknown) {-# LINE 440 "Sound/Alsa/Sequencer/Marshal.hsc" #-} -- note events (4) , (5, peek_note_ev ANote) {-# LINE 443 "Sound/Alsa/Sequencer/Marshal.hsc" #-} , (6, peek_note_ev NoteOn) {-# LINE 444 "Sound/Alsa/Sequencer/Marshal.hsc" #-} , (7, peek_note_ev NoteOff) {-# LINE 445 "Sound/Alsa/Sequencer/Marshal.hsc" #-} , (8, peek_note_ev KeyPress) {-# LINE 446 "Sound/Alsa/Sequencer/Marshal.hsc" #-} -- control events (12) , (10, peek_ctrl_ev Controller) {-# LINE 449 "Sound/Alsa/Sequencer/Marshal.hsc" #-} , (11, peek_ctrl_ev PgmChange) {-# LINE 450 "Sound/Alsa/Sequencer/Marshal.hsc" #-} , (12, peek_ctrl_ev ChanPress) {-# LINE 451 "Sound/Alsa/Sequencer/Marshal.hsc" #-} , (13, peek_ctrl_ev PitchBend) {-# LINE 452 "Sound/Alsa/Sequencer/Marshal.hsc" #-} , (14, peek_ctrl_ev Control14) {-# LINE 453 "Sound/Alsa/Sequencer/Marshal.hsc" #-} , (15, peek_ctrl_ev NonRegParam) {-# LINE 454 "Sound/Alsa/Sequencer/Marshal.hsc" #-} , (16, peek_ctrl_ev RegParam) {-# LINE 455 "Sound/Alsa/Sequencer/Marshal.hsc" #-} , (20, peek_ctrl_ev SongPos) {-# LINE 456 "Sound/Alsa/Sequencer/Marshal.hsc" #-} , (21, peek_ctrl_ev SongSel) {-# LINE 457 "Sound/Alsa/Sequencer/Marshal.hsc" #-} , (22, peek_ctrl_ev QFrame) {-# LINE 458 "Sound/Alsa/Sequencer/Marshal.hsc" #-} , (23, peek_ctrl_ev TimeSign) {-# LINE 459 "Sound/Alsa/Sequencer/Marshal.hsc" #-} , (24, peek_ctrl_ev KeySign) {-# LINE 460 "Sound/Alsa/Sequencer/Marshal.hsc" #-} -- queue control (10) , (30, unknown) {-# LINE 463 "Sound/Alsa/Sequencer/Marshal.hsc" #-} , (31, unknown) {-# LINE 464 "Sound/Alsa/Sequencer/Marshal.hsc" #-} , (32, unknown) {-# LINE 465 "Sound/Alsa/Sequencer/Marshal.hsc" #-} , (33, unknown) {-# LINE 466 "Sound/Alsa/Sequencer/Marshal.hsc" #-} , (34, unknown) {-# LINE 467 "Sound/Alsa/Sequencer/Marshal.hsc" #-} , (35, unknown) {-# LINE 468 "Sound/Alsa/Sequencer/Marshal.hsc" #-} , (36, unknown) {-# LINE 469 "Sound/Alsa/Sequencer/Marshal.hsc" #-} , (37, unknown) {-# LINE 470 "Sound/Alsa/Sequencer/Marshal.hsc" #-} , (38, unknown) {-# LINE 471 "Sound/Alsa/Sequencer/Marshal.hsc" #-} , (39, unknown) {-# LINE 472 "Sound/Alsa/Sequencer/Marshal.hsc" #-} -- misc (3) , (40, peek_empty_ev TuneRequest) {-# LINE 475 "Sound/Alsa/Sequencer/Marshal.hsc" #-} , (41, peek_empty_ev Reset) {-# LINE 476 "Sound/Alsa/Sequencer/Marshal.hsc" #-} , (42, peek_empty_ev Sensing) {-# LINE 477 "Sound/Alsa/Sequencer/Marshal.hsc" #-} , (50, unknown) {-# LINE 479 "Sound/Alsa/Sequencer/Marshal.hsc" #-} , (51, unknown) {-# LINE 480 "Sound/Alsa/Sequencer/Marshal.hsc" #-} -- networking (8) , (60, peek_addr_ev ClientStart) {-# LINE 483 "Sound/Alsa/Sequencer/Marshal.hsc" #-} , (61, peek_addr_ev ClientExit) {-# LINE 484 "Sound/Alsa/Sequencer/Marshal.hsc" #-} , (62, peek_addr_ev ClientChange) {-# LINE 485 "Sound/Alsa/Sequencer/Marshal.hsc" #-} , (63, peek_addr_ev PortStart) {-# LINE 486 "Sound/Alsa/Sequencer/Marshal.hsc" #-} , (64, peek_addr_ev PortExit) {-# LINE 487 "Sound/Alsa/Sequencer/Marshal.hsc" #-} , (65, peek_addr_ev PortChange) {-# LINE 488 "Sound/Alsa/Sequencer/Marshal.hsc" #-} , (66, peek_conn_ev PortSubscribed) {-# LINE 489 "Sound/Alsa/Sequencer/Marshal.hsc" #-} , (67, peek_conn_ev PortUnsubscribed) {-# LINE 490 "Sound/Alsa/Sequencer/Marshal.hsc" #-} {- , (#{const SND_SEQ_EVENT_SAMPLE}, unknown) , (#{const SND_SEQ_EVENT_SAMPLE_CLUSTER}, unknown) , (#{const SND_SEQ_EVENT_SAMPLE_START}, unknown) , (#{const SND_SEQ_EVENT_SAMPLE_STOP}, unknown) , (#{const SND_SEQ_EVENT_SAMPLE_FREQ}, unknown) , (#{const SND_SEQ_EVENT_SAMPLE_VOLUME}, unknown) , (#{const SND_SEQ_EVENT_SAMPLE_LOOP}, unknown) , (#{const SND_SEQ_EVENT_SAMPLE_POSITION}, unknown) , (#{const SND_SEQ_EVENT_SAMPLE_PRIVATE1}, unknown) -} , (90, unknown) {-# LINE 503 "Sound/Alsa/Sequencer/Marshal.hsc" #-} , (91, unknown) {-# LINE 504 "Sound/Alsa/Sequencer/Marshal.hsc" #-} , (92, unknown) {-# LINE 505 "Sound/Alsa/Sequencer/Marshal.hsc" #-} , (93, unknown) {-# LINE 506 "Sound/Alsa/Sequencer/Marshal.hsc" #-} , (94, unknown) {-# LINE 507 "Sound/Alsa/Sequencer/Marshal.hsc" #-} , (95, unknown) {-# LINE 508 "Sound/Alsa/Sequencer/Marshal.hsc" #-} , (96, unknown) {-# LINE 509 "Sound/Alsa/Sequencer/Marshal.hsc" #-} , (97, unknown) {-# LINE 510 "Sound/Alsa/Sequencer/Marshal.hsc" #-} , (98, unknown) {-# LINE 511 "Sound/Alsa/Sequencer/Marshal.hsc" #-} , (99, unknown) {-# LINE 512 "Sound/Alsa/Sequencer/Marshal.hsc" #-} {- , (#{const SND_SEQ_EVENT_INSTR_BEGIN}, unknown) , (#{const SND_SEQ_EVENT_INSTR_END}, unknown) , (#{const SND_SEQ_EVENT_INSTR_INFO}, unknown) , (#{const SND_SEQ_EVENT_INSTR_INFO_RESULT}, unknown) , (#{const SND_SEQ_EVENT_INSTR_FINFO}, unknown) , (#{const SND_SEQ_EVENT_INSTR_FINFO_RESULT}, unknown) , (#{const SND_SEQ_EVENT_INSTR_RESET}, unknown) , (#{const SND_SEQ_EVENT_INSTR_STATUS}, unknown) , (#{const SND_SEQ_EVENT_INSTR_STATUS_RESULT}, unknown) , (#{const SND_SEQ_EVENT_INSTR_PUT}, unknown) , (#{const SND_SEQ_EVENT_INSTR_GET}, unknown) , (#{const SND_SEQ_EVENT_INSTR_GET_RESULT}, unknown) , (#{const SND_SEQ_EVENT_INSTR_FREE}, unknown) , (#{const SND_SEQ_EVENT_INSTR_LIST}, unknown) , (#{const SND_SEQ_EVENT_INSTR_LIST_RESULT}, unknown) , (#{const SND_SEQ_EVENT_INSTR_CLUSTER}, unknown) , (#{const SND_SEQ_EVENT_INSTR_CLUSTER_GET}, unknown) , (#{const SND_SEQ_EVENT_INSTR_CLUSTER_RESULT}, unknown) , (#{const SND_SEQ_EVENT_INSTR_CHANGE}, unknown) -} , (130, unknown) {-# LINE 536 "Sound/Alsa/Sequencer/Marshal.hsc" #-} , (131, unknown) {-# LINE 537 "Sound/Alsa/Sequencer/Marshal.hsc" #-} , (135, unknown) {-# LINE 539 "Sound/Alsa/Sequencer/Marshal.hsc" #-} , (136, unknown) {-# LINE 540 "Sound/Alsa/Sequencer/Marshal.hsc" #-} , (137, unknown) {-# LINE 541 "Sound/Alsa/Sequencer/Marshal.hsc" #-} , (138, unknown) {-# LINE 542 "Sound/Alsa/Sequencer/Marshal.hsc" #-} , (138, unknown) {-# LINE 543 "Sound/Alsa/Sequencer/Marshal.hsc" #-} , (255, peek_empty_ev None) {-# LINE 545 "Sound/Alsa/Sequencer/Marshal.hsc" #-} ] where unknown = peek_empty_ev Unknown data NoteEv = ANote | NoteOn | NoteOff | KeyPress deriving Show data CtrlEv = Controller | PgmChange | ChanPress | PitchBend | Control14 | NonRegParam | RegParam | SongPos | SongSel | QFrame | TimeSign | KeySign deriving Show data EmptyEv = TuneRequest | Reset | Sensing | None | Unknown deriving Show data AddrEv = ClientStart | ClientExit | ClientChange | PortStart | PortExit | PortChange deriving Show data ConnEv = PortSubscribed | PortUnsubscribed deriving Show exp_note_ev :: NoteEv -> Word8 exp_note_ev e = case e of ANote -> 5 {-# LINE 575 "Sound/Alsa/Sequencer/Marshal.hsc" #-} NoteOn -> 6 {-# LINE 576 "Sound/Alsa/Sequencer/Marshal.hsc" #-} NoteOff -> 7 {-# LINE 577 "Sound/Alsa/Sequencer/Marshal.hsc" #-} KeyPress -> 8 {-# LINE 578 "Sound/Alsa/Sequencer/Marshal.hsc" #-} exp_ctrl_ev :: CtrlEv -> Word8 exp_ctrl_ev e = case e of Controller -> 10 {-# LINE 582 "Sound/Alsa/Sequencer/Marshal.hsc" #-} PgmChange -> 11 {-# LINE 583 "Sound/Alsa/Sequencer/Marshal.hsc" #-} ChanPress -> 12 {-# LINE 584 "Sound/Alsa/Sequencer/Marshal.hsc" #-} PitchBend -> 13 {-# LINE 585 "Sound/Alsa/Sequencer/Marshal.hsc" #-} Control14 -> 14 {-# LINE 586 "Sound/Alsa/Sequencer/Marshal.hsc" #-} NonRegParam -> 15 {-# LINE 587 "Sound/Alsa/Sequencer/Marshal.hsc" #-} RegParam -> 16 {-# LINE 588 "Sound/Alsa/Sequencer/Marshal.hsc" #-} SongPos -> 20 {-# LINE 589 "Sound/Alsa/Sequencer/Marshal.hsc" #-} SongSel -> 21 {-# LINE 590 "Sound/Alsa/Sequencer/Marshal.hsc" #-} QFrame -> 22 {-# LINE 591 "Sound/Alsa/Sequencer/Marshal.hsc" #-} TimeSign -> 23 {-# LINE 592 "Sound/Alsa/Sequencer/Marshal.hsc" #-} KeySign -> 24 {-# LINE 593 "Sound/Alsa/Sequencer/Marshal.hsc" #-} exp_empty_ev :: EmptyEv -> Word8 exp_empty_ev e = case e of TuneRequest -> 40 {-# LINE 597 "Sound/Alsa/Sequencer/Marshal.hsc" #-} Reset -> 41 {-# LINE 598 "Sound/Alsa/Sequencer/Marshal.hsc" #-} Sensing -> 42 {-# LINE 599 "Sound/Alsa/Sequencer/Marshal.hsc" #-} None -> 255 {-# LINE 600 "Sound/Alsa/Sequencer/Marshal.hsc" #-} Unknown -> 255 {-# LINE 601 "Sound/Alsa/Sequencer/Marshal.hsc" #-} exp_addr_ev :: AddrEv -> Word8 exp_addr_ev e = case e of ClientStart -> 60 {-# LINE 605 "Sound/Alsa/Sequencer/Marshal.hsc" #-} ClientExit -> 61 {-# LINE 606 "Sound/Alsa/Sequencer/Marshal.hsc" #-} ClientChange -> 62 {-# LINE 607 "Sound/Alsa/Sequencer/Marshal.hsc" #-} PortStart -> 63 {-# LINE 608 "Sound/Alsa/Sequencer/Marshal.hsc" #-} PortExit -> 64 {-# LINE 609 "Sound/Alsa/Sequencer/Marshal.hsc" #-} PortChange -> 65 {-# LINE 610 "Sound/Alsa/Sequencer/Marshal.hsc" #-} exp_conn_ev :: ConnEv -> Word8 exp_conn_ev e = case e of PortSubscribed -> 66 {-# LINE 614 "Sound/Alsa/Sequencer/Marshal.hsc" #-} PortUnsubscribed -> 67 {-# LINE 615 "Sound/Alsa/Sequencer/Marshal.hsc" #-} peek_note_ev :: NoteEv -> Ptr EventData -> IO EventData peek_note_ev e p = NoteEv e `fmap` peek (castPtr p) peek_ctrl_ev :: CtrlEv -> Ptr EventData -> IO EventData peek_ctrl_ev e p = CtrlEv e `fmap` peek (castPtr p) peek_addr_ev :: AddrEv -> Ptr EventData -> IO EventData peek_addr_ev e p = AddrEv e `fmap` peek (castPtr p) peek_conn_ev :: ConnEv -> Ptr EventData -> IO EventData peek_conn_ev e p = ConnEv e `fmap` peek (castPtr p) peek_empty_ev :: EmptyEv -> Ptr EventData -> IO EventData peek_empty_ev e _ = return (EmptyEv e) data EventData = NoteEv NoteEv Note | CtrlEv CtrlEv Ctrl | AddrEv AddrEv Addr | ConnEv ConnEv Connect | EmptyEv EmptyEv deriving Show