seq_midi_event.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549
  1. /*
  2. * MIDI byte <-> sequencer event coder
  3. *
  4. * Copyright (C) 1998,99 Takashi Iwai <tiwai@suse.de>,
  5. * Jaroslav Kysela <perex@perex.cz>
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 2 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  20. */
  21. #include <linux/slab.h>
  22. #include <linux/errno.h>
  23. #include <linux/string.h>
  24. #include <sound/core.h>
  25. #include <sound/seq_kernel.h>
  26. #include <sound/seq_midi_event.h>
  27. #include <sound/asoundef.h>
  28. MODULE_AUTHOR("Takashi Iwai <tiwai@suse.de>, Jaroslav Kysela <perex@perex.cz>");
  29. MODULE_DESCRIPTION("MIDI byte <-> sequencer event coder");
  30. MODULE_LICENSE("GPL");
  31. /* event type, index into status_event[] */
  32. /* from 0 to 6 are normal commands (note off, on, etc.) for 0x9?-0xe? */
  33. #define ST_INVALID 7
  34. #define ST_SPECIAL 8
  35. #define ST_SYSEX ST_SPECIAL
  36. /* from 8 to 15 are events for 0xf0-0xf7 */
  37. /*
  38. * prototypes
  39. */
  40. static void note_event(struct snd_midi_event *dev, struct snd_seq_event *ev);
  41. static void one_param_ctrl_event(struct snd_midi_event *dev, struct snd_seq_event *ev);
  42. static void pitchbend_ctrl_event(struct snd_midi_event *dev, struct snd_seq_event *ev);
  43. static void two_param_ctrl_event(struct snd_midi_event *dev, struct snd_seq_event *ev);
  44. static void one_param_event(struct snd_midi_event *dev, struct snd_seq_event *ev);
  45. static void songpos_event(struct snd_midi_event *dev, struct snd_seq_event *ev);
  46. static void note_decode(struct snd_seq_event *ev, unsigned char *buf);
  47. static void one_param_decode(struct snd_seq_event *ev, unsigned char *buf);
  48. static void pitchbend_decode(struct snd_seq_event *ev, unsigned char *buf);
  49. static void two_param_decode(struct snd_seq_event *ev, unsigned char *buf);
  50. static void songpos_decode(struct snd_seq_event *ev, unsigned char *buf);
  51. /*
  52. * event list
  53. */
  54. static struct status_event_list {
  55. int event;
  56. int qlen;
  57. void (*encode)(struct snd_midi_event *dev, struct snd_seq_event *ev);
  58. void (*decode)(struct snd_seq_event *ev, unsigned char *buf);
  59. } status_event[] = {
  60. /* 0x80 - 0xef */
  61. {SNDRV_SEQ_EVENT_NOTEOFF, 2, note_event, note_decode},
  62. {SNDRV_SEQ_EVENT_NOTEON, 2, note_event, note_decode},
  63. {SNDRV_SEQ_EVENT_KEYPRESS, 2, note_event, note_decode},
  64. {SNDRV_SEQ_EVENT_CONTROLLER, 2, two_param_ctrl_event, two_param_decode},
  65. {SNDRV_SEQ_EVENT_PGMCHANGE, 1, one_param_ctrl_event, one_param_decode},
  66. {SNDRV_SEQ_EVENT_CHANPRESS, 1, one_param_ctrl_event, one_param_decode},
  67. {SNDRV_SEQ_EVENT_PITCHBEND, 2, pitchbend_ctrl_event, pitchbend_decode},
  68. /* invalid */
  69. {SNDRV_SEQ_EVENT_NONE, -1, NULL, NULL},
  70. /* 0xf0 - 0xff */
  71. {SNDRV_SEQ_EVENT_SYSEX, 1, NULL, NULL}, /* sysex: 0xf0 */
  72. {SNDRV_SEQ_EVENT_QFRAME, 1, one_param_event, one_param_decode}, /* 0xf1 */
  73. {SNDRV_SEQ_EVENT_SONGPOS, 2, songpos_event, songpos_decode}, /* 0xf2 */
  74. {SNDRV_SEQ_EVENT_SONGSEL, 1, one_param_event, one_param_decode}, /* 0xf3 */
  75. {SNDRV_SEQ_EVENT_NONE, -1, NULL, NULL}, /* 0xf4 */
  76. {SNDRV_SEQ_EVENT_NONE, -1, NULL, NULL}, /* 0xf5 */
  77. {SNDRV_SEQ_EVENT_TUNE_REQUEST, 0, NULL, NULL}, /* 0xf6 */
  78. {SNDRV_SEQ_EVENT_NONE, -1, NULL, NULL}, /* 0xf7 */
  79. {SNDRV_SEQ_EVENT_CLOCK, 0, NULL, NULL}, /* 0xf8 */
  80. {SNDRV_SEQ_EVENT_NONE, -1, NULL, NULL}, /* 0xf9 */
  81. {SNDRV_SEQ_EVENT_START, 0, NULL, NULL}, /* 0xfa */
  82. {SNDRV_SEQ_EVENT_CONTINUE, 0, NULL, NULL}, /* 0xfb */
  83. {SNDRV_SEQ_EVENT_STOP, 0, NULL, NULL}, /* 0xfc */
  84. {SNDRV_SEQ_EVENT_NONE, -1, NULL, NULL}, /* 0xfd */
  85. {SNDRV_SEQ_EVENT_SENSING, 0, NULL, NULL}, /* 0xfe */
  86. {SNDRV_SEQ_EVENT_RESET, 0, NULL, NULL}, /* 0xff */
  87. };
  88. static int extra_decode_ctrl14(struct snd_midi_event *dev, unsigned char *buf, int len,
  89. struct snd_seq_event *ev);
  90. static int extra_decode_xrpn(struct snd_midi_event *dev, unsigned char *buf, int count,
  91. struct snd_seq_event *ev);
  92. static struct extra_event_list {
  93. int event;
  94. int (*decode)(struct snd_midi_event *dev, unsigned char *buf, int len,
  95. struct snd_seq_event *ev);
  96. } extra_event[] = {
  97. {SNDRV_SEQ_EVENT_CONTROL14, extra_decode_ctrl14},
  98. {SNDRV_SEQ_EVENT_NONREGPARAM, extra_decode_xrpn},
  99. {SNDRV_SEQ_EVENT_REGPARAM, extra_decode_xrpn},
  100. };
  101. /*
  102. * new/delete record
  103. */
  104. int snd_midi_event_new(int bufsize, struct snd_midi_event **rdev)
  105. {
  106. struct snd_midi_event *dev;
  107. *rdev = NULL;
  108. dev = kzalloc(sizeof(*dev), GFP_KERNEL);
  109. if (dev == NULL)
  110. return -ENOMEM;
  111. if (bufsize > 0) {
  112. dev->buf = kmalloc(bufsize, GFP_KERNEL);
  113. if (dev->buf == NULL) {
  114. kfree(dev);
  115. return -ENOMEM;
  116. }
  117. }
  118. dev->bufsize = bufsize;
  119. dev->lastcmd = 0xff;
  120. dev->type = ST_INVALID;
  121. spin_lock_init(&dev->lock);
  122. *rdev = dev;
  123. return 0;
  124. }
  125. void snd_midi_event_free(struct snd_midi_event *dev)
  126. {
  127. if (dev != NULL) {
  128. kfree(dev->buf);
  129. kfree(dev);
  130. }
  131. }
  132. /*
  133. * initialize record
  134. */
  135. static inline void reset_encode(struct snd_midi_event *dev)
  136. {
  137. dev->read = 0;
  138. dev->qlen = 0;
  139. dev->type = ST_INVALID;
  140. }
  141. void snd_midi_event_reset_encode(struct snd_midi_event *dev)
  142. {
  143. unsigned long flags;
  144. spin_lock_irqsave(&dev->lock, flags);
  145. reset_encode(dev);
  146. spin_unlock_irqrestore(&dev->lock, flags);
  147. }
  148. void snd_midi_event_reset_decode(struct snd_midi_event *dev)
  149. {
  150. unsigned long flags;
  151. spin_lock_irqsave(&dev->lock, flags);
  152. dev->lastcmd = 0xff;
  153. spin_unlock_irqrestore(&dev->lock, flags);
  154. }
  155. #if 0
  156. void snd_midi_event_init(struct snd_midi_event *dev)
  157. {
  158. snd_midi_event_reset_encode(dev);
  159. snd_midi_event_reset_decode(dev);
  160. }
  161. #endif /* 0 */
  162. void snd_midi_event_no_status(struct snd_midi_event *dev, int on)
  163. {
  164. dev->nostat = on ? 1 : 0;
  165. }
  166. /*
  167. * resize buffer
  168. */
  169. #if 0
  170. int snd_midi_event_resize_buffer(struct snd_midi_event *dev, int bufsize)
  171. {
  172. unsigned char *new_buf, *old_buf;
  173. unsigned long flags;
  174. if (bufsize == dev->bufsize)
  175. return 0;
  176. new_buf = kmalloc(bufsize, GFP_KERNEL);
  177. if (new_buf == NULL)
  178. return -ENOMEM;
  179. spin_lock_irqsave(&dev->lock, flags);
  180. old_buf = dev->buf;
  181. dev->buf = new_buf;
  182. dev->bufsize = bufsize;
  183. reset_encode(dev);
  184. spin_unlock_irqrestore(&dev->lock, flags);
  185. kfree(old_buf);
  186. return 0;
  187. }
  188. #endif /* 0 */
  189. /*
  190. * read bytes and encode to sequencer event if finished
  191. * return the size of encoded bytes
  192. */
  193. long snd_midi_event_encode(struct snd_midi_event *dev, unsigned char *buf, long count,
  194. struct snd_seq_event *ev)
  195. {
  196. long result = 0;
  197. int rc;
  198. ev->type = SNDRV_SEQ_EVENT_NONE;
  199. while (count-- > 0) {
  200. rc = snd_midi_event_encode_byte(dev, *buf++, ev);
  201. result++;
  202. if (rc < 0)
  203. return rc;
  204. else if (rc > 0)
  205. return result;
  206. }
  207. return result;
  208. }
  209. /*
  210. * read one byte and encode to sequencer event:
  211. * return 1 if MIDI bytes are encoded to an event
  212. * 0 data is not finished
  213. * negative for error
  214. */
  215. int snd_midi_event_encode_byte(struct snd_midi_event *dev, int c,
  216. struct snd_seq_event *ev)
  217. {
  218. int rc = 0;
  219. unsigned long flags;
  220. c &= 0xff;
  221. if (c >= MIDI_CMD_COMMON_CLOCK) {
  222. /* real-time event */
  223. ev->type = status_event[ST_SPECIAL + c - 0xf0].event;
  224. ev->flags &= ~SNDRV_SEQ_EVENT_LENGTH_MASK;
  225. ev->flags |= SNDRV_SEQ_EVENT_LENGTH_FIXED;
  226. return ev->type != SNDRV_SEQ_EVENT_NONE;
  227. }
  228. spin_lock_irqsave(&dev->lock, flags);
  229. if ((c & 0x80) &&
  230. (c != MIDI_CMD_COMMON_SYSEX_END || dev->type != ST_SYSEX)) {
  231. /* new command */
  232. dev->buf[0] = c;
  233. if ((c & 0xf0) == 0xf0) /* system messages */
  234. dev->type = (c & 0x0f) + ST_SPECIAL;
  235. else
  236. dev->type = (c >> 4) & 0x07;
  237. dev->read = 1;
  238. dev->qlen = status_event[dev->type].qlen;
  239. } else {
  240. if (dev->qlen > 0) {
  241. /* rest of command */
  242. dev->buf[dev->read++] = c;
  243. if (dev->type != ST_SYSEX)
  244. dev->qlen--;
  245. } else {
  246. /* running status */
  247. dev->buf[1] = c;
  248. dev->qlen = status_event[dev->type].qlen - 1;
  249. dev->read = 2;
  250. }
  251. }
  252. if (dev->qlen == 0) {
  253. ev->type = status_event[dev->type].event;
  254. ev->flags &= ~SNDRV_SEQ_EVENT_LENGTH_MASK;
  255. ev->flags |= SNDRV_SEQ_EVENT_LENGTH_FIXED;
  256. if (status_event[dev->type].encode) /* set data values */
  257. status_event[dev->type].encode(dev, ev);
  258. if (dev->type >= ST_SPECIAL)
  259. dev->type = ST_INVALID;
  260. rc = 1;
  261. } else if (dev->type == ST_SYSEX) {
  262. if (c == MIDI_CMD_COMMON_SYSEX_END ||
  263. dev->read >= dev->bufsize) {
  264. ev->flags &= ~SNDRV_SEQ_EVENT_LENGTH_MASK;
  265. ev->flags |= SNDRV_SEQ_EVENT_LENGTH_VARIABLE;
  266. ev->type = SNDRV_SEQ_EVENT_SYSEX;
  267. ev->data.ext.len = dev->read;
  268. ev->data.ext.ptr = dev->buf;
  269. if (c != MIDI_CMD_COMMON_SYSEX_END)
  270. dev->read = 0; /* continue to parse */
  271. else
  272. reset_encode(dev); /* all parsed */
  273. rc = 1;
  274. }
  275. }
  276. spin_unlock_irqrestore(&dev->lock, flags);
  277. return rc;
  278. }
  279. /* encode note event */
  280. static void note_event(struct snd_midi_event *dev, struct snd_seq_event *ev)
  281. {
  282. ev->data.note.channel = dev->buf[0] & 0x0f;
  283. ev->data.note.note = dev->buf[1];
  284. ev->data.note.velocity = dev->buf[2];
  285. }
  286. /* encode one parameter controls */
  287. static void one_param_ctrl_event(struct snd_midi_event *dev, struct snd_seq_event *ev)
  288. {
  289. ev->data.control.channel = dev->buf[0] & 0x0f;
  290. ev->data.control.value = dev->buf[1];
  291. }
  292. /* encode pitch wheel change */
  293. static void pitchbend_ctrl_event(struct snd_midi_event *dev, struct snd_seq_event *ev)
  294. {
  295. ev->data.control.channel = dev->buf[0] & 0x0f;
  296. ev->data.control.value = (int)dev->buf[2] * 128 + (int)dev->buf[1] - 8192;
  297. }
  298. /* encode midi control change */
  299. static void two_param_ctrl_event(struct snd_midi_event *dev, struct snd_seq_event *ev)
  300. {
  301. ev->data.control.channel = dev->buf[0] & 0x0f;
  302. ev->data.control.param = dev->buf[1];
  303. ev->data.control.value = dev->buf[2];
  304. }
  305. /* encode one parameter value*/
  306. static void one_param_event(struct snd_midi_event *dev, struct snd_seq_event *ev)
  307. {
  308. ev->data.control.value = dev->buf[1];
  309. }
  310. /* encode song position */
  311. static void songpos_event(struct snd_midi_event *dev, struct snd_seq_event *ev)
  312. {
  313. ev->data.control.value = (int)dev->buf[2] * 128 + (int)dev->buf[1];
  314. }
  315. /*
  316. * decode from a sequencer event to midi bytes
  317. * return the size of decoded midi events
  318. */
  319. long snd_midi_event_decode(struct snd_midi_event *dev, unsigned char *buf, long count,
  320. struct snd_seq_event *ev)
  321. {
  322. unsigned int cmd, type;
  323. if (ev->type == SNDRV_SEQ_EVENT_NONE)
  324. return -ENOENT;
  325. for (type = 0; type < ARRAY_SIZE(status_event); type++) {
  326. if (ev->type == status_event[type].event)
  327. goto __found;
  328. }
  329. for (type = 0; type < ARRAY_SIZE(extra_event); type++) {
  330. if (ev->type == extra_event[type].event)
  331. return extra_event[type].decode(dev, buf, count, ev);
  332. }
  333. return -ENOENT;
  334. __found:
  335. if (type >= ST_SPECIAL)
  336. cmd = 0xf0 + (type - ST_SPECIAL);
  337. else
  338. /* data.note.channel and data.control.channel is identical */
  339. cmd = 0x80 | (type << 4) | (ev->data.note.channel & 0x0f);
  340. if (cmd == MIDI_CMD_COMMON_SYSEX) {
  341. snd_midi_event_reset_decode(dev);
  342. return snd_seq_expand_var_event(ev, count, buf, 1, 0);
  343. } else {
  344. int qlen;
  345. unsigned char xbuf[4];
  346. unsigned long flags;
  347. spin_lock_irqsave(&dev->lock, flags);
  348. if ((cmd & 0xf0) == 0xf0 || dev->lastcmd != cmd || dev->nostat) {
  349. dev->lastcmd = cmd;
  350. spin_unlock_irqrestore(&dev->lock, flags);
  351. xbuf[0] = cmd;
  352. if (status_event[type].decode)
  353. status_event[type].decode(ev, xbuf + 1);
  354. qlen = status_event[type].qlen + 1;
  355. } else {
  356. spin_unlock_irqrestore(&dev->lock, flags);
  357. if (status_event[type].decode)
  358. status_event[type].decode(ev, xbuf + 0);
  359. qlen = status_event[type].qlen;
  360. }
  361. if (count < qlen)
  362. return -ENOMEM;
  363. memcpy(buf, xbuf, qlen);
  364. return qlen;
  365. }
  366. }
  367. /* decode note event */
  368. static void note_decode(struct snd_seq_event *ev, unsigned char *buf)
  369. {
  370. buf[0] = ev->data.note.note & 0x7f;
  371. buf[1] = ev->data.note.velocity & 0x7f;
  372. }
  373. /* decode one parameter controls */
  374. static void one_param_decode(struct snd_seq_event *ev, unsigned char *buf)
  375. {
  376. buf[0] = ev->data.control.value & 0x7f;
  377. }
  378. /* decode pitch wheel change */
  379. static void pitchbend_decode(struct snd_seq_event *ev, unsigned char *buf)
  380. {
  381. int value = ev->data.control.value + 8192;
  382. buf[0] = value & 0x7f;
  383. buf[1] = (value >> 7) & 0x7f;
  384. }
  385. /* decode midi control change */
  386. static void two_param_decode(struct snd_seq_event *ev, unsigned char *buf)
  387. {
  388. buf[0] = ev->data.control.param & 0x7f;
  389. buf[1] = ev->data.control.value & 0x7f;
  390. }
  391. /* decode song position */
  392. static void songpos_decode(struct snd_seq_event *ev, unsigned char *buf)
  393. {
  394. buf[0] = ev->data.control.value & 0x7f;
  395. buf[1] = (ev->data.control.value >> 7) & 0x7f;
  396. }
  397. /* decode 14bit control */
  398. static int extra_decode_ctrl14(struct snd_midi_event *dev, unsigned char *buf,
  399. int count, struct snd_seq_event *ev)
  400. {
  401. unsigned char cmd;
  402. int idx = 0;
  403. cmd = MIDI_CMD_CONTROL|(ev->data.control.channel & 0x0f);
  404. if (ev->data.control.param < 0x20) {
  405. if (count < 4)
  406. return -ENOMEM;
  407. if (dev->nostat && count < 6)
  408. return -ENOMEM;
  409. if (cmd != dev->lastcmd || dev->nostat) {
  410. if (count < 5)
  411. return -ENOMEM;
  412. buf[idx++] = dev->lastcmd = cmd;
  413. }
  414. buf[idx++] = ev->data.control.param;
  415. buf[idx++] = (ev->data.control.value >> 7) & 0x7f;
  416. if (dev->nostat)
  417. buf[idx++] = cmd;
  418. buf[idx++] = ev->data.control.param + 0x20;
  419. buf[idx++] = ev->data.control.value & 0x7f;
  420. } else {
  421. if (count < 2)
  422. return -ENOMEM;
  423. if (cmd != dev->lastcmd || dev->nostat) {
  424. if (count < 3)
  425. return -ENOMEM;
  426. buf[idx++] = dev->lastcmd = cmd;
  427. }
  428. buf[idx++] = ev->data.control.param & 0x7f;
  429. buf[idx++] = ev->data.control.value & 0x7f;
  430. }
  431. return idx;
  432. }
  433. /* decode reg/nonreg param */
  434. static int extra_decode_xrpn(struct snd_midi_event *dev, unsigned char *buf,
  435. int count, struct snd_seq_event *ev)
  436. {
  437. unsigned char cmd;
  438. char *cbytes;
  439. static char cbytes_nrpn[4] = { MIDI_CTL_NONREG_PARM_NUM_MSB,
  440. MIDI_CTL_NONREG_PARM_NUM_LSB,
  441. MIDI_CTL_MSB_DATA_ENTRY,
  442. MIDI_CTL_LSB_DATA_ENTRY };
  443. static char cbytes_rpn[4] = { MIDI_CTL_REGIST_PARM_NUM_MSB,
  444. MIDI_CTL_REGIST_PARM_NUM_LSB,
  445. MIDI_CTL_MSB_DATA_ENTRY,
  446. MIDI_CTL_LSB_DATA_ENTRY };
  447. unsigned char bytes[4];
  448. int idx = 0, i;
  449. if (count < 8)
  450. return -ENOMEM;
  451. if (dev->nostat && count < 12)
  452. return -ENOMEM;
  453. cmd = MIDI_CMD_CONTROL|(ev->data.control.channel & 0x0f);
  454. bytes[0] = ev->data.control.param & 0x007f;
  455. bytes[1] = (ev->data.control.param & 0x3f80) >> 7;
  456. bytes[2] = ev->data.control.value & 0x007f;
  457. bytes[3] = (ev->data.control.value & 0x3f80) >> 7;
  458. if (cmd != dev->lastcmd && !dev->nostat) {
  459. if (count < 9)
  460. return -ENOMEM;
  461. buf[idx++] = dev->lastcmd = cmd;
  462. }
  463. cbytes = ev->type == SNDRV_SEQ_EVENT_NONREGPARAM ? cbytes_nrpn : cbytes_rpn;
  464. for (i = 0; i < 4; i++) {
  465. if (dev->nostat)
  466. buf[idx++] = dev->lastcmd = cmd;
  467. buf[idx++] = cbytes[i];
  468. buf[idx++] = bytes[i];
  469. }
  470. return idx;
  471. }
  472. /*
  473. * exports
  474. */
  475. EXPORT_SYMBOL(snd_midi_event_new);
  476. EXPORT_SYMBOL(snd_midi_event_free);
  477. EXPORT_SYMBOL(snd_midi_event_reset_encode);
  478. EXPORT_SYMBOL(snd_midi_event_reset_decode);
  479. EXPORT_SYMBOL(snd_midi_event_no_status);
  480. EXPORT_SYMBOL(snd_midi_event_encode);
  481. EXPORT_SYMBOL(snd_midi_event_encode_byte);
  482. EXPORT_SYMBOL(snd_midi_event_decode);
  483. static int __init alsa_seq_midi_event_init(void)
  484. {
  485. return 0;
  486. }
  487. static void __exit alsa_seq_midi_event_exit(void)
  488. {
  489. }
  490. module_init(alsa_seq_midi_event_init)
  491. module_exit(alsa_seq_midi_event_exit)