jpayne@69: /** jpayne@69: * \file include/seq_event.h jpayne@69: * \brief Application interface library for the ALSA driver jpayne@69: * \author Jaroslav Kysela jpayne@69: * \author Abramo Bagnara jpayne@69: * \author Takashi Iwai jpayne@69: * \date 1998-2001 jpayne@69: * jpayne@69: * Application interface library for the ALSA driver jpayne@69: */ jpayne@69: /* jpayne@69: * This library is free software; you can redistribute it and/or modify jpayne@69: * it under the terms of the GNU Lesser General Public License as jpayne@69: * published by the Free Software Foundation; either version 2.1 of jpayne@69: * the License, or (at your option) any later version. jpayne@69: * jpayne@69: * This program is distributed in the hope that it will be useful, jpayne@69: * but WITHOUT ANY WARRANTY; without even the implied warranty of jpayne@69: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the jpayne@69: * GNU Lesser General Public License for more details. jpayne@69: * jpayne@69: * You should have received a copy of the GNU Lesser General Public jpayne@69: * License along with this library; if not, write to the Free Software jpayne@69: * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA jpayne@69: * jpayne@69: */ jpayne@69: jpayne@69: #ifndef __ALSA_SEQ_EVENT_H jpayne@69: #define __ALSA_SEQ_EVENT_H jpayne@69: jpayne@69: /** jpayne@69: * \defgroup SeqEvents Sequencer Event Definitions jpayne@69: * Sequencer Event Definitions jpayne@69: * \ingroup Sequencer jpayne@69: * \{ jpayne@69: */ jpayne@69: jpayne@69: /** jpayne@69: * Sequencer event data type jpayne@69: */ jpayne@69: typedef unsigned char snd_seq_event_type_t; jpayne@69: jpayne@69: /** Sequencer event type */ jpayne@69: enum snd_seq_event_type { jpayne@69: /** system status; event data type = #snd_seq_result_t */ jpayne@69: SND_SEQ_EVENT_SYSTEM = 0, jpayne@69: /** returned result status; event data type = #snd_seq_result_t */ jpayne@69: SND_SEQ_EVENT_RESULT, jpayne@69: jpayne@69: /** note on and off with duration; event data type = #snd_seq_ev_note_t */ jpayne@69: SND_SEQ_EVENT_NOTE = 5, jpayne@69: /** note on; event data type = #snd_seq_ev_note_t */ jpayne@69: SND_SEQ_EVENT_NOTEON, jpayne@69: /** note off; event data type = #snd_seq_ev_note_t */ jpayne@69: SND_SEQ_EVENT_NOTEOFF, jpayne@69: /** key pressure change (aftertouch); event data type = #snd_seq_ev_note_t */ jpayne@69: SND_SEQ_EVENT_KEYPRESS, jpayne@69: jpayne@69: /** controller; event data type = #snd_seq_ev_ctrl_t */ jpayne@69: SND_SEQ_EVENT_CONTROLLER = 10, jpayne@69: /** program change; event data type = #snd_seq_ev_ctrl_t */ jpayne@69: SND_SEQ_EVENT_PGMCHANGE, jpayne@69: /** channel pressure; event data type = #snd_seq_ev_ctrl_t */ jpayne@69: SND_SEQ_EVENT_CHANPRESS, jpayne@69: /** pitchwheel; event data type = #snd_seq_ev_ctrl_t; data is from -8192 to 8191) */ jpayne@69: SND_SEQ_EVENT_PITCHBEND, jpayne@69: /** 14 bit controller value; event data type = #snd_seq_ev_ctrl_t */ jpayne@69: SND_SEQ_EVENT_CONTROL14, jpayne@69: /** 14 bit NRPN; event data type = #snd_seq_ev_ctrl_t */ jpayne@69: SND_SEQ_EVENT_NONREGPARAM, jpayne@69: /** 14 bit RPN; event data type = #snd_seq_ev_ctrl_t */ jpayne@69: SND_SEQ_EVENT_REGPARAM, jpayne@69: jpayne@69: /** SPP with LSB and MSB values; event data type = #snd_seq_ev_ctrl_t */ jpayne@69: SND_SEQ_EVENT_SONGPOS = 20, jpayne@69: /** Song Select with song ID number; event data type = #snd_seq_ev_ctrl_t */ jpayne@69: SND_SEQ_EVENT_SONGSEL, jpayne@69: /** midi time code quarter frame; event data type = #snd_seq_ev_ctrl_t */ jpayne@69: SND_SEQ_EVENT_QFRAME, jpayne@69: /** SMF Time Signature event; event data type = #snd_seq_ev_ctrl_t */ jpayne@69: SND_SEQ_EVENT_TIMESIGN, jpayne@69: /** SMF Key Signature event; event data type = #snd_seq_ev_ctrl_t */ jpayne@69: SND_SEQ_EVENT_KEYSIGN, jpayne@69: jpayne@69: /** MIDI Real Time Start message; event data type = #snd_seq_ev_queue_control_t */ jpayne@69: SND_SEQ_EVENT_START = 30, jpayne@69: /** MIDI Real Time Continue message; event data type = #snd_seq_ev_queue_control_t */ jpayne@69: SND_SEQ_EVENT_CONTINUE, jpayne@69: /** MIDI Real Time Stop message; event data type = #snd_seq_ev_queue_control_t */ jpayne@69: SND_SEQ_EVENT_STOP, jpayne@69: /** Set tick queue position; event data type = #snd_seq_ev_queue_control_t */ jpayne@69: SND_SEQ_EVENT_SETPOS_TICK, jpayne@69: /** Set real-time queue position; event data type = #snd_seq_ev_queue_control_t */ jpayne@69: SND_SEQ_EVENT_SETPOS_TIME, jpayne@69: /** (SMF) Tempo event; event data type = #snd_seq_ev_queue_control_t */ jpayne@69: SND_SEQ_EVENT_TEMPO, jpayne@69: /** MIDI Real Time Clock message; event data type = #snd_seq_ev_queue_control_t */ jpayne@69: SND_SEQ_EVENT_CLOCK, jpayne@69: /** MIDI Real Time Tick message; event data type = #snd_seq_ev_queue_control_t */ jpayne@69: SND_SEQ_EVENT_TICK, jpayne@69: /** Queue timer skew; event data type = #snd_seq_ev_queue_control_t */ jpayne@69: SND_SEQ_EVENT_QUEUE_SKEW, jpayne@69: /** Sync position changed; event data type = #snd_seq_ev_queue_control_t */ jpayne@69: SND_SEQ_EVENT_SYNC_POS, jpayne@69: jpayne@69: /** Tune request; event data type = none */ jpayne@69: SND_SEQ_EVENT_TUNE_REQUEST = 40, jpayne@69: /** Reset to power-on state; event data type = none */ jpayne@69: SND_SEQ_EVENT_RESET, jpayne@69: /** Active sensing event; event data type = none */ jpayne@69: SND_SEQ_EVENT_SENSING, jpayne@69: jpayne@69: /** Echo-back event; event data type = any type */ jpayne@69: SND_SEQ_EVENT_ECHO = 50, jpayne@69: /** OSS emulation raw event; event data type = any type */ jpayne@69: SND_SEQ_EVENT_OSS, jpayne@69: jpayne@69: /** New client has connected; event data type = #snd_seq_addr_t */ jpayne@69: SND_SEQ_EVENT_CLIENT_START = 60, jpayne@69: /** Client has left the system; event data type = #snd_seq_addr_t */ jpayne@69: SND_SEQ_EVENT_CLIENT_EXIT, jpayne@69: /** Client status/info has changed; event data type = #snd_seq_addr_t */ jpayne@69: SND_SEQ_EVENT_CLIENT_CHANGE, jpayne@69: /** New port was created; event data type = #snd_seq_addr_t */ jpayne@69: SND_SEQ_EVENT_PORT_START, jpayne@69: /** Port was deleted from system; event data type = #snd_seq_addr_t */ jpayne@69: SND_SEQ_EVENT_PORT_EXIT, jpayne@69: /** Port status/info has changed; event data type = #snd_seq_addr_t */ jpayne@69: SND_SEQ_EVENT_PORT_CHANGE, jpayne@69: jpayne@69: /** Ports connected; event data type = #snd_seq_connect_t */ jpayne@69: SND_SEQ_EVENT_PORT_SUBSCRIBED, jpayne@69: /** Ports disconnected; event data type = #snd_seq_connect_t */ jpayne@69: SND_SEQ_EVENT_PORT_UNSUBSCRIBED, jpayne@69: jpayne@69: /** user-defined event; event data type = any (fixed size) */ jpayne@69: SND_SEQ_EVENT_USR0 = 90, jpayne@69: /** user-defined event; event data type = any (fixed size) */ jpayne@69: SND_SEQ_EVENT_USR1, jpayne@69: /** user-defined event; event data type = any (fixed size) */ jpayne@69: SND_SEQ_EVENT_USR2, jpayne@69: /** user-defined event; event data type = any (fixed size) */ jpayne@69: SND_SEQ_EVENT_USR3, jpayne@69: /** user-defined event; event data type = any (fixed size) */ jpayne@69: SND_SEQ_EVENT_USR4, jpayne@69: /** user-defined event; event data type = any (fixed size) */ jpayne@69: SND_SEQ_EVENT_USR5, jpayne@69: /** user-defined event; event data type = any (fixed size) */ jpayne@69: SND_SEQ_EVENT_USR6, jpayne@69: /** user-defined event; event data type = any (fixed size) */ jpayne@69: SND_SEQ_EVENT_USR7, jpayne@69: /** user-defined event; event data type = any (fixed size) */ jpayne@69: SND_SEQ_EVENT_USR8, jpayne@69: /** user-defined event; event data type = any (fixed size) */ jpayne@69: SND_SEQ_EVENT_USR9, jpayne@69: jpayne@69: /** system exclusive data (variable length); event data type = #snd_seq_ev_ext_t */ jpayne@69: SND_SEQ_EVENT_SYSEX = 130, jpayne@69: /** error event; event data type = #snd_seq_ev_ext_t */ jpayne@69: SND_SEQ_EVENT_BOUNCE, jpayne@69: /** reserved for user apps; event data type = #snd_seq_ev_ext_t */ jpayne@69: SND_SEQ_EVENT_USR_VAR0 = 135, jpayne@69: /** reserved for user apps; event data type = #snd_seq_ev_ext_t */ jpayne@69: SND_SEQ_EVENT_USR_VAR1, jpayne@69: /** reserved for user apps; event data type = #snd_seq_ev_ext_t */ jpayne@69: SND_SEQ_EVENT_USR_VAR2, jpayne@69: /** reserved for user apps; event data type = #snd_seq_ev_ext_t */ jpayne@69: SND_SEQ_EVENT_USR_VAR3, jpayne@69: /** reserved for user apps; event data type = #snd_seq_ev_ext_t */ jpayne@69: SND_SEQ_EVENT_USR_VAR4, jpayne@69: jpayne@69: /** NOP; ignored in any case */ jpayne@69: SND_SEQ_EVENT_NONE = 255 jpayne@69: }; jpayne@69: jpayne@69: jpayne@69: /** Sequencer event address */ jpayne@69: typedef struct snd_seq_addr { jpayne@69: unsigned char client; /**< Client id */ jpayne@69: unsigned char port; /**< Port id */ jpayne@69: } snd_seq_addr_t; jpayne@69: jpayne@69: /** Connection (subscription) between ports */ jpayne@69: typedef struct snd_seq_connect { jpayne@69: snd_seq_addr_t sender; /**< sender address */ jpayne@69: snd_seq_addr_t dest; /**< destination address */ jpayne@69: } snd_seq_connect_t; jpayne@69: jpayne@69: jpayne@69: /** Real-time data record */ jpayne@69: typedef struct snd_seq_real_time { jpayne@69: unsigned int tv_sec; /**< seconds */ jpayne@69: unsigned int tv_nsec; /**< nanoseconds */ jpayne@69: } snd_seq_real_time_t; jpayne@69: jpayne@69: /** (MIDI) Tick-time data record */ jpayne@69: typedef unsigned int snd_seq_tick_time_t; jpayne@69: jpayne@69: /** unioned time stamp */ jpayne@69: typedef union snd_seq_timestamp { jpayne@69: snd_seq_tick_time_t tick; /**< tick-time */ jpayne@69: struct snd_seq_real_time time; /**< real-time */ jpayne@69: } snd_seq_timestamp_t; jpayne@69: jpayne@69: jpayne@69: /** jpayne@69: * Event mode flags jpayne@69: * jpayne@69: * NOTE: only 8 bits available! jpayne@69: */ jpayne@69: #define SND_SEQ_TIME_STAMP_TICK (0<<0) /**< timestamp in clock ticks */ jpayne@69: #define SND_SEQ_TIME_STAMP_REAL (1<<0) /**< timestamp in real time */ jpayne@69: #define SND_SEQ_TIME_STAMP_MASK (1<<0) /**< mask for timestamp bits */ jpayne@69: jpayne@69: #define SND_SEQ_TIME_MODE_ABS (0<<1) /**< absolute timestamp */ jpayne@69: #define SND_SEQ_TIME_MODE_REL (1<<1) /**< relative to current time */ jpayne@69: #define SND_SEQ_TIME_MODE_MASK (1<<1) /**< mask for time mode bits */ jpayne@69: jpayne@69: #define SND_SEQ_EVENT_LENGTH_FIXED (0<<2) /**< fixed event size */ jpayne@69: #define SND_SEQ_EVENT_LENGTH_VARIABLE (1<<2) /**< variable event size */ jpayne@69: #define SND_SEQ_EVENT_LENGTH_VARUSR (2<<2) /**< variable event size - user memory space */ jpayne@69: #define SND_SEQ_EVENT_LENGTH_MASK (3<<2) /**< mask for event length bits */ jpayne@69: jpayne@69: #define SND_SEQ_PRIORITY_NORMAL (0<<4) /**< normal priority */ jpayne@69: #define SND_SEQ_PRIORITY_HIGH (1<<4) /**< event should be processed before others */ jpayne@69: #define SND_SEQ_PRIORITY_MASK (1<<4) /**< mask for priority bits */ jpayne@69: jpayne@69: jpayne@69: /** Note event */ jpayne@69: typedef struct snd_seq_ev_note { jpayne@69: unsigned char channel; /**< channel number */ jpayne@69: unsigned char note; /**< note */ jpayne@69: unsigned char velocity; /**< velocity */ jpayne@69: unsigned char off_velocity; /**< note-off velocity; only for #SND_SEQ_EVENT_NOTE */ jpayne@69: unsigned int duration; /**< duration until note-off; only for #SND_SEQ_EVENT_NOTE */ jpayne@69: } snd_seq_ev_note_t; jpayne@69: jpayne@69: /** Controller event */ jpayne@69: typedef struct snd_seq_ev_ctrl { jpayne@69: unsigned char channel; /**< channel number */ jpayne@69: unsigned char unused[3]; /**< reserved */ jpayne@69: unsigned int param; /**< control parameter */ jpayne@69: signed int value; /**< control value */ jpayne@69: } snd_seq_ev_ctrl_t; jpayne@69: jpayne@69: /** generic set of bytes (12x8 bit) */ jpayne@69: typedef struct snd_seq_ev_raw8 { jpayne@69: unsigned char d[12]; /**< 8 bit value */ jpayne@69: } snd_seq_ev_raw8_t; jpayne@69: jpayne@69: /** generic set of integers (3x32 bit) */ jpayne@69: typedef struct snd_seq_ev_raw32 { jpayne@69: unsigned int d[3]; /**< 32 bit value */ jpayne@69: } snd_seq_ev_raw32_t; jpayne@69: jpayne@69: /** external stored data */ jpayne@69: struct snd_seq_ev_ext { jpayne@69: unsigned int len; /**< length of data */ jpayne@69: void *ptr; /**< pointer to data (note: can be 64-bit) */ jpayne@69: } __attribute__((packed)); jpayne@69: /** external stored data */ jpayne@69: typedef struct snd_seq_ev_ext snd_seq_ev_ext_t; jpayne@69: #ifdef DOC_HIDDEN jpayne@69: /* redefine typedef for stupid doxygen */ jpayne@69: typedef snd_seq_ev_ext snd_seq_ev_ext_t; jpayne@69: #endif jpayne@69: jpayne@69: /** Result events */ jpayne@69: typedef struct snd_seq_result { jpayne@69: int event; /**< processed event type */ jpayne@69: int result; /**< status */ jpayne@69: } snd_seq_result_t; jpayne@69: jpayne@69: /** Queue skew values */ jpayne@69: typedef struct snd_seq_queue_skew { jpayne@69: unsigned int value; /**< skew value */ jpayne@69: unsigned int base; /**< skew base */ jpayne@69: } snd_seq_queue_skew_t; jpayne@69: jpayne@69: /** queue timer control */ jpayne@69: typedef struct snd_seq_ev_queue_control { jpayne@69: unsigned char queue; /**< affected queue */ jpayne@69: unsigned char unused[3]; /**< reserved */ jpayne@69: union { jpayne@69: signed int value; /**< affected value (e.g. tempo) */ jpayne@69: snd_seq_timestamp_t time; /**< time */ jpayne@69: unsigned int position; /**< sync position */ jpayne@69: snd_seq_queue_skew_t skew; /**< queue skew */ jpayne@69: unsigned int d32[2]; /**< any data */ jpayne@69: unsigned char d8[8]; /**< any data */ jpayne@69: } param; /**< data value union */ jpayne@69: } snd_seq_ev_queue_control_t; jpayne@69: jpayne@69: jpayne@69: /** Sequencer event */ jpayne@69: typedef struct snd_seq_event { jpayne@69: snd_seq_event_type_t type; /**< event type */ jpayne@69: unsigned char flags; /**< event flags */ jpayne@69: unsigned char tag; /**< tag */ jpayne@69: jpayne@69: unsigned char queue; /**< schedule queue */ jpayne@69: snd_seq_timestamp_t time; /**< schedule time */ jpayne@69: jpayne@69: snd_seq_addr_t source; /**< source address */ jpayne@69: snd_seq_addr_t dest; /**< destination address */ jpayne@69: jpayne@69: union { jpayne@69: snd_seq_ev_note_t note; /**< note information */ jpayne@69: snd_seq_ev_ctrl_t control; /**< MIDI control information */ jpayne@69: snd_seq_ev_raw8_t raw8; /**< raw8 data */ jpayne@69: snd_seq_ev_raw32_t raw32; /**< raw32 data */ jpayne@69: snd_seq_ev_ext_t ext; /**< external data */ jpayne@69: snd_seq_ev_queue_control_t queue; /**< queue control */ jpayne@69: snd_seq_timestamp_t time; /**< timestamp */ jpayne@69: snd_seq_addr_t addr; /**< address */ jpayne@69: snd_seq_connect_t connect; /**< connect information */ jpayne@69: snd_seq_result_t result; /**< operation result code */ jpayne@69: } data; /**< event data... */ jpayne@69: } snd_seq_event_t; jpayne@69: jpayne@69: jpayne@69: /** \} */ jpayne@69: jpayne@69: #endif /* __ALSA_SEQ_EVENT_H */ jpayne@69: