seq_event.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326
  1. /**
  2. * \file include/seq_event.h
  3. * \brief Application interface library for the ALSA driver
  4. * \author Jaroslav Kysela <perex@perex.cz>
  5. * \author Abramo Bagnara <abramo@alsa-project.org>
  6. * \author Takashi Iwai <tiwai@suse.de>
  7. * \date 1998-2001
  8. *
  9. * Application interface library for the ALSA driver
  10. */
  11. /*
  12. * This library is free software; you can redistribute it and/or modify
  13. * it under the terms of the GNU Lesser General Public License as
  14. * published by the Free Software Foundation; either version 2.1 of
  15. * the License, or (at your option) any later version.
  16. *
  17. * This program is distributed in the hope that it will be useful,
  18. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. * GNU Lesser General Public License for more details.
  21. *
  22. * You should have received a copy of the GNU Lesser General Public
  23. * License along with this library; if not, write to the Free Software
  24. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  25. *
  26. */
  27. #ifndef __ALSA_SEQ_EVENT_H
  28. #define __ALSA_SEQ_EVENT_H
  29. /**
  30. * \defgroup SeqEvents Sequencer Event Definitions
  31. * Sequencer Event Definitions
  32. * \ingroup Sequencer
  33. * \{
  34. */
  35. /**
  36. * Sequencer event data type
  37. */
  38. typedef unsigned char snd_seq_event_type_t;
  39. /** Sequencer event type */
  40. enum snd_seq_event_type {
  41. /** system status; event data type = #snd_seq_result_t */
  42. SND_SEQ_EVENT_SYSTEM = 0,
  43. /** returned result status; event data type = #snd_seq_result_t */
  44. SND_SEQ_EVENT_RESULT,
  45. /** note on and off with duration; event data type = #snd_seq_ev_note_t */
  46. SND_SEQ_EVENT_NOTE = 5,
  47. /** note on; event data type = #snd_seq_ev_note_t */
  48. SND_SEQ_EVENT_NOTEON,
  49. /** note off; event data type = #snd_seq_ev_note_t */
  50. SND_SEQ_EVENT_NOTEOFF,
  51. /** key pressure change (aftertouch); event data type = #snd_seq_ev_note_t */
  52. SND_SEQ_EVENT_KEYPRESS,
  53. /** controller; event data type = #snd_seq_ev_ctrl_t */
  54. SND_SEQ_EVENT_CONTROLLER = 10,
  55. /** program change; event data type = #snd_seq_ev_ctrl_t */
  56. SND_SEQ_EVENT_PGMCHANGE,
  57. /** channel pressure; event data type = #snd_seq_ev_ctrl_t */
  58. SND_SEQ_EVENT_CHANPRESS,
  59. /** pitchwheel; event data type = #snd_seq_ev_ctrl_t; data is from -8192 to 8191) */
  60. SND_SEQ_EVENT_PITCHBEND,
  61. /** 14 bit controller value; event data type = #snd_seq_ev_ctrl_t */
  62. SND_SEQ_EVENT_CONTROL14,
  63. /** 14 bit NRPN; event data type = #snd_seq_ev_ctrl_t */
  64. SND_SEQ_EVENT_NONREGPARAM,
  65. /** 14 bit RPN; event data type = #snd_seq_ev_ctrl_t */
  66. SND_SEQ_EVENT_REGPARAM,
  67. /** SPP with LSB and MSB values; event data type = #snd_seq_ev_ctrl_t */
  68. SND_SEQ_EVENT_SONGPOS = 20,
  69. /** Song Select with song ID number; event data type = #snd_seq_ev_ctrl_t */
  70. SND_SEQ_EVENT_SONGSEL,
  71. /** midi time code quarter frame; event data type = #snd_seq_ev_ctrl_t */
  72. SND_SEQ_EVENT_QFRAME,
  73. /** SMF Time Signature event; event data type = #snd_seq_ev_ctrl_t */
  74. SND_SEQ_EVENT_TIMESIGN,
  75. /** SMF Key Signature event; event data type = #snd_seq_ev_ctrl_t */
  76. SND_SEQ_EVENT_KEYSIGN,
  77. /** MIDI Real Time Start message; event data type = #snd_seq_ev_queue_control_t */
  78. SND_SEQ_EVENT_START = 30,
  79. /** MIDI Real Time Continue message; event data type = #snd_seq_ev_queue_control_t */
  80. SND_SEQ_EVENT_CONTINUE,
  81. /** MIDI Real Time Stop message; event data type = #snd_seq_ev_queue_control_t */
  82. SND_SEQ_EVENT_STOP,
  83. /** Set tick queue position; event data type = #snd_seq_ev_queue_control_t */
  84. SND_SEQ_EVENT_SETPOS_TICK,
  85. /** Set real-time queue position; event data type = #snd_seq_ev_queue_control_t */
  86. SND_SEQ_EVENT_SETPOS_TIME,
  87. /** (SMF) Tempo event; event data type = #snd_seq_ev_queue_control_t */
  88. SND_SEQ_EVENT_TEMPO,
  89. /** MIDI Real Time Clock message; event data type = #snd_seq_ev_queue_control_t */
  90. SND_SEQ_EVENT_CLOCK,
  91. /** MIDI Real Time Tick message; event data type = #snd_seq_ev_queue_control_t */
  92. SND_SEQ_EVENT_TICK,
  93. /** Queue timer skew; event data type = #snd_seq_ev_queue_control_t */
  94. SND_SEQ_EVENT_QUEUE_SKEW,
  95. /** Sync position changed; event data type = #snd_seq_ev_queue_control_t */
  96. SND_SEQ_EVENT_SYNC_POS,
  97. /** Tune request; event data type = none */
  98. SND_SEQ_EVENT_TUNE_REQUEST = 40,
  99. /** Reset to power-on state; event data type = none */
  100. SND_SEQ_EVENT_RESET,
  101. /** Active sensing event; event data type = none */
  102. SND_SEQ_EVENT_SENSING,
  103. /** Echo-back event; event data type = any type */
  104. SND_SEQ_EVENT_ECHO = 50,
  105. /** OSS emulation raw event; event data type = any type */
  106. SND_SEQ_EVENT_OSS,
  107. /** New client has connected; event data type = #snd_seq_addr_t */
  108. SND_SEQ_EVENT_CLIENT_START = 60,
  109. /** Client has left the system; event data type = #snd_seq_addr_t */
  110. SND_SEQ_EVENT_CLIENT_EXIT,
  111. /** Client status/info has changed; event data type = #snd_seq_addr_t */
  112. SND_SEQ_EVENT_CLIENT_CHANGE,
  113. /** New port was created; event data type = #snd_seq_addr_t */
  114. SND_SEQ_EVENT_PORT_START,
  115. /** Port was deleted from system; event data type = #snd_seq_addr_t */
  116. SND_SEQ_EVENT_PORT_EXIT,
  117. /** Port status/info has changed; event data type = #snd_seq_addr_t */
  118. SND_SEQ_EVENT_PORT_CHANGE,
  119. /** Ports connected; event data type = #snd_seq_connect_t */
  120. SND_SEQ_EVENT_PORT_SUBSCRIBED,
  121. /** Ports disconnected; event data type = #snd_seq_connect_t */
  122. SND_SEQ_EVENT_PORT_UNSUBSCRIBED,
  123. /** user-defined event; event data type = any (fixed size) */
  124. SND_SEQ_EVENT_USR0 = 90,
  125. /** user-defined event; event data type = any (fixed size) */
  126. SND_SEQ_EVENT_USR1,
  127. /** user-defined event; event data type = any (fixed size) */
  128. SND_SEQ_EVENT_USR2,
  129. /** user-defined event; event data type = any (fixed size) */
  130. SND_SEQ_EVENT_USR3,
  131. /** user-defined event; event data type = any (fixed size) */
  132. SND_SEQ_EVENT_USR4,
  133. /** user-defined event; event data type = any (fixed size) */
  134. SND_SEQ_EVENT_USR5,
  135. /** user-defined event; event data type = any (fixed size) */
  136. SND_SEQ_EVENT_USR6,
  137. /** user-defined event; event data type = any (fixed size) */
  138. SND_SEQ_EVENT_USR7,
  139. /** user-defined event; event data type = any (fixed size) */
  140. SND_SEQ_EVENT_USR8,
  141. /** user-defined event; event data type = any (fixed size) */
  142. SND_SEQ_EVENT_USR9,
  143. /** system exclusive data (variable length); event data type = #snd_seq_ev_ext_t */
  144. SND_SEQ_EVENT_SYSEX = 130,
  145. /** error event; event data type = #snd_seq_ev_ext_t */
  146. SND_SEQ_EVENT_BOUNCE,
  147. /** reserved for user apps; event data type = #snd_seq_ev_ext_t */
  148. SND_SEQ_EVENT_USR_VAR0 = 135,
  149. /** reserved for user apps; event data type = #snd_seq_ev_ext_t */
  150. SND_SEQ_EVENT_USR_VAR1,
  151. /** reserved for user apps; event data type = #snd_seq_ev_ext_t */
  152. SND_SEQ_EVENT_USR_VAR2,
  153. /** reserved for user apps; event data type = #snd_seq_ev_ext_t */
  154. SND_SEQ_EVENT_USR_VAR3,
  155. /** reserved for user apps; event data type = #snd_seq_ev_ext_t */
  156. SND_SEQ_EVENT_USR_VAR4,
  157. /** NOP; ignored in any case */
  158. SND_SEQ_EVENT_NONE = 255
  159. };
  160. /** Sequencer event address */
  161. typedef struct snd_seq_addr {
  162. unsigned char client; /**< Client id */
  163. unsigned char port; /**< Port id */
  164. } snd_seq_addr_t;
  165. /** Connection (subscription) between ports */
  166. typedef struct snd_seq_connect {
  167. snd_seq_addr_t sender; /**< sender address */
  168. snd_seq_addr_t dest; /**< destination address */
  169. } snd_seq_connect_t;
  170. /** Real-time data record */
  171. typedef struct snd_seq_real_time {
  172. unsigned int tv_sec; /**< seconds */
  173. unsigned int tv_nsec; /**< nanoseconds */
  174. } snd_seq_real_time_t;
  175. /** (MIDI) Tick-time data record */
  176. typedef unsigned int snd_seq_tick_time_t;
  177. /** unioned time stamp */
  178. typedef union snd_seq_timestamp {
  179. snd_seq_tick_time_t tick; /**< tick-time */
  180. struct snd_seq_real_time time; /**< real-time */
  181. } snd_seq_timestamp_t;
  182. /**
  183. * Event mode flags
  184. *
  185. * NOTE: only 8 bits available!
  186. */
  187. #define SND_SEQ_TIME_STAMP_TICK (0<<0) /**< timestamp in clock ticks */
  188. #define SND_SEQ_TIME_STAMP_REAL (1<<0) /**< timestamp in real time */
  189. #define SND_SEQ_TIME_STAMP_MASK (1<<0) /**< mask for timestamp bits */
  190. #define SND_SEQ_TIME_MODE_ABS (0<<1) /**< absolute timestamp */
  191. #define SND_SEQ_TIME_MODE_REL (1<<1) /**< relative to current time */
  192. #define SND_SEQ_TIME_MODE_MASK (1<<1) /**< mask for time mode bits */
  193. #define SND_SEQ_EVENT_LENGTH_FIXED (0<<2) /**< fixed event size */
  194. #define SND_SEQ_EVENT_LENGTH_VARIABLE (1<<2) /**< variable event size */
  195. #define SND_SEQ_EVENT_LENGTH_VARUSR (2<<2) /**< variable event size - user memory space */
  196. #define SND_SEQ_EVENT_LENGTH_MASK (3<<2) /**< mask for event length bits */
  197. #define SND_SEQ_PRIORITY_NORMAL (0<<4) /**< normal priority */
  198. #define SND_SEQ_PRIORITY_HIGH (1<<4) /**< event should be processed before others */
  199. #define SND_SEQ_PRIORITY_MASK (1<<4) /**< mask for priority bits */
  200. /** Note event */
  201. typedef struct snd_seq_ev_note {
  202. unsigned char channel; /**< channel number */
  203. unsigned char note; /**< note */
  204. unsigned char velocity; /**< velocity */
  205. unsigned char off_velocity; /**< note-off velocity; only for #SND_SEQ_EVENT_NOTE */
  206. unsigned int duration; /**< duration until note-off; only for #SND_SEQ_EVENT_NOTE */
  207. } snd_seq_ev_note_t;
  208. /** Controller event */
  209. typedef struct snd_seq_ev_ctrl {
  210. unsigned char channel; /**< channel number */
  211. unsigned char unused[3]; /**< reserved */
  212. unsigned int param; /**< control parameter */
  213. signed int value; /**< control value */
  214. } snd_seq_ev_ctrl_t;
  215. /** generic set of bytes (12x8 bit) */
  216. typedef struct snd_seq_ev_raw8 {
  217. unsigned char d[12]; /**< 8 bit value */
  218. } snd_seq_ev_raw8_t;
  219. /** generic set of integers (3x32 bit) */
  220. typedef struct snd_seq_ev_raw32 {
  221. unsigned int d[3]; /**< 32 bit value */
  222. } snd_seq_ev_raw32_t;
  223. /** external stored data */
  224. struct snd_seq_ev_ext {
  225. unsigned int len; /**< length of data */
  226. void *ptr; /**< pointer to data (note: can be 64-bit) */
  227. } __attribute__((packed));
  228. /** external stored data */
  229. typedef struct snd_seq_ev_ext snd_seq_ev_ext_t;
  230. #ifdef DOC_HIDDEN
  231. /* redefine typedef for stupid doxygen */
  232. typedef snd_seq_ev_ext snd_seq_ev_ext_t;
  233. #endif
  234. /** Result events */
  235. typedef struct snd_seq_result {
  236. int event; /**< processed event type */
  237. int result; /**< status */
  238. } snd_seq_result_t;
  239. /** Queue skew values */
  240. typedef struct snd_seq_queue_skew {
  241. unsigned int value; /**< skew value */
  242. unsigned int base; /**< skew base */
  243. } snd_seq_queue_skew_t;
  244. /** queue timer control */
  245. typedef struct snd_seq_ev_queue_control {
  246. unsigned char queue; /**< affected queue */
  247. unsigned char unused[3]; /**< reserved */
  248. union {
  249. signed int value; /**< affected value (e.g. tempo) */
  250. snd_seq_timestamp_t time; /**< time */
  251. unsigned int position; /**< sync position */
  252. snd_seq_queue_skew_t skew; /**< queue skew */
  253. unsigned int d32[2]; /**< any data */
  254. unsigned char d8[8]; /**< any data */
  255. } param; /**< data value union */
  256. } snd_seq_ev_queue_control_t;
  257. /** Sequencer event */
  258. typedef struct snd_seq_event {
  259. snd_seq_event_type_t type; /**< event type */
  260. unsigned char flags; /**< event flags */
  261. unsigned char tag; /**< tag */
  262. unsigned char queue; /**< schedule queue */
  263. snd_seq_timestamp_t time; /**< schedule time */
  264. snd_seq_addr_t source; /**< source address */
  265. snd_seq_addr_t dest; /**< destination address */
  266. union {
  267. snd_seq_ev_note_t note; /**< note information */
  268. snd_seq_ev_ctrl_t control; /**< MIDI control information */
  269. snd_seq_ev_raw8_t raw8; /**< raw8 data */
  270. snd_seq_ev_raw32_t raw32; /**< raw32 data */
  271. snd_seq_ev_ext_t ext; /**< external data */
  272. snd_seq_ev_queue_control_t queue; /**< queue control */
  273. snd_seq_timestamp_t time; /**< timestamp */
  274. snd_seq_addr_t addr; /**< address */
  275. snd_seq_connect_t connect; /**< connect information */
  276. snd_seq_result_t result; /**< operation result code */
  277. } data; /**< event data... */
  278. } snd_seq_event_t;
  279. /** \} */
  280. #endif /* __ALSA_SEQ_EVENT_H */