Logo Search packages:      
Sourcecode: alsa-lib version File versions  Download package

seq_event.h

Go to the documentation of this file.
/**
 * \file include/seq_event.h
 * \brief Application interface library for the ALSA driver
 * \author Jaroslav Kysela <perex@suse.cz>
 * \author Abramo Bagnara <abramo@alsa-project.org>
 * \author Takashi Iwai <tiwai@suse.de>
 * \date 1998-2001
 *
 * Application interface library for the ALSA driver
 */
/*
 *   This library is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU Lesser General Public License as
 *   published by the Free Software Foundation; either version 2.1 of
 *   the License, or (at your option) any later version.
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU Lesser General Public License for more details.
 *
 *   You should have received a copy of the GNU Lesser General Public
 *   License along with this library; if not, write to the Free Software
 *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 *
 */

#ifndef __ALSA_SEQ_EVENT_H
#define __ALSA_SEQ_EVENT_H

/**
 *  \defgroup SeqEvents Sequencer Event Definitions
 *  Sequencer Event Definitions
 *  \ingroup Sequencer
 *  \{
 */

/**
 * Sequencer event data type
 */
00041 typedef unsigned char snd_seq_event_type_t;

/** Sequencer event type */
00044 enum snd_seq_event_type {
      /** system status; event data type = #snd_seq_result_t */
00046       SND_SEQ_EVENT_SYSTEM = 0,
      /** returned result status; event data type = #snd_seq_result_t */
00048       SND_SEQ_EVENT_RESULT,

      /** note on and off with duration; event data type = #snd_seq_ev_note_t */
00051       SND_SEQ_EVENT_NOTE = 5,
      /** note on; event data type = #snd_seq_ev_note_t */
00053       SND_SEQ_EVENT_NOTEON,
      /** note off; event data type = #snd_seq_ev_note_t */
00055       SND_SEQ_EVENT_NOTEOFF,
      /** key pressure change (aftertouch); event data type = #snd_seq_ev_note_t */
00057       SND_SEQ_EVENT_KEYPRESS,
      
      /** controller; event data type = #snd_seq_ev_ctrl_t */
00060       SND_SEQ_EVENT_CONTROLLER = 10,
      /** program change; event data type = #snd_seq_ev_ctrl_t */
00062       SND_SEQ_EVENT_PGMCHANGE,
      /** channel pressure; event data type = #snd_seq_ev_ctrl_t */
00064       SND_SEQ_EVENT_CHANPRESS,
      /** pitchwheel; event data type = #snd_seq_ev_ctrl_t; data is from -8192 to 8191) */
00066       SND_SEQ_EVENT_PITCHBEND,
      /** 14 bit controller value; event data type = #snd_seq_ev_ctrl_t */
00068       SND_SEQ_EVENT_CONTROL14,
      /** 14 bit NRPN;  event data type = #snd_seq_ev_ctrl_t */
00070       SND_SEQ_EVENT_NONREGPARAM,
      /** 14 bit RPN; event data type = #snd_seq_ev_ctrl_t */
00072       SND_SEQ_EVENT_REGPARAM,

      /** SPP with LSB and MSB values; event data type = #snd_seq_ev_ctrl_t */
00075       SND_SEQ_EVENT_SONGPOS = 20,
      /** Song Select with song ID number; event data type = #snd_seq_ev_ctrl_t */
00077       SND_SEQ_EVENT_SONGSEL,
      /** midi time code quarter frame; event data type = #snd_seq_ev_ctrl_t */
00079       SND_SEQ_EVENT_QFRAME,
      /** SMF Time Signature event; event data type = #snd_seq_ev_ctrl_t */
00081       SND_SEQ_EVENT_TIMESIGN,
      /** SMF Key Signature event; event data type = #snd_seq_ev_ctrl_t */
00083       SND_SEQ_EVENT_KEYSIGN,
              
      /** MIDI Real Time Start message; event data type = #snd_seq_ev_queue_control_t */
00086       SND_SEQ_EVENT_START = 30,
      /** MIDI Real Time Continue message; event data type = #snd_seq_ev_queue_control_t */
00088       SND_SEQ_EVENT_CONTINUE,
      /** MIDI Real Time Stop message; event data type = #snd_seq_ev_queue_control_t */
00090       SND_SEQ_EVENT_STOP,
      /** Set tick queue position; event data type = #snd_seq_ev_queue_control_t */
00092       SND_SEQ_EVENT_SETPOS_TICK,
      /** Set real-time queue position; event data type = #snd_seq_ev_queue_control_t */
00094       SND_SEQ_EVENT_SETPOS_TIME,
      /** (SMF) Tempo event; event data type = #snd_seq_ev_queue_control_t */
00096       SND_SEQ_EVENT_TEMPO,
      /** MIDI Real Time Clock message; event data type = #snd_seq_ev_queue_control_t */
00098       SND_SEQ_EVENT_CLOCK,
      /** MIDI Real Time Tick message; event data type = #snd_seq_ev_queue_control_t */
00100       SND_SEQ_EVENT_TICK,
      /** Queue timer skew; event data type = #snd_seq_ev_queue_control_t */
00102       SND_SEQ_EVENT_QUEUE_SKEW,
      /** Sync position changed; event data type = #snd_seq_ev_queue_control_t */
00104       SND_SEQ_EVENT_SYNC_POS,

      /** Tune request; event data type = none */
00107       SND_SEQ_EVENT_TUNE_REQUEST = 40,
      /** Reset to power-on state; event data type = none */
00109       SND_SEQ_EVENT_RESET,
      /** Active sensing event; event data type = none */
00111       SND_SEQ_EVENT_SENSING,

      /** Echo-back event; event data type = any type */
00114       SND_SEQ_EVENT_ECHO = 50,
      /** OSS emulation raw event; event data type = any type */
00116       SND_SEQ_EVENT_OSS,

      /** New client has connected; event data type = #snd_seq_addr_t */
00119       SND_SEQ_EVENT_CLIENT_START = 60,
      /** Client has left the system; event data type = #snd_seq_addr_t */
00121       SND_SEQ_EVENT_CLIENT_EXIT,
      /** Client status/info has changed; event data type = #snd_seq_addr_t */
00123       SND_SEQ_EVENT_CLIENT_CHANGE,
      /** New port was created; event data type = #snd_seq_addr_t */
00125       SND_SEQ_EVENT_PORT_START,
      /** Port was deleted from system; event data type = #snd_seq_addr_t */
00127       SND_SEQ_EVENT_PORT_EXIT,
      /** Port status/info has changed; event data type = #snd_seq_addr_t */
00129       SND_SEQ_EVENT_PORT_CHANGE,

      /** Ports connected; event data type = #snd_seq_connect_t */
00132       SND_SEQ_EVENT_PORT_SUBSCRIBED,
      /** Ports disconnected; event data type = #snd_seq_connect_t */
00134       SND_SEQ_EVENT_PORT_UNSUBSCRIBED,

      /** Sample select; event data type = #snd_seq_ev_sample_control_t */
00137       SND_SEQ_EVENT_SAMPLE = 70,
      /** Sample cluster select; event data type = #snd_seq_ev_sample_control_t */
00139       SND_SEQ_EVENT_SAMPLE_CLUSTER,
      /** voice start */
00141       SND_SEQ_EVENT_SAMPLE_START,
      /** voice stop */
00143       SND_SEQ_EVENT_SAMPLE_STOP,
      /** playback frequency */
00145       SND_SEQ_EVENT_SAMPLE_FREQ,
      /** volume and balance */
00147       SND_SEQ_EVENT_SAMPLE_VOLUME,
      /** sample loop */
00149       SND_SEQ_EVENT_SAMPLE_LOOP,
      /** sample position */
00151       SND_SEQ_EVENT_SAMPLE_POSITION,
      /** private (hardware dependent) event */
00153       SND_SEQ_EVENT_SAMPLE_PRIVATE1,

      /** user-defined event; event data type = any (fixed size) */
00156       SND_SEQ_EVENT_USR0 = 90,
      /** user-defined event; event data type = any (fixed size) */
00158       SND_SEQ_EVENT_USR1,
      /** user-defined event; event data type = any (fixed size) */
00160       SND_SEQ_EVENT_USR2,
      /** user-defined event; event data type = any (fixed size) */
00162       SND_SEQ_EVENT_USR3,
      /** user-defined event; event data type = any (fixed size) */
00164       SND_SEQ_EVENT_USR4,
      /** user-defined event; event data type = any (fixed size) */
00166       SND_SEQ_EVENT_USR5,
      /** user-defined event; event data type = any (fixed size) */
00168       SND_SEQ_EVENT_USR6,
      /** user-defined event; event data type = any (fixed size) */
00170       SND_SEQ_EVENT_USR7,
      /** user-defined event; event data type = any (fixed size) */
00172       SND_SEQ_EVENT_USR8,
      /** user-defined event; event data type = any (fixed size) */
00174       SND_SEQ_EVENT_USR9,

      /** begin of instrument management */
00177       SND_SEQ_EVENT_INSTR_BEGIN = 100,
      /** end of instrument management */
00179       SND_SEQ_EVENT_INSTR_END,
      /** query instrument interface info */
00181       SND_SEQ_EVENT_INSTR_INFO,
      /** result of instrument interface info */
00183       SND_SEQ_EVENT_INSTR_INFO_RESULT,
      /** query instrument format info */
00185       SND_SEQ_EVENT_INSTR_FINFO,
      /** result of instrument format info */
00187       SND_SEQ_EVENT_INSTR_FINFO_RESULT,
      /** reset instrument instrument memory */
00189       SND_SEQ_EVENT_INSTR_RESET,
      /** get instrument interface status */
00191       SND_SEQ_EVENT_INSTR_STATUS,
      /** result of instrument interface status */
00193       SND_SEQ_EVENT_INSTR_STATUS_RESULT,
      /** put an instrument to port */
00195       SND_SEQ_EVENT_INSTR_PUT,
      /** get an instrument from port */
00197       SND_SEQ_EVENT_INSTR_GET,
      /** result of instrument query */
00199       SND_SEQ_EVENT_INSTR_GET_RESULT,
      /** free instrument(s) */
00201       SND_SEQ_EVENT_INSTR_FREE,
      /** get instrument list */
00203       SND_SEQ_EVENT_INSTR_LIST,
      /** result of instrument list */
00205       SND_SEQ_EVENT_INSTR_LIST_RESULT,
      /** set cluster parameters */
00207       SND_SEQ_EVENT_INSTR_CLUSTER,
      /** get cluster parameters */
00209       SND_SEQ_EVENT_INSTR_CLUSTER_GET,
      /** result of cluster parameters */
00211       SND_SEQ_EVENT_INSTR_CLUSTER_RESULT,
      /** instrument change */
00213       SND_SEQ_EVENT_INSTR_CHANGE,

      /** system exclusive data (variable length);  event data type = #snd_seq_ev_ext_t */
00216       SND_SEQ_EVENT_SYSEX = 130,
      /** error event;  event data type = #snd_seq_ev_ext_t */
00218       SND_SEQ_EVENT_BOUNCE,
      /** reserved for user apps;  event data type = #snd_seq_ev_ext_t */
00220       SND_SEQ_EVENT_USR_VAR0 = 135,
      /** reserved for user apps; event data type = #snd_seq_ev_ext_t */
00222       SND_SEQ_EVENT_USR_VAR1,
      /** reserved for user apps; event data type = #snd_seq_ev_ext_t */
00224       SND_SEQ_EVENT_USR_VAR2,
      /** reserved for user apps; event data type = #snd_seq_ev_ext_t */
00226       SND_SEQ_EVENT_USR_VAR3,
      /** reserved for user apps; event data type = #snd_seq_ev_ext_t */
00228       SND_SEQ_EVENT_USR_VAR4,

      /** NOP; ignored in any case */
00231       SND_SEQ_EVENT_NONE = 255
};


/** Sequencer event address */
00236 typedef struct snd_seq_addr {
00237       unsigned char client;   /**< Client id */
00238       unsigned char port;     /**< Port id */
} snd_seq_addr_t;

/** Connection (subscription) between ports */
00242 typedef struct snd_seq_connect {
00243       snd_seq_addr_t sender;  /**< sender address */
00244       snd_seq_addr_t dest;    /**< destination address */
} snd_seq_connect_t;


/** Real-time data record */
00249 typedef struct snd_seq_real_time {
00250       unsigned int tv_sec;          /**< seconds */
00251       unsigned int tv_nsec;         /**< nanoseconds */
} snd_seq_real_time_t;

/** (MIDI) Tick-time data record */
00255 typedef unsigned int snd_seq_tick_time_t;

/** unioned time stamp */
00258 typedef union snd_seq_timestamp {
00259       snd_seq_tick_time_t tick;     /**< tick-time */
00260       struct snd_seq_real_time time;      /**< real-time */
} snd_seq_timestamp_t;


/**
 * Event mode flags
 *
 * NOTE: only 8 bits available!
 */
00269 #define SND_SEQ_TIME_STAMP_TICK           (0<<0)      /**< timestamp in clock ticks */
00270 #define SND_SEQ_TIME_STAMP_REAL           (1<<0)      /**< timestamp in real time */
00271 #define SND_SEQ_TIME_STAMP_MASK           (1<<0)      /**< mask for timestamp bits */

00273 #define SND_SEQ_TIME_MODE_ABS       (0<<1)      /**< absolute timestamp */
00274 #define SND_SEQ_TIME_MODE_REL       (1<<1)      /**< relative to current time */
00275 #define SND_SEQ_TIME_MODE_MASK            (1<<1)      /**< mask for time mode bits */

00277 #define SND_SEQ_EVENT_LENGTH_FIXED  (0<<2)      /**< fixed event size */
00278 #define SND_SEQ_EVENT_LENGTH_VARIABLE     (1<<2)      /**< variable event size */
00279 #define SND_SEQ_EVENT_LENGTH_VARUSR (2<<2)      /**< variable event size - user memory space */
00280 #define SND_SEQ_EVENT_LENGTH_MASK   (3<<2)      /**< mask for event length bits */

00282 #define SND_SEQ_PRIORITY_NORMAL           (0<<4)      /**< normal priority */
00283 #define SND_SEQ_PRIORITY_HIGH       (1<<4)      /**< event should be processed before others */
00284 #define SND_SEQ_PRIORITY_MASK       (1<<4)      /**< mask for priority bits */


/** Note event */
00288 typedef struct snd_seq_ev_note {
00289       unsigned char channel;        /**< channel number */
00290       unsigned char note;           /**< note */
00291       unsigned char velocity;       /**< velocity */
00292       unsigned char off_velocity;   /**< note-off velocity; only for #SND_SEQ_EVENT_NOTE */
00293       unsigned int duration;        /**< duration until note-off; only for #SND_SEQ_EVENT_NOTE */
} snd_seq_ev_note_t;

/** Controller event */
00297 typedef struct snd_seq_ev_ctrl {
00298       unsigned char channel;        /**< channel number */
00299       unsigned char unused[3];      /**< reserved */
00300       unsigned int param;           /**< control parameter */
00301       signed int value;       /**< control value */
} snd_seq_ev_ctrl_t;

/** generic set of bytes (12x8 bit) */
00305 typedef struct snd_seq_ev_raw8 {
00306       unsigned char d[12];          /**< 8 bit value */
} snd_seq_ev_raw8_t;

/** generic set of integers (3x32 bit) */
00310 typedef struct snd_seq_ev_raw32 {
00311       unsigned int d[3];            /**< 32 bit value */
} snd_seq_ev_raw32_t;

/** external stored data */
00315 typedef struct snd_seq_ev_ext {
00316       unsigned int len;       /**< length of data */
00317       void *ptr;              /**< pointer to data (note: can be 64-bit) */
} __attribute__((packed)) snd_seq_ev_ext_t;
00319 
00320 /** Instrument cluster type */
00321 typedef unsigned int snd_seq_instr_cluster_t;

/** Instrument type */
00324 typedef struct snd_seq_instr {
00325       snd_seq_instr_cluster_t cluster;    /**< cluster id */
00326       unsigned int std; /**< instrument standard id; the upper byte means a private instrument (owner - client id) */
00327       unsigned short bank;    /**< instrument bank id */
00328       unsigned short prg;     /**< instrument program id */
} snd_seq_instr_t;

/** sample number */
00332 typedef struct snd_seq_ev_sample {
00333       unsigned int std; /**< sample standard id */
00334       unsigned short bank;    /**< sample bank id */
00335       unsigned short prg;     /**< sample program id */
} snd_seq_ev_sample_t;

/** sample cluster */
00339 typedef struct snd_seq_ev_cluster {
00340       snd_seq_instr_cluster_t cluster;    /**< cluster id */
} snd_seq_ev_cluster_t;

/** sample position */
00344 typedef unsigned int snd_seq_position_t; /**< playback position (in samples) * 16 */

/** sample stop mode */
00347 typedef enum snd_seq_stop_mode {
00348       SND_SEQ_SAMPLE_STOP_IMMEDIATELY = 0,      /**< terminate playing immediately */
00349       SND_SEQ_SAMPLE_STOP_VENVELOPE = 1,  /**< finish volume envelope */
00350       SND_SEQ_SAMPLE_STOP_LOOP = 2        /**< terminate loop and finish wave */
} snd_seq_stop_mode_t;

/** sample frequency */
00354 typedef int snd_seq_frequency_t; /**< playback frequency in HZ * 16 */

/** sample volume control; if any value is set to -1 == do not change */
00357 typedef struct snd_seq_ev_volume {
00358       signed short volume;    /**< range: 0-16383 */
00359       signed short lr;  /**< left-right balance; range: 0-16383 */
00360       signed short fr;  /**< front-rear balance; range: 0-16383 */
00361       signed short du;  /**< down-up balance; range: 0-16383 */
} snd_seq_ev_volume_t;

/** simple loop redefinition */
00365 typedef struct snd_seq_ev_loop {
00366       unsigned int start;     /**< loop start (in samples) * 16 */
00367       unsigned int end; /**< loop end (in samples) * 16 */
} snd_seq_ev_loop_t;

/** Sample control events */
00371 typedef struct snd_seq_ev_sample_control {
00372       unsigned char channel;        /**< channel */
00373       unsigned char unused[3];      /**< reserved */
      union {
00375             snd_seq_ev_sample_t sample;   /**< sample number */
00376             snd_seq_ev_cluster_t cluster; /**< cluster number */
00377             snd_seq_position_t position;  /**< position */
00378             snd_seq_stop_mode_t stop_mode;      /**< stop mode */
00379             snd_seq_frequency_t frequency;      /**< frequency */
00380             snd_seq_ev_volume_t volume;   /**< volume */
00381             snd_seq_ev_loop_t loop;       /**< loop control */
00382             unsigned char raw8[8];        /**< raw 8-bit */
      } param;          /**< control parameters */
} snd_seq_ev_sample_control_t;



/** INSTR_BEGIN event */
00389 typedef struct snd_seq_ev_instr_begin {
00390       int timeout;            /**< zero = forever, otherwise timeout in ms */
} snd_seq_ev_instr_begin_t;

/** Result events */
00394 typedef struct snd_seq_result {
00395       int event;        /**< processed event type */
00396       int result;       /**< status */
} snd_seq_result_t;

/** Queue skew values */
00400 typedef struct snd_seq_queue_skew {
00401       unsigned int value;     /**< skew value */
00402       unsigned int base;      /**< skew base */
} snd_seq_queue_skew_t;

/** queue timer control */
00406 typedef struct snd_seq_ev_queue_control {
00407       unsigned char queue;                /**< affected queue */
00408       unsigned char unused[3];            /**< reserved */
      union {
00410             signed int value;       /**< affected value (e.g. tempo) */
00411             snd_seq_timestamp_t time;     /**< time */
00412             unsigned int position;        /**< sync position */
00413             snd_seq_queue_skew_t skew;    /**< queue skew */
00414             unsigned int d32[2];          /**< any data */
00415             unsigned char d8[8];          /**< any data */
      } param;                      /**< data value union */
} snd_seq_ev_queue_control_t;


/** Sequencer event */
00421 typedef struct snd_seq_event {
00422       snd_seq_event_type_t type;    /**< event type */
00423       unsigned char flags;          /**< event flags */
00424       unsigned char tag;            /**< tag */
      
00426       unsigned char queue;          /**< schedule queue */
00427       snd_seq_timestamp_t time;     /**< schedule time */

00429       snd_seq_addr_t source;        /**< source address */
00430       snd_seq_addr_t dest;          /**< destination address */

      union {
00433             snd_seq_ev_note_t note;       /**< note information */
00434             snd_seq_ev_ctrl_t control;    /**< MIDI control information */
00435             snd_seq_ev_raw8_t raw8;       /**< raw8 data */
00436             snd_seq_ev_raw32_t raw32;     /**< raw32 data */
00437             snd_seq_ev_ext_t ext;         /**< external data */
00438             snd_seq_ev_queue_control_t queue; /**< queue control */
            snd_seq_timestamp_t time;     /**< timestamp */
00440             snd_seq_addr_t addr;          /**< address */
00441             snd_seq_connect_t connect;    /**< connect information */
00442             snd_seq_result_t result;      /**< operation result code */
00443             snd_seq_ev_instr_begin_t instr_begin; /**< instrument */
00444             snd_seq_ev_sample_control_t sample; /**< sample control */
      } data;                       /**< event data... */
} snd_seq_event_t;


/** \} */

#endif /* __ALSA_SEQ_EVENT_H */


Generated by  Doxygen 1.6.0   Back to index