Coverage for linuxpy/midi/raw.py: 100%
283 statements
« prev ^ index » next coverage.py v7.10.4, created at 2026-02-19 15:11 +0100
« prev ^ index » next coverage.py v7.10.4, created at 2026-02-19 15:11 +0100
1#
2# This file is part of the linuxpy project
3#
4# Copyright (c) 2023 Tiago Coutinho
5# Distributed under the GPLv3 license. See LICENSE for more info.
7# This file has been generated by __main__
8# Date: 2023-11-07 06:37:12.044793
9# System: Linux
10# Release: 6.2.0-36-generic
11# Version: #37~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Mon Oct 9 15:34:04 UTC 2
13import enum
15from linuxpy.ctypes import POINTER, Struct, Union, cchar, cint, cuint, cvoidp, u8, u16
16from linuxpy.ioctl import IOR as _IOR, IOW as _IOW, IOWR as _IOWR
19class ClientType(enum.IntEnum):
20 NO_CLIENT = 0
21 USER = 1
22 KERNEL = 2
25class EventLength(enum.IntEnum):
26 FIXED = 0 << 2 # fixed event size
27 VARIABLE = 1 << 2 # variable event size
28 VARUSR = 2 << 2 # variable event size - user memory space
29 MASK = 3 << 2
32class TimeStamp(enum.IntFlag):
33 TICK = 0 << 0 # timestamp in clock ticks
34 REAL = 1 << 0 # timestamp in real time
35 MASK = 1 << 0
38class TimeMode(enum.IntFlag):
39 ABS = 0 << 1 # absolute timestamp
40 REL = 1 << 1 # relative to current time
41 MASK = 1 << 1
44class Priority(enum.IntFlag):
45 NORMAL = 0 << 4 # normal priority
46 HIGH = 1 << 4 # event should be processed before others
47 MASK = 1 << 4
50class EventType(enum.IntEnum):
51 SYSTEM = 0x0
52 RESULT = 0x1
53 NOTE = 0x5
54 NOTEON = 0x6
55 NOTEOFF = 0x7
56 KEYPRESS = 0x8
57 CONTROLLER = 0xA
58 PGMCHANGE = 0xB
59 CHANPRESS = 0xC
60 PITCHBEND = 13 # *< from -8192 to 8191
61 CONTROL14 = 14 # *< 14 bit controller value
62 NONREGPARAM = 15 # *< 14 bit NRPN address + 14 bit unsigned value
63 REGPARAM = 16 # *< 14 bit RPN address + 14 bit unsigned value
64 SONGPOS = 20 # Song Position Pointer with LSB and MSB values
65 SONGSEL = 21 # Song Select with song ID number
66 QFRAME = 22 # midi time code quarter frame
67 TIMESIGN = 23 # SMF Time Signature event
68 KEYSIGN = 24 # SMF Key Signature event
69 START = 30 # midi Real Time Start message
70 CONTINUE = 31 # midi Real Time Continue message
71 STOP = 32 # midi Real Time Stop message
72 SETPOS_TICK = 33 # set tick queue position
73 SETPOS_TIME = 34 # set realtime queue position
74 TEMPO = 35 # (SMF) Tempo event
75 CLOCK = 36 # midi Real Time Clock message
76 TICK = 37 # midi Real Time Tick message
77 QUEUE_SKEW = 38 # skew queue tempo
78 TUNE_REQUEST = 40 # tune request
79 RESET = 41 # reset to power-on state
80 SENSING = 42 # "active sensing" event
81 ECHO = 50 # echo event
82 OSS = 51 # OSS raw event
83 CLIENT_START = 60 # new client has connected
84 CLIENT_EXIT = 61 # client has left the system
85 CLIENT_CHANGE = 62 # client status/info has changed
86 PORT_START = 63 # new port was created
87 PORT_EXIT = 64 # port was deleted from system
88 PORT_CHANGE = 65 # port status/info has changed
89 PORT_SUBSCRIBED = 66 # ports connected
90 PORT_UNSUBSCRIBED = 67 # ports disconnected
91 USR0 = 0x5A
92 USR1 = 0x5B
93 USR2 = 0x5C
94 USR3 = 0x5D
95 USR4 = 0x5E
96 USR5 = 0x5F
97 USR6 = 0x60
98 USR7 = 0x61
99 USR8 = 0x62
100 USR9 = 0x63
101 SYSEX = 130 # system exclusive data (variable length)
102 BOUNCE = 131 # error event
103 USR_VAR0 = 0x87
104 USR_VAR1 = 0x88
105 USR_VAR2 = 0x89
106 USR_VAR3 = 0x8A
107 USR_VAR4 = 0x8B
108 KERNEL_ERROR = 0x96
109 KERNEL_QUOTE = 151 # obsolete
110 NONE = 0xFF
113class ClientNumber(enum.IntEnum):
114 SYSTEM = 0x0
115 DUMMY = 14 # midi through
116 OSS = 15 # oss sequencer emulator
119class Filter(enum.IntFlag):
120 BROADCAST = 1 << 0 # accept broadcast messages
121 MULTICAST = 1 << 1 # accept multicast messages
122 BOUNCE = 1 << 2 # accept bounce event in error
123 USE_EVENT = 1 << 31 # use event filter
126class Remove(enum.IntFlag):
127 INPUT = 1 << 0 # Flush input queues
128 OUTPUT = 1 << 1 # Flush output queues
129 DEST = 1 << 2 # Restrict by destination q:client:port
130 DEST_CHANNEL = 1 << 3 # Restrict by channel
131 TIME_BEFORE = 1 << 4 # Restrict to before time
132 TIME_AFTER = 1 << 5 # Restrict to time or after
133 TIME_TICK = 1 << 6 # Time is in ticks
134 EVENT_TYPE = 1 << 7 # Restrict to event type
135 IGNORE_OFF = 1 << 8 # Do not flush off events
136 TAG_MATCH = 1 << 9 # Restrict to events with given tag
139class PortSystem(enum.IntFlag):
140 TIMER = 0x0
141 ANNOUNCE = 0x1
144class PortCapability(enum.IntFlag):
145 READ = 1 << 0 # readable from this port
146 WRITE = 1 << 1 # writable to this port
147 SYNC_READ = 1 << 2
148 SYNC_WRITE = 1 << 3
149 DUPLEX = 1 << 4
150 SUBS_READ = 1 << 5 # allow read subscription
151 SUBS_WRITE = 1 << 6 # allow write subscription
152 NO_EXPORT = 1 << 7 # routing not allowed
155class PortType(enum.IntFlag):
156 SPECIFIC = 1 << 0 # hardware specific
157 MIDI_GENERIC = 1 << 1 # generic MIDI device
158 MIDI_GM = 1 << 2 # General MIDI compatible device
159 MIDI_GS = 1 << 3 # GS compatible device
160 MIDI_XG = 1 << 4 # XG compatible device
161 MIDI_MT32 = 1 << 5 # MT-32 compatible device
162 MIDI_GM2 = 1 << 6 # General MIDI 2 compatible device
163 SYNTH = 1 << 10 # Synth device (no MIDI compatible - direct wavetable)
164 DIRECT_SAMPLE = 1 << 11 # Sampling device (support sample download)
165 SAMPLE = 1 << 12 # Sampling device (sample can be downloaded at any time)
166 HARDWARE = 1 << 16 # driver for a hardware device
167 SOFTWARE = 1 << 17 # implemented in software
168 SYNTHESIZER = 1 << 18 # generates sound
169 PORT = 1 << 19 # connects to other device(s)
170 APPLICATION = 1 << 20 # application (sequencer/editor)
173class PortFlag(enum.IntFlag):
174 GIVEN_PORT = 1 << 0
175 TIMESTAMP = 1 << 1
176 TIME_REAL = 1 << 2
179class QueueFlga(enum.IntFlag):
180 SYNC = 1 << 0 # sync enabled
183class Timer(enum.IntEnum):
184 ALSA = 0 # ALSA timer
185 MIDI_CLOCK = 1 # Midi Clock (CLOCK event)
186 MIDI_TICK = 2 # Midi Timer Tick (TICK event)
189class QuerySubscription(enum.IntEnum):
190 READ = 0x0
191 WRITE = 0x1
194snd_seq_tick_time_t = cuint
197class snd_seq_real_time(Struct):
198 _fields_ = [
199 ("tv_sec", cuint),
200 ("tv_nsec", cuint),
201 ]
204# It's a Union so not automatically generated
205class snd_seq_timestamp(Union):
206 _fields_ = [
207 ("tick", snd_seq_tick_time_t),
208 ("time", snd_seq_real_time),
209 ]
212# Defined in /usr/include/sound/asound.h
213class snd_timer_id(Struct):
214 _fields_ = [
215 ("dev_class", cint),
216 ("dev_sclass", cint),
217 ("card", cint),
218 ("device", cint),
219 ("subdevice", cint),
220 ]
223class snd_seq_addr(Struct):
224 _pack_ = True
225 _layout_ = "ms"
228snd_seq_addr._fields_ = [("client", u8), ("port", u8)]
231class snd_seq_connect(Struct):
232 _pack_ = True
233 _layout_ = "ms"
236snd_seq_connect._fields_ = [("sender", snd_seq_addr), ("dest", snd_seq_addr)]
239class snd_seq_ev_note(Struct):
240 pass
243snd_seq_ev_note._fields_ = [
244 ("channel", u8),
245 ("note", u8),
246 ("velocity", u8),
247 ("off_velocity", u8),
248 ("duration", cuint),
249]
252class snd_seq_ev_ctrl(Struct):
253 pass
256snd_seq_ev_ctrl._fields_ = [
257 ("channel", u8),
258 ("unused1", u8),
259 ("unused2", u8),
260 ("unused3", u8),
261 ("param", cuint),
262 ("value", cint),
263]
266class snd_seq_ev_raw8(Struct):
267 _pack_ = True
268 _layout_ = "ms"
271snd_seq_ev_raw8._fields_ = [("d", cchar * 12)]
274class snd_seq_ev_raw32(Struct):
275 pass
278snd_seq_ev_raw32._fields_ = [("d", cuint * 3)]
281class snd_seq_ev_ext(Struct):
282 _pack_ = True
283 _layout_ = "ms"
286snd_seq_ev_ext._fields_ = [("len", cuint), ("ptr", cvoidp)]
289class snd_seq_result(Struct):
290 pass
293snd_seq_result._fields_ = [("event", cint), ("result", cint)]
296class snd_seq_real_time(Struct):
297 pass
300snd_seq_real_time._fields_ = [("tv_sec", cuint), ("tv_nsec", cuint)]
303class snd_seq_queue_skew(Struct):
304 pass
307snd_seq_queue_skew._fields_ = [("value", cuint), ("base", cuint)]
310class snd_seq_ev_queue_control(Struct):
311 class M1(Union):
312 pass
314 M1._fields_ = [
315 ("value", cint),
316 ("time", snd_seq_timestamp),
317 ("position", cuint),
318 ("skew", snd_seq_queue_skew),
319 ("d32", cuint * 2),
320 ("d8", cchar * 8),
321 ]
324snd_seq_ev_queue_control._fields_ = [
325 ("queue", u8),
326 ("pad", cchar * 3),
327 ("param", snd_seq_ev_queue_control.M1),
328]
331class snd_seq_ev_quote(Struct):
332 _pack_ = True
333 _layout_ = "ms"
336class snd_seq_event(Struct):
337 class M1(Union):
338 pass
341snd_seq_ev_quote._fields_ = [
342 ("origin", snd_seq_addr),
343 ("value", u16),
344 ("event", POINTER(snd_seq_event)),
345]
348snd_seq_event.M1._fields_ = [
349 ("note", snd_seq_ev_note),
350 ("control", snd_seq_ev_ctrl),
351 ("raw8", snd_seq_ev_raw8),
352 ("raw32", snd_seq_ev_raw32),
353 ("ext", snd_seq_ev_ext),
354 ("queue", snd_seq_ev_queue_control),
355 ("time", snd_seq_timestamp),
356 ("addr", snd_seq_addr),
357 ("connect", snd_seq_connect),
358 ("result", snd_seq_result),
359 ("quote", snd_seq_ev_quote),
360]
363snd_seq_event._fields_ = [
364 ("type", u8),
365 ("flags", u8),
366 ("tag", cchar),
367 ("queue", u8),
368 ("time", snd_seq_timestamp),
369 ("source", snd_seq_addr),
370 ("dest", snd_seq_addr),
371 ("data", snd_seq_event.M1),
372]
375class snd_seq_event_bounce(Struct):
376 pass
379snd_seq_event_bounce._fields_ = [("err", cint), ("event", snd_seq_event)]
382class snd_seq_system_info(Struct):
383 pass
386snd_seq_system_info._fields_ = [
387 ("queues", cint),
388 ("clients", cint),
389 ("ports", cint),
390 ("channels", cint),
391 ("cur_clients", cint),
392 ("cur_queues", cint),
393 ("reserved", cchar * 24),
394]
397class snd_seq_running_info(Struct):
398 _pack_ = True
399 _layout_ = "ms"
402snd_seq_running_info._fields_ = [
403 ("client", u8),
404 ("big_endian", u8),
405 ("cpu_mode", u8),
406 ("pad", u8),
407 ("reserved", cchar * 12),
408]
411class snd_seq_client_info(Struct):
412 pass
415snd_seq_client_info._fields_ = [
416 ("client", cint),
417 ("type", cint),
418 ("name", cchar * 64),
419 ("filter", cuint),
420 ("multicast_filter", cchar * 8),
421 ("event_filter", cchar * 32),
422 ("num_ports", cint),
423 ("event_lost", cint),
424 ("card", cint),
425 ("pid", cint),
426 ("reserved", cchar * 56),
427]
430class snd_seq_client_pool(Struct):
431 pass
434snd_seq_client_pool._fields_ = [
435 ("client", cint),
436 ("output_pool", cint),
437 ("input_pool", cint),
438 ("output_room", cint),
439 ("output_free", cint),
440 ("input_free", cint),
441 ("reserved", cchar * 64),
442]
445class snd_seq_remove_events(Struct):
446 pass
449snd_seq_remove_events._fields_ = [
450 ("remove_mode", cuint),
451 ("time", snd_seq_timestamp),
452 ("queue", u8),
453 ("dest", snd_seq_addr),
454 ("channel", u8),
455 ("type", cint),
456 ("tag", cchar),
457 ("reserved", cint * 10),
458]
461class snd_seq_port_info(Struct):
462 pass
465snd_seq_port_info._fields_ = [
466 ("addr", snd_seq_addr),
467 ("name", cchar * 64),
468 ("capability", cuint),
469 ("type", cuint),
470 ("midi_channels", cint),
471 ("midi_voices", cint),
472 ("synth_voices", cint),
473 ("read_use", cint),
474 ("write_use", cint),
475 ("kernel", POINTER(None)),
476 ("flags", cuint),
477 ("time_queue", u8),
478 ("reserved", cchar * 59),
479]
482class snd_seq_queue_info(Struct):
483 pass
486snd_seq_queue_info._fields_ = [
487 ("queue", cint),
488 ("owner", cint),
489 ("locked", cuint),
490 ("name", cchar * 64),
491 ("flags", cuint),
492 ("reserved", cchar * 60),
493]
496class snd_seq_queue_status(Struct):
497 pass
500snd_seq_queue_status._fields_ = [
501 ("queue", cint),
502 ("events", cint),
503 ("tick", cuint),
504 ("time", snd_seq_real_time),
505 ("running", cint),
506 ("flags", cint),
507 ("reserved", cchar * 64),
508]
511class snd_seq_queue_tempo(Struct):
512 pass
515snd_seq_queue_tempo._fields_ = [
516 ("queue", cint),
517 ("tempo", cuint),
518 ("ppq", cint),
519 ("skew_value", cuint),
520 ("skew_base", cuint),
521 ("reserved", cchar * 24),
522]
525class snd_seq_queue_timer(Struct):
526 class M1(Union):
527 class M1(Struct):
528 pass
530 M1._fields_ = [("id", snd_timer_id), ("resolution", cuint)]
532 M1._fields_ = [("alsa", M1.M1)]
535snd_seq_queue_timer._fields_ = [
536 ("queue", cint),
537 ("type", cint),
538 ("u", snd_seq_queue_timer.M1),
539 ("reserved", cchar * 64),
540]
543class snd_seq_queue_client(Struct):
544 pass
547snd_seq_queue_client._fields_ = [
548 ("queue", cint),
549 ("client", cint),
550 ("used", cint),
551 ("reserved", cchar * 64),
552]
555class snd_seq_port_subscribe(Struct):
556 pass
559snd_seq_port_subscribe._fields_ = [
560 ("sender", snd_seq_addr),
561 ("dest", snd_seq_addr),
562 ("voices", cuint),
563 ("flags", cuint),
564 ("queue", u8),
565 ("pad", cchar * 3),
566 ("reserved", cchar * 64),
567]
570class snd_seq_query_subs(Struct):
571 pass
574snd_seq_query_subs._fields_ = [
575 ("root", snd_seq_addr),
576 ("type", cint),
577 ("index", cint),
578 ("num_subs", cint),
579 ("addr", snd_seq_addr),
580 ("queue", u8),
581 ("flags", cuint),
582 ("reserved", cchar * 64),
583]
586class snd_seq_timestamp(Union):
587 pass
590snd_seq_timestamp._fields_ = [("tick", cuint), ("time", snd_seq_real_time)]
593class IOC(enum.IntEnum):
594 PVERSION = _IOR("S", 0x00, cint)
595 CLIENT_ID = _IOR("S", 0x01, cint)
596 SYSTEM_INFO = _IOWR("S", 0x02, snd_seq_system_info)
597 RUNNING_MODE = _IOWR("S", 0x03, snd_seq_running_info)
598 GET_CLIENT_INFO = _IOWR("S", 0x10, snd_seq_client_info)
599 SET_CLIENT_INFO = _IOW("S", 0x11, snd_seq_client_info)
600 CREATE_PORT = _IOWR("S", 0x20, snd_seq_port_info)
601 DELETE_PORT = _IOW("S", 0x21, snd_seq_port_info)
602 GET_PORT_INFO = _IOWR("S", 0x22, snd_seq_port_info)
603 SET_PORT_INFO = _IOW("S", 0x23, snd_seq_port_info)
604 SUBSCRIBE_PORT = _IOW("S", 0x30, snd_seq_port_subscribe)
605 UNSUBSCRIBE_PORT = _IOW("S", 0x31, snd_seq_port_subscribe)
606 CREATE_QUEUE = _IOWR("S", 0x32, snd_seq_queue_info)
607 DELETE_QUEUE = _IOW("S", 0x33, snd_seq_queue_info)
608 GET_QUEUE_INFO = _IOWR("S", 0x34, snd_seq_queue_info)
609 SET_QUEUE_INFO = _IOWR("S", 0x35, snd_seq_queue_info)
610 GET_NAMED_QUEUE = _IOWR("S", 0x36, snd_seq_queue_info)
611 GET_QUEUE_STATUS = _IOWR("S", 0x40, snd_seq_queue_status)
612 GET_QUEUE_TEMPO = _IOWR("S", 0x41, snd_seq_queue_tempo)
613 SET_QUEUE_TEMPO = _IOW("S", 0x42, snd_seq_queue_tempo)
614 GET_QUEUE_TIMER = _IOWR("S", 0x45, snd_seq_queue_timer)
615 SET_QUEUE_TIMER = _IOW("S", 0x46, snd_seq_queue_timer)
616 GET_QUEUE_CLIENT = _IOWR("S", 0x49, snd_seq_queue_client)
617 SET_QUEUE_CLIENT = _IOW("S", 0x4A, snd_seq_queue_client)
618 GET_CLIENT_POOL = _IOWR("S", 0x4B, snd_seq_client_pool)
619 SET_CLIENT_POOL = _IOW("S", 0x4C, snd_seq_client_pool)
620 REMOVE_EVENTS = _IOW("S", 0x4E, snd_seq_remove_events)
621 QUERY_SUBS = _IOWR("S", 0x4F, snd_seq_query_subs)
622 GET_SUBSCRIPTION = _IOWR("S", 0x50, snd_seq_port_subscribe)
623 QUERY_NEXT_CLIENT = _IOWR("S", 0x51, snd_seq_client_info)
624 QUERY_NEXT_PORT = _IOWR("S", 0x52, snd_seq_port_info)