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