jpayne@69: /** jpayne@69: * \file include/seqmid.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_SEQMID_H jpayne@69: #define __ALSA_SEQMID_H jpayne@69: jpayne@69: #ifdef __cplusplus jpayne@69: extern "C" { jpayne@69: #endif jpayne@69: jpayne@69: /** jpayne@69: * \defgroup SeqMiddle Sequencer Middle Level Interface jpayne@69: * Sequencer Middle Level Interface jpayne@69: * \ingroup Sequencer jpayne@69: * \{ jpayne@69: */ jpayne@69: jpayne@69: /** jpayne@69: * \brief initialize event record jpayne@69: * \param ev event record pointer jpayne@69: * jpayne@69: * This macro clears the given event record pointer to the default status. jpayne@69: */ jpayne@69: #define snd_seq_ev_clear(ev) \ jpayne@69: memset(ev, 0, sizeof(snd_seq_event_t)) jpayne@69: jpayne@69: /** jpayne@69: * \brief set the tag for given event jpayne@69: * \param ev event record jpayne@69: * \param t event tag jpayne@69: * jpayne@69: * This macro sets the tag to the given event record. jpayne@69: */ jpayne@69: #define snd_seq_ev_set_tag(ev,t) \ jpayne@69: ((ev)->tag = (t)) jpayne@69: jpayne@69: /** jpayne@69: * \brief set the explicit destination jpayne@69: * \param ev event record jpayne@69: * \param c destination client id jpayne@69: * \param p destination port id jpayne@69: * jpayne@69: * This macro sets the client and port id numbers to the given event record. jpayne@69: * jpayne@69: * \sa snd_seq_ev_set_subs() jpayne@69: */ jpayne@69: #define snd_seq_ev_set_dest(ev,c,p) \ jpayne@69: ((ev)->dest.client = (c), (ev)->dest.port = (p)) jpayne@69: jpayne@69: /** jpayne@69: * \brief set broadcasting to subscribers jpayne@69: * \param ev event record jpayne@69: * jpayne@69: * This macro sets the destination as the subscribers. jpayne@69: * jpayne@69: * \sa snd_seq_ev_set_dest() jpayne@69: */ jpayne@69: #define snd_seq_ev_set_subs(ev) \ jpayne@69: ((ev)->dest.client = SND_SEQ_ADDRESS_SUBSCRIBERS,\ jpayne@69: (ev)->dest.port = SND_SEQ_ADDRESS_UNKNOWN) jpayne@69: jpayne@69: /** jpayne@69: * \brief set broadcasting to all clients/ports jpayne@69: * \param ev event record jpayne@69: * jpayne@69: * This macro sets the destination as the broadcasting. jpayne@69: * jpayne@69: * \sa snd_seq_ev_set_dest() jpayne@69: */ jpayne@69: #define snd_seq_ev_set_broadcast(ev) \ jpayne@69: ((ev)->dest.client = SND_SEQ_ADDRESS_BROADCAST,\ jpayne@69: (ev)->dest.port = SND_SEQ_ADDRESS_BROADCAST) jpayne@69: jpayne@69: /** jpayne@69: * \brief set the source port jpayne@69: * \param ev event record jpayne@69: * \param p source port id jpayne@69: * jpayne@69: * This macro sets the source port id number. jpayne@69: */ jpayne@69: #define snd_seq_ev_set_source(ev,p) \ jpayne@69: ((ev)->source.port = (p)) jpayne@69: jpayne@69: /** jpayne@69: * \brief set direct passing mode (without queued) jpayne@69: * \param ev event instance jpayne@69: * jpayne@69: * This macro sets the event to the direct passing mode jpayne@69: * to be delivered immediately without queueing. jpayne@69: * jpayne@69: * \sa snd_seq_ev_schedule_tick(), snd_seq_ev_schedule_real() jpayne@69: */ jpayne@69: #define snd_seq_ev_set_direct(ev) \ jpayne@69: ((ev)->queue = SND_SEQ_QUEUE_DIRECT) jpayne@69: jpayne@69: /** jpayne@69: * \brief set tick-scheduling mode on queue jpayne@69: * \param ev event instance jpayne@69: * \param q queue id to schedule jpayne@69: * \param relative relative time-stamp if non-zero jpayne@69: * \param ttick tick time-stamp to be delivered jpayne@69: * jpayne@69: * This macro sets the scheduling of the event in the jpayne@69: * MIDI tick mode. jpayne@69: * jpayne@69: * \sa snd_seq_ev_schedule_real(), snd_seq_ev_set_direct() jpayne@69: */ jpayne@69: #define snd_seq_ev_schedule_tick(ev, q, relative, ttick) \ jpayne@69: ((ev)->flags &= ~(SND_SEQ_TIME_STAMP_MASK | SND_SEQ_TIME_MODE_MASK),\ jpayne@69: (ev)->flags |= SND_SEQ_TIME_STAMP_TICK,\ jpayne@69: (ev)->flags |= (relative) ? SND_SEQ_TIME_MODE_REL : SND_SEQ_TIME_MODE_ABS,\ jpayne@69: (ev)->time.tick = (ttick),\ jpayne@69: (ev)->queue = (q)) jpayne@69: jpayne@69: /** jpayne@69: * \brief set real-time-scheduling mode on queue jpayne@69: * \param ev event instance jpayne@69: * \param q queue id to schedule jpayne@69: * \param relative relative time-stamp if non-zero jpayne@69: * \param rtime time-stamp to be delivered jpayne@69: * jpayne@69: * This macro sets the scheduling of the event in the jpayne@69: * realtime mode. jpayne@69: * jpayne@69: * \sa snd_seq_ev_schedule_tick(), snd_seq_ev_set_direct() jpayne@69: */ jpayne@69: #define snd_seq_ev_schedule_real(ev, q, relative, rtime) \ jpayne@69: ((ev)->flags &= ~(SND_SEQ_TIME_STAMP_MASK | SND_SEQ_TIME_MODE_MASK),\ jpayne@69: (ev)->flags |= SND_SEQ_TIME_STAMP_REAL,\ jpayne@69: (ev)->flags |= (relative) ? SND_SEQ_TIME_MODE_REL : SND_SEQ_TIME_MODE_ABS,\ jpayne@69: (ev)->time.time = *(rtime),\ jpayne@69: (ev)->queue = (q)) jpayne@69: jpayne@69: /** jpayne@69: * \brief set event priority jpayne@69: * \param ev event instance jpayne@69: * \param high_prior 1 for high priority mode jpayne@69: */ jpayne@69: #define snd_seq_ev_set_priority(ev, high_prior) \ jpayne@69: ((ev)->flags &= ~SND_SEQ_PRIORITY_MASK,\ jpayne@69: (ev)->flags |= (high_prior) ? SND_SEQ_PRIORITY_HIGH : SND_SEQ_PRIORITY_NORMAL) jpayne@69: jpayne@69: /** jpayne@69: * \brief set fixed data jpayne@69: * \param ev event instance jpayne@69: * jpayne@69: * Sets the event length mode as fixed size. jpayne@69: * jpayne@69: * \sa snd_seq_ev_set_variable(), snd_seq_ev_set_varusr() jpayne@69: */ jpayne@69: #define snd_seq_ev_set_fixed(ev) \ jpayne@69: ((ev)->flags &= ~SND_SEQ_EVENT_LENGTH_MASK,\ jpayne@69: (ev)->flags |= SND_SEQ_EVENT_LENGTH_FIXED) jpayne@69: jpayne@69: /** jpayne@69: * \brief set variable data jpayne@69: * \param ev event instance jpayne@69: * \param datalen length of the external data jpayne@69: * \param dataptr pointer of the external data jpayne@69: * jpayne@69: * Sets the event length mode as variable length and stores the data. jpayne@69: * jpayne@69: * \sa snd_seq_ev_set_fixed(), snd_seq_ev_set_varusr() jpayne@69: */ jpayne@69: #define snd_seq_ev_set_variable(ev, datalen, dataptr) \ jpayne@69: ((ev)->flags &= ~SND_SEQ_EVENT_LENGTH_MASK,\ jpayne@69: (ev)->flags |= SND_SEQ_EVENT_LENGTH_VARIABLE,\ jpayne@69: (ev)->data.ext.len = (datalen),\ jpayne@69: (ev)->data.ext.ptr = (dataptr)) jpayne@69: jpayne@69: /** jpayne@69: * \brief set varusr data jpayne@69: * \param ev event instance jpayne@69: * \param datalen length of the external data jpayne@69: * \param dataptr pointer of the external data jpayne@69: * jpayne@69: * Sets the event length mode as variable user-space data and stores the data. jpayne@69: * jpayne@69: * \sa snd_seq_ev_set_fixed(), snd_seq_ev_set_variable() jpayne@69: */ jpayne@69: #define snd_seq_ev_set_varusr(ev, datalen, dataptr) \ jpayne@69: ((ev)->flags &= ~SND_SEQ_EVENT_LENGTH_MASK,\ jpayne@69: (ev)->flags |= SND_SEQ_EVENT_LENGTH_VARUSR,\ jpayne@69: (ev)->data.ext.len = (datalen),\ jpayne@69: (ev)->data.ext.ptr = (dataptr)) jpayne@69: jpayne@69: /** jpayne@69: * \brief set queue controls jpayne@69: * \param ev event record jpayne@69: * \param typ event type jpayne@69: * \param q queue id jpayne@69: * \param val control value jpayne@69: */ jpayne@69: #define snd_seq_ev_set_queue_control(ev, typ, q, val) \ jpayne@69: ((ev)->type = (typ),\ jpayne@69: snd_seq_ev_set_dest(ev, SND_SEQ_CLIENT_SYSTEM, SND_SEQ_PORT_SYSTEM_TIMER),\ jpayne@69: (ev)->data.queue.queue = (q),\ jpayne@69: (ev)->data.queue.param.value = (val)) jpayne@69: jpayne@69: /** jpayne@69: * \brief set the start queue event jpayne@69: * \param ev event record jpayne@69: * \param q queue id to start jpayne@69: * jpayne@69: * \sa snd_seq_ev_set_queue_stop(), snd_seq_ev_set_queue_continue() jpayne@69: */ jpayne@69: #define snd_seq_ev_set_queue_start(ev, q) \ jpayne@69: snd_seq_ev_set_queue_control(ev, SND_SEQ_EVENT_START, q, 0) jpayne@69: jpayne@69: /** jpayne@69: * \brief set the stop queue event jpayne@69: * \param ev event record jpayne@69: * \param q queue id to stop jpayne@69: * jpayne@69: * \sa snd_seq_ev_set_queue_start(), snd_seq_ev_set_queue_continue() jpayne@69: */ jpayne@69: #define snd_seq_ev_set_queue_stop(ev, q) \ jpayne@69: snd_seq_ev_set_queue_control(ev, SND_SEQ_EVENT_STOP, q, 0) jpayne@69: jpayne@69: /** jpayne@69: * \brief set the stop queue event jpayne@69: * \param ev event record jpayne@69: * \param q queue id to continue jpayne@69: * jpayne@69: * \sa snd_seq_ev_set_queue_start(), snd_seq_ev_set_queue_stop() jpayne@69: */ jpayne@69: #define snd_seq_ev_set_queue_continue(ev, q) \ jpayne@69: snd_seq_ev_set_queue_control(ev, SND_SEQ_EVENT_CONTINUE, q, 0) jpayne@69: jpayne@69: /** jpayne@69: * \brief set the stop queue event jpayne@69: * \param ev event record jpayne@69: * \param q queue id to change tempo jpayne@69: * \param val the new tempo value jpayne@69: */ jpayne@69: #define snd_seq_ev_set_queue_tempo(ev, q, val) \ jpayne@69: snd_seq_ev_set_queue_control(ev, SND_SEQ_EVENT_TEMPO, q, val) jpayne@69: jpayne@69: /** jpayne@69: * \brief set the real-time position of a queue jpayne@69: * \param ev event record jpayne@69: * \param q queue id to change tempo jpayne@69: * \param rtime the new real-time pointer jpayne@69: */ jpayne@69: #define snd_seq_ev_set_queue_pos_real(ev, q, rtime) \ jpayne@69: ((ev)->type = SND_SEQ_EVENT_SETPOS_TIME,\ jpayne@69: snd_seq_ev_set_dest(ev, SND_SEQ_CLIENT_SYSTEM, SND_SEQ_PORT_SYSTEM_TIMER),\ jpayne@69: (ev)->data.queue.queue = (q),\ jpayne@69: (ev)->data.queue.param.time.time = *(rtime)) jpayne@69: jpayne@69: /** jpayne@69: * \brief set the tick-time position of a queue jpayne@69: * \param ev event record jpayne@69: * \param q queue id to change tempo jpayne@69: * \param ttime the new tick-time jpayne@69: */ jpayne@69: #define snd_seq_ev_set_queue_pos_tick(ev, q, ttime) \ jpayne@69: ((ev)->type = SND_SEQ_EVENT_SETPOS_TICK,\ jpayne@69: snd_seq_ev_set_dest(ev, SND_SEQ_CLIENT_SYSTEM, SND_SEQ_PORT_SYSTEM_TIMER),\ jpayne@69: (ev)->data.queue.queue = (q),\ jpayne@69: (ev)->data.queue.param.time.tick = (ttime)) jpayne@69: jpayne@69: /* set and send a queue control event */ jpayne@69: int snd_seq_control_queue(snd_seq_t *seq, int q, int type, int value, snd_seq_event_t *ev); jpayne@69: jpayne@69: /** jpayne@69: * \brief start the specified queue jpayne@69: * \param seq sequencer handle jpayne@69: * \param q queue id to start jpayne@69: * \param ev optional event record (see #snd_seq_control_queue) jpayne@69: */ jpayne@69: #define snd_seq_start_queue(seq, q, ev) \ jpayne@69: snd_seq_control_queue(seq, q, SND_SEQ_EVENT_START, 0, ev) jpayne@69: jpayne@69: /** jpayne@69: * \brief stop the specified queue jpayne@69: * \param seq sequencer handle jpayne@69: * \param q queue id to stop jpayne@69: * \param ev optional event record (see #snd_seq_control_queue) jpayne@69: */ jpayne@69: #define snd_seq_stop_queue(seq, q, ev) \ jpayne@69: snd_seq_control_queue(seq, q, SND_SEQ_EVENT_STOP, 0, ev) jpayne@69: jpayne@69: /** jpayne@69: * \brief continue the specified queue jpayne@69: * \param seq sequencer handle jpayne@69: * \param q queue id to continue jpayne@69: * \param ev optional event record (see #snd_seq_control_queue) jpayne@69: */ jpayne@69: #define snd_seq_continue_queue(seq, q, ev) \ jpayne@69: snd_seq_control_queue(seq, q, SND_SEQ_EVENT_CONTINUE, 0, ev) jpayne@69: jpayne@69: /** jpayne@69: * \brief change the tempo of the specified queue jpayne@69: * \param seq sequencer handle jpayne@69: * \param q queue id jpayne@69: * \param tempo the new tempo value jpayne@69: * \param ev optional event record (see #snd_seq_control_queue) jpayne@69: */ jpayne@69: #define snd_seq_change_queue_tempo(seq, q, tempo, ev) \ jpayne@69: snd_seq_control_queue(seq, q, SND_SEQ_EVENT_TEMPO, tempo, ev) jpayne@69: jpayne@69: /* create a port - simple version - return the port number */ jpayne@69: int snd_seq_create_simple_port(snd_seq_t *seq, const char *name, jpayne@69: unsigned int caps, unsigned int type); jpayne@69: /* delete the port */ jpayne@69: int snd_seq_delete_simple_port(snd_seq_t *seq, int port); jpayne@69: jpayne@69: /* simple subscription between this port and another port jpayne@69: (w/o exclusive & time conversion) jpayne@69: */ jpayne@69: int snd_seq_connect_from(snd_seq_t *seq, int my_port, int src_client, int src_port); jpayne@69: int snd_seq_connect_to(snd_seq_t *seq, int my_port, int dest_client, int dest_port); jpayne@69: int snd_seq_disconnect_from(snd_seq_t *seq, int my_port, int src_client, int src_port); jpayne@69: int snd_seq_disconnect_to(snd_seq_t *seq, int my_port, int dest_client, int dest_port); jpayne@69: jpayne@69: /* jpayne@69: * set client information jpayne@69: */ jpayne@69: int snd_seq_set_client_name(snd_seq_t *seq, const char *name); jpayne@69: int snd_seq_set_client_event_filter(snd_seq_t *seq, int event_type); jpayne@69: int snd_seq_set_client_pool_output(snd_seq_t *seq, size_t size); jpayne@69: int snd_seq_set_client_pool_output_room(snd_seq_t *seq, size_t size); jpayne@69: int snd_seq_set_client_pool_input(snd_seq_t *seq, size_t size); jpayne@69: /* sync output queue */ jpayne@69: int snd_seq_sync_output_queue(snd_seq_t *seq); jpayne@69: jpayne@69: /* jpayne@69: * parse the given string and get the sequencer address jpayne@69: */ jpayne@69: int snd_seq_parse_address(snd_seq_t *seq, snd_seq_addr_t *addr, const char *str); jpayne@69: jpayne@69: /* jpayne@69: * reset client input/output pool jpayne@69: */ jpayne@69: int snd_seq_reset_pool_output(snd_seq_t *seq); jpayne@69: int snd_seq_reset_pool_input(snd_seq_t *seq); jpayne@69: jpayne@69: /** jpayne@69: * \brief set note event jpayne@69: * \param ev event record jpayne@69: * \param ch channel number jpayne@69: * \param key note key jpayne@69: * \param vel velocity jpayne@69: * \param dur duration (in tick or msec) jpayne@69: */ jpayne@69: #define snd_seq_ev_set_note(ev, ch, key, vel, dur) \ jpayne@69: ((ev)->type = SND_SEQ_EVENT_NOTE,\ jpayne@69: snd_seq_ev_set_fixed(ev),\ jpayne@69: (ev)->data.note.channel = (ch),\ jpayne@69: (ev)->data.note.note = (key),\ jpayne@69: (ev)->data.note.velocity = (vel),\ jpayne@69: (ev)->data.note.duration = (dur)) jpayne@69: jpayne@69: /** jpayne@69: * \brief set note-on event jpayne@69: * \param ev event record jpayne@69: * \param ch channel number jpayne@69: * \param key note key jpayne@69: * \param vel velocity jpayne@69: */ jpayne@69: #define snd_seq_ev_set_noteon(ev, ch, key, vel) \ jpayne@69: ((ev)->type = SND_SEQ_EVENT_NOTEON,\ jpayne@69: snd_seq_ev_set_fixed(ev),\ jpayne@69: (ev)->data.note.channel = (ch),\ jpayne@69: (ev)->data.note.note = (key),\ jpayne@69: (ev)->data.note.velocity = (vel)) jpayne@69: jpayne@69: /** jpayne@69: * \brief set note-off event jpayne@69: * \param ev event record jpayne@69: * \param ch channel number jpayne@69: * \param key note key jpayne@69: * \param vel velocity jpayne@69: */ jpayne@69: #define snd_seq_ev_set_noteoff(ev, ch, key, vel) \ jpayne@69: ((ev)->type = SND_SEQ_EVENT_NOTEOFF,\ jpayne@69: snd_seq_ev_set_fixed(ev),\ jpayne@69: (ev)->data.note.channel = (ch),\ jpayne@69: (ev)->data.note.note = (key),\ jpayne@69: (ev)->data.note.velocity = (vel)) jpayne@69: jpayne@69: /** jpayne@69: * \brief set key-pressure event jpayne@69: * \param ev event record jpayne@69: * \param ch channel number jpayne@69: * \param key note key jpayne@69: * \param vel velocity jpayne@69: */ jpayne@69: #define snd_seq_ev_set_keypress(ev,ch,key,vel) \ jpayne@69: ((ev)->type = SND_SEQ_EVENT_KEYPRESS,\ jpayne@69: snd_seq_ev_set_fixed(ev),\ jpayne@69: (ev)->data.note.channel = (ch),\ jpayne@69: (ev)->data.note.note = (key),\ jpayne@69: (ev)->data.note.velocity = (vel)) jpayne@69: jpayne@69: /** jpayne@69: * \brief set MIDI controller event jpayne@69: * \param ev event record jpayne@69: * \param ch channel number jpayne@69: * \param cc controller number jpayne@69: * \param val control value jpayne@69: */ jpayne@69: #define snd_seq_ev_set_controller(ev,ch,cc,val) \ jpayne@69: ((ev)->type = SND_SEQ_EVENT_CONTROLLER,\ jpayne@69: snd_seq_ev_set_fixed(ev),\ jpayne@69: (ev)->data.control.channel = (ch),\ jpayne@69: (ev)->data.control.param = (cc),\ jpayne@69: (ev)->data.control.value = (val)) jpayne@69: jpayne@69: /** jpayne@69: * \brief set program change event jpayne@69: * \param ev event record jpayne@69: * \param ch channel number jpayne@69: * \param val program number jpayne@69: */ jpayne@69: #define snd_seq_ev_set_pgmchange(ev,ch,val) \ jpayne@69: ((ev)->type = SND_SEQ_EVENT_PGMCHANGE,\ jpayne@69: snd_seq_ev_set_fixed(ev),\ jpayne@69: (ev)->data.control.channel = (ch),\ jpayne@69: (ev)->data.control.value = (val)) jpayne@69: jpayne@69: /** jpayne@69: * \brief set pitch-bend event jpayne@69: * \param ev event record jpayne@69: * \param ch channel number jpayne@69: * \param val pitch bend; zero centered from -8192 to 8191 jpayne@69: */ jpayne@69: #define snd_seq_ev_set_pitchbend(ev,ch,val) \ jpayne@69: ((ev)->type = SND_SEQ_EVENT_PITCHBEND,\ jpayne@69: snd_seq_ev_set_fixed(ev),\ jpayne@69: (ev)->data.control.channel = (ch),\ jpayne@69: (ev)->data.control.value = (val)) jpayne@69: jpayne@69: /** jpayne@69: * \brief set channel pressure event jpayne@69: * \param ev event record jpayne@69: * \param ch channel number jpayne@69: * \param val channel pressure value jpayne@69: */ jpayne@69: #define snd_seq_ev_set_chanpress(ev,ch,val) \ jpayne@69: ((ev)->type = SND_SEQ_EVENT_CHANPRESS,\ jpayne@69: snd_seq_ev_set_fixed(ev),\ jpayne@69: (ev)->data.control.channel = (ch),\ jpayne@69: (ev)->data.control.value = (val)) jpayne@69: jpayne@69: /** jpayne@69: * \brief set sysex event jpayne@69: * \param ev event record jpayne@69: * \param datalen length of sysex data jpayne@69: * \param dataptr sysex data pointer jpayne@69: * jpayne@69: * the sysex data must contain the start byte 0xf0 and the end byte 0xf7. jpayne@69: */ jpayne@69: #define snd_seq_ev_set_sysex(ev,datalen,dataptr) \ jpayne@69: ((ev)->type = SND_SEQ_EVENT_SYSEX,\ jpayne@69: snd_seq_ev_set_variable(ev, datalen, dataptr)) jpayne@69: jpayne@69: /** \} */ jpayne@69: jpayne@69: #ifdef __cplusplus jpayne@69: } jpayne@69: #endif jpayne@69: jpayne@69: #endif /* __ALSA_SEQMID_H */ jpayne@69: