Coverage for linuxpy/midi/raw.py: 100%

277 statements  

« prev     ^ index     » next       coverage.py v7.6.1, created at 2024-10-18 07:40 +0200

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. 

6 

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 

12 

13import enum 

14 

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 

17 

18 

19class ClientType(enum.IntEnum): 

20 NO_CLIENT = 0 

21 USER = 1 

22 KERNEL = 2 

23 

24 

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 

30 

31 

32class TimeStamp(enum.IntFlag): 

33 TICK = 0 << 0 # timestamp in clock ticks 

34 REAL = 1 << 0 # timestamp in real time 

35 MASK = 1 << 0 

36 

37 

38class TimeMode(enum.IntFlag): 

39 ABS = 0 << 1 # absolute timestamp 

40 REL = 1 << 1 # relative to current time 

41 MASK = 1 << 1 

42 

43 

44class Priority(enum.IntFlag): 

45 NORMAL = 0 << 4 # normal priority 

46 HIGH = 1 << 4 # event should be processed before others 

47 MASK = 1 << 4 

48 

49 

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 

111 

112 

113class ClientNumber(enum.IntEnum): 

114 SYSTEM = 0x0 

115 DUMMY = 14 # midi through 

116 OSS = 15 # oss sequencer emulator 

117 

118 

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 

124 

125 

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 

137 

138 

139class PortSystem(enum.IntFlag): 

140 TIMER = 0x0 

141 ANNOUNCE = 0x1 

142 

143 

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 

153 

154 

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) 

171 

172 

173class PortFlag(enum.IntFlag): 

174 GIVEN_PORT = 1 << 0 

175 TIMESTAMP = 1 << 1 

176 TIME_REAL = 1 << 2 

177 

178 

179class QueueFlga(enum.IntFlag): 

180 SYNC = 1 << 0 # sync enabled 

181 

182 

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) 

187 

188 

189class QuerySubscription(enum.IntEnum): 

190 READ = 0x0 

191 WRITE = 0x1 

192 

193 

194snd_seq_tick_time_t = cuint 

195 

196 

197class snd_seq_real_time(Struct): 

198 _fields_ = [ 

199 ("tv_sec", cuint), 

200 ("tv_nsec", cuint), 

201 ] 

202 

203 

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 ] 

210 

211 

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 ] 

221 

222 

223class snd_seq_addr(Struct): 

224 _pack_ = True 

225 

226 

227snd_seq_addr._fields_ = [("client", u8), ("port", u8)] 

228 

229 

230class snd_seq_connect(Struct): 

231 _pack_ = True 

232 

233 

234snd_seq_connect._fields_ = [("sender", snd_seq_addr), ("dest", snd_seq_addr)] 

235 

236 

237class snd_seq_ev_note(Struct): 

238 pass 

239 

240 

241snd_seq_ev_note._fields_ = [ 

242 ("channel", u8), 

243 ("note", u8), 

244 ("velocity", u8), 

245 ("off_velocity", u8), 

246 ("duration", cuint), 

247] 

248 

249 

250class snd_seq_ev_ctrl(Struct): 

251 pass 

252 

253 

254snd_seq_ev_ctrl._fields_ = [ 

255 ("channel", u8), 

256 ("unused1", u8), 

257 ("unused2", u8), 

258 ("unused3", u8), 

259 ("param", cuint), 

260 ("value", cint), 

261] 

262 

263 

264class snd_seq_ev_raw8(Struct): 

265 _pack_ = True 

266 

267 

268snd_seq_ev_raw8._fields_ = [("d", cchar * 12)] 

269 

270 

271class snd_seq_ev_raw32(Struct): 

272 pass 

273 

274 

275snd_seq_ev_raw32._fields_ = [("d", cuint * 3)] 

276 

277 

278class snd_seq_ev_ext(Struct): 

279 _pack_ = True 

280 

281 

282snd_seq_ev_ext._fields_ = [("len", cuint), ("ptr", cvoidp)] 

283 

284 

285class snd_seq_result(Struct): 

286 pass 

287 

288 

289snd_seq_result._fields_ = [("event", cint), ("result", cint)] 

290 

291 

292class snd_seq_real_time(Struct): 

293 pass 

294 

295 

296snd_seq_real_time._fields_ = [("tv_sec", cuint), ("tv_nsec", cuint)] 

297 

298 

299class snd_seq_queue_skew(Struct): 

300 pass 

301 

302 

303snd_seq_queue_skew._fields_ = [("value", cuint), ("base", cuint)] 

304 

305 

306class snd_seq_ev_queue_control(Struct): 

307 class M1(Union): 

308 pass 

309 

310 M1._fields_ = [ 

311 ("value", cint), 

312 ("time", snd_seq_timestamp), 

313 ("position", cuint), 

314 ("skew", snd_seq_queue_skew), 

315 ("d32", cuint * 2), 

316 ("d8", cchar * 8), 

317 ] 

318 

319 

320snd_seq_ev_queue_control._fields_ = [ 

321 ("queue", u8), 

322 ("pad", cchar * 3), 

323 ("param", snd_seq_ev_queue_control.M1), 

324] 

325 

326 

327class snd_seq_ev_quote(Struct): 

328 _pack_ = True 

329 

330 

331class snd_seq_event(Struct): 

332 class M1(Union): 

333 pass 

334 

335 

336snd_seq_ev_quote._fields_ = [ 

337 ("origin", snd_seq_addr), 

338 ("value", u16), 

339 ("event", POINTER(snd_seq_event)), 

340] 

341 

342 

343snd_seq_event.M1._fields_ = [ 

344 ("note", snd_seq_ev_note), 

345 ("control", snd_seq_ev_ctrl), 

346 ("raw8", snd_seq_ev_raw8), 

347 ("raw32", snd_seq_ev_raw32), 

348 ("ext", snd_seq_ev_ext), 

349 ("queue", snd_seq_ev_queue_control), 

350 ("time", snd_seq_timestamp), 

351 ("addr", snd_seq_addr), 

352 ("connect", snd_seq_connect), 

353 ("result", snd_seq_result), 

354 ("quote", snd_seq_ev_quote), 

355] 

356 

357 

358snd_seq_event._fields_ = [ 

359 ("type", u8), 

360 ("flags", u8), 

361 ("tag", cchar), 

362 ("queue", u8), 

363 ("time", snd_seq_timestamp), 

364 ("source", snd_seq_addr), 

365 ("dest", snd_seq_addr), 

366 ("data", snd_seq_event.M1), 

367] 

368 

369 

370class snd_seq_event_bounce(Struct): 

371 pass 

372 

373 

374snd_seq_event_bounce._fields_ = [("err", cint), ("event", snd_seq_event)] 

375 

376 

377class snd_seq_system_info(Struct): 

378 pass 

379 

380 

381snd_seq_system_info._fields_ = [ 

382 ("queues", cint), 

383 ("clients", cint), 

384 ("ports", cint), 

385 ("channels", cint), 

386 ("cur_clients", cint), 

387 ("cur_queues", cint), 

388 ("reserved", cchar * 24), 

389] 

390 

391 

392class snd_seq_running_info(Struct): 

393 _pack_ = True 

394 

395 

396snd_seq_running_info._fields_ = [ 

397 ("client", u8), 

398 ("big_endian", u8), 

399 ("cpu_mode", u8), 

400 ("pad", u8), 

401 ("reserved", cchar * 12), 

402] 

403 

404 

405class snd_seq_client_info(Struct): 

406 pass 

407 

408 

409snd_seq_client_info._fields_ = [ 

410 ("client", cint), 

411 ("type", cint), 

412 ("name", cchar * 64), 

413 ("filter", cuint), 

414 ("multicast_filter", cchar * 8), 

415 ("event_filter", cchar * 32), 

416 ("num_ports", cint), 

417 ("event_lost", cint), 

418 ("card", cint), 

419 ("pid", cint), 

420 ("reserved", cchar * 56), 

421] 

422 

423 

424class snd_seq_client_pool(Struct): 

425 pass 

426 

427 

428snd_seq_client_pool._fields_ = [ 

429 ("client", cint), 

430 ("output_pool", cint), 

431 ("input_pool", cint), 

432 ("output_room", cint), 

433 ("output_free", cint), 

434 ("input_free", cint), 

435 ("reserved", cchar * 64), 

436] 

437 

438 

439class snd_seq_remove_events(Struct): 

440 pass 

441 

442 

443snd_seq_remove_events._fields_ = [ 

444 ("remove_mode", cuint), 

445 ("time", snd_seq_timestamp), 

446 ("queue", u8), 

447 ("dest", snd_seq_addr), 

448 ("channel", u8), 

449 ("type", cint), 

450 ("tag", cchar), 

451 ("reserved", cint * 10), 

452] 

453 

454 

455class snd_seq_port_info(Struct): 

456 pass 

457 

458 

459snd_seq_port_info._fields_ = [ 

460 ("addr", snd_seq_addr), 

461 ("name", cchar * 64), 

462 ("capability", cuint), 

463 ("type", cuint), 

464 ("midi_channels", cint), 

465 ("midi_voices", cint), 

466 ("synth_voices", cint), 

467 ("read_use", cint), 

468 ("write_use", cint), 

469 ("kernel", POINTER(None)), 

470 ("flags", cuint), 

471 ("time_queue", u8), 

472 ("reserved", cchar * 59), 

473] 

474 

475 

476class snd_seq_queue_info(Struct): 

477 pass 

478 

479 

480snd_seq_queue_info._fields_ = [ 

481 ("queue", cint), 

482 ("owner", cint), 

483 ("locked", cuint), 

484 ("name", cchar * 64), 

485 ("flags", cuint), 

486 ("reserved", cchar * 60), 

487] 

488 

489 

490class snd_seq_queue_status(Struct): 

491 pass 

492 

493 

494snd_seq_queue_status._fields_ = [ 

495 ("queue", cint), 

496 ("events", cint), 

497 ("tick", cuint), 

498 ("time", snd_seq_real_time), 

499 ("running", cint), 

500 ("flags", cint), 

501 ("reserved", cchar * 64), 

502] 

503 

504 

505class snd_seq_queue_tempo(Struct): 

506 pass 

507 

508 

509snd_seq_queue_tempo._fields_ = [ 

510 ("queue", cint), 

511 ("tempo", cuint), 

512 ("ppq", cint), 

513 ("skew_value", cuint), 

514 ("skew_base", cuint), 

515 ("reserved", cchar * 24), 

516] 

517 

518 

519class snd_seq_queue_timer(Struct): 

520 class M1(Union): 

521 class M1(Struct): 

522 pass 

523 

524 M1._fields_ = [("id", snd_timer_id), ("resolution", cuint)] 

525 

526 M1._fields_ = [("alsa", M1.M1)] 

527 

528 

529snd_seq_queue_timer._fields_ = [ 

530 ("queue", cint), 

531 ("type", cint), 

532 ("u", snd_seq_queue_timer.M1), 

533 ("reserved", cchar * 64), 

534] 

535 

536 

537class snd_seq_queue_client(Struct): 

538 pass 

539 

540 

541snd_seq_queue_client._fields_ = [ 

542 ("queue", cint), 

543 ("client", cint), 

544 ("used", cint), 

545 ("reserved", cchar * 64), 

546] 

547 

548 

549class snd_seq_port_subscribe(Struct): 

550 pass 

551 

552 

553snd_seq_port_subscribe._fields_ = [ 

554 ("sender", snd_seq_addr), 

555 ("dest", snd_seq_addr), 

556 ("voices", cuint), 

557 ("flags", cuint), 

558 ("queue", u8), 

559 ("pad", cchar * 3), 

560 ("reserved", cchar * 64), 

561] 

562 

563 

564class snd_seq_query_subs(Struct): 

565 pass 

566 

567 

568snd_seq_query_subs._fields_ = [ 

569 ("root", snd_seq_addr), 

570 ("type", cint), 

571 ("index", cint), 

572 ("num_subs", cint), 

573 ("addr", snd_seq_addr), 

574 ("queue", u8), 

575 ("flags", cuint), 

576 ("reserved", cchar * 64), 

577] 

578 

579 

580class snd_seq_timestamp(Union): 

581 pass 

582 

583 

584snd_seq_timestamp._fields_ = [("tick", cuint), ("time", snd_seq_real_time)] 

585 

586 

587class IOC(enum.IntEnum): 

588 PVERSION = _IOR("S", 0x00, cint) 

589 CLIENT_ID = _IOR("S", 0x01, cint) 

590 SYSTEM_INFO = _IOWR("S", 0x02, snd_seq_system_info) 

591 RUNNING_MODE = _IOWR("S", 0x03, snd_seq_running_info) 

592 GET_CLIENT_INFO = _IOWR("S", 0x10, snd_seq_client_info) 

593 SET_CLIENT_INFO = _IOW("S", 0x11, snd_seq_client_info) 

594 CREATE_PORT = _IOWR("S", 0x20, snd_seq_port_info) 

595 DELETE_PORT = _IOW("S", 0x21, snd_seq_port_info) 

596 GET_PORT_INFO = _IOWR("S", 0x22, snd_seq_port_info) 

597 SET_PORT_INFO = _IOW("S", 0x23, snd_seq_port_info) 

598 SUBSCRIBE_PORT = _IOW("S", 0x30, snd_seq_port_subscribe) 

599 UNSUBSCRIBE_PORT = _IOW("S", 0x31, snd_seq_port_subscribe) 

600 CREATE_QUEUE = _IOWR("S", 0x32, snd_seq_queue_info) 

601 DELETE_QUEUE = _IOW("S", 0x33, snd_seq_queue_info) 

602 GET_QUEUE_INFO = _IOWR("S", 0x34, snd_seq_queue_info) 

603 SET_QUEUE_INFO = _IOWR("S", 0x35, snd_seq_queue_info) 

604 GET_NAMED_QUEUE = _IOWR("S", 0x36, snd_seq_queue_info) 

605 GET_QUEUE_STATUS = _IOWR("S", 0x40, snd_seq_queue_status) 

606 GET_QUEUE_TEMPO = _IOWR("S", 0x41, snd_seq_queue_tempo) 

607 SET_QUEUE_TEMPO = _IOW("S", 0x42, snd_seq_queue_tempo) 

608 GET_QUEUE_TIMER = _IOWR("S", 0x45, snd_seq_queue_timer) 

609 SET_QUEUE_TIMER = _IOW("S", 0x46, snd_seq_queue_timer) 

610 GET_QUEUE_CLIENT = _IOWR("S", 0x49, snd_seq_queue_client) 

611 SET_QUEUE_CLIENT = _IOW("S", 0x4A, snd_seq_queue_client) 

612 GET_CLIENT_POOL = _IOWR("S", 0x4B, snd_seq_client_pool) 

613 SET_CLIENT_POOL = _IOW("S", 0x4C, snd_seq_client_pool) 

614 REMOVE_EVENTS = _IOW("S", 0x4E, snd_seq_remove_events) 

615 QUERY_SUBS = _IOWR("S", 0x4F, snd_seq_query_subs) 

616 GET_SUBSCRIPTION = _IOWR("S", 0x50, snd_seq_port_subscribe) 

617 QUERY_NEXT_CLIENT = _IOWR("S", 0x51, snd_seq_client_info) 

618 QUERY_NEXT_PORT = _IOWR("S", 0x52, snd_seq_port_info)