Logo Search packages:      
Sourcecode: csound version File versions

seq_event.h

/**
 * \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 */
00235 typedef struct snd_seq_addr {
00236         unsigned char client;   /**< Client id */
00237         unsigned char port;     /**< Port id */
} snd_seq_addr_t;

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

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

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

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

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

00270 #define SND_SEQ_TIME_MODE_ABS           (0<<1)  /**< absolute timestamp */
00271 #define SND_SEQ_TIME_MODE_REL           (1<<1)  /**< relative to current time */
00272 #define SND_SEQ_TIME_MODE_MASK          (1<<1)  /**< mask for time mode bits */

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

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

/** Note event */
00284 typedef struct snd_seq_ev_note {
00285         unsigned char channel;          /**< channel number */
00286         unsigned char note;             /**< note */
00287         unsigned char velocity;         /**< velocity */
00288         unsigned char off_velocity;     /**< note-off velocity; only for #SND_SEQ_EVENT_NOTE */
00289         unsigned int duration;          /**< duration until note-off; only for #SND_SEQ_EVENT_NOTE */
} snd_seq_ev_note_t;

/** Controller event */
00293 typedef struct snd_seq_ev_ctrl {
00294         unsigned char channel;          /**< channel number */
00295         unsigned char unused[3];        /**< reserved */
00296         unsigned int param;             /**< control parameter */
00297         signed int value;               /**< control value */
} snd_seq_ev_ctrl_t;

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

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

/** external stored data */
00311 typedef struct snd_seq_ev_ext {
00312         unsigned int len;               /**< length of data */
00313         void *ptr;                      /**< pointer to data (note: can be 64-bit) */
} __attribute__((packed)) snd_seq_ev_ext_t;

/** Instrument cluster type */
00317 typedef unsigned int snd_seq_instr_cluster_t;

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

/** sample number */
00328 typedef struct snd_seq_ev_sample {
00329         unsigned int std;       /**< sample standard id */
00330         unsigned short bank;    /**< sample bank id */
00331         unsigned short prg;     /**< sample program id */
} snd_seq_ev_sample_t;

/** sample cluster */
00335 typedef struct snd_seq_ev_cluster {
00336         snd_seq_instr_cluster_t cluster;        /**< cluster id */
} snd_seq_ev_cluster_t;

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

/** sample stop mode */
00343 typedef enum snd_seq_stop_mode {
00344         SND_SEQ_SAMPLE_STOP_IMMEDIATELY = 0,    /**< terminate playing immediately */
00345         SND_SEQ_SAMPLE_STOP_VENVELOPE = 1,      /**< finish volume envelope */
00346         SND_SEQ_SAMPLE_STOP_LOOP = 2            /**< terminate loop and finish wave */
} snd_seq_stop_mode_t;

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

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

/** simple loop redefinition */
00361 typedef struct snd_seq_ev_loop {
00362         unsigned int start;     /**< loop start (in samples) * 16 */
00363         unsigned int end;       /**< loop end (in samples) * 16 */
} snd_seq_ev_loop_t;

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

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

/** Result events */
00388 typedef struct snd_seq_result {
00389         int event;              /**< processed event type */
00390         int result;             /**< status */
} snd_seq_result_t;

/** Queue skew values */
00394 typedef struct snd_seq_queue_skew {
00395         unsigned int value;     /**< skew value */
00396         unsigned int base;      /**< skew base */
} snd_seq_queue_skew_t;

/** queue timer control */
00400 typedef struct snd_seq_ev_queue_control {
00401         unsigned char queue;                    /**< affected queue */
00402         unsigned char unused[3];                /**< reserved */
        union {
00404                 signed int value;               /**< affected value (e.g. tempo) */
00405                 snd_seq_timestamp_t time;       /**< time */
00406                 unsigned int position;          /**< sync position */
00407                 snd_seq_queue_skew_t skew;      /**< queue skew */
00408                 unsigned int d32[2];            /**< any data */
00409                 unsigned char d8[8];            /**< any data */
        } param;                                /**< data value union */
} snd_seq_ev_queue_control_t;

/** Sequencer event */
00414 typedef struct snd_seq_event {
00415         snd_seq_event_type_t type;      /**< event type */
00416         unsigned char flags;            /**< event flags */
00417         unsigned char tag;              /**< tag */

00419         unsigned char queue;            /**< schedule queue */
00420         snd_seq_timestamp_t time;       /**< schedule time */

00422         snd_seq_addr_t source;          /**< source address */
00423         snd_seq_addr_t dest;            /**< destination address */

        union {
00426                 snd_seq_ev_note_t note;         /**< note information */
00427                 snd_seq_ev_ctrl_t control;      /**< MIDI control information */
00428                 snd_seq_ev_raw8_t raw8;         /**< raw8 data */
00429                 snd_seq_ev_raw32_t raw32;       /**< raw32 data */
00430                 snd_seq_ev_ext_t ext;           /**< external data */
00431                 snd_seq_ev_queue_control_t queue; /**< queue control */
                snd_seq_timestamp_t time;       /**< timestamp */
00433                 snd_seq_addr_t addr;            /**< address */
00434                 snd_seq_connect_t connect;      /**< connect information */
00435                 snd_seq_result_t result;        /**< operation result code */
00436                 snd_seq_ev_instr_begin_t instr_begin; /**< instrument */
00437                 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