Path: blob/master/thirdparty/linuxbsd_headers/alsa/seqmid.h
9898 views
/**1* \file include/seqmid.h2* \brief Application interface library for the ALSA driver3* \author Jaroslav Kysela <[email protected]>4* \author Abramo Bagnara <[email protected]>5* \author Takashi Iwai <[email protected]>6* \date 1998-20017*8* Application interface library for the ALSA driver9*/10/*11* This library is free software; you can redistribute it and/or modify12* it under the terms of the GNU Lesser General Public License as13* published by the Free Software Foundation; either version 2.1 of14* the License, or (at your option) any later version.15*16* This program is distributed in the hope that it will be useful,17* but WITHOUT ANY WARRANTY; without even the implied warranty of18* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the19* GNU Lesser General Public License for more details.20*21* You should have received a copy of the GNU Lesser General Public22* License along with this library; if not, write to the Free Software23* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA24*25*/2627#ifndef __ALSA_SEQMID_H28#define __ALSA_SEQMID_H2930#ifdef __cplusplus31extern "C" {32#endif3334/**35* \defgroup SeqMiddle Sequencer Middle Level Interface36* Sequencer Middle Level Interface37* \ingroup Sequencer38* \{39*/4041/**42* \brief initialize event record43* \param ev event record pointer44*45* This macro clears the given event record pointer to the default status.46*/47#define snd_seq_ev_clear(ev) \48memset(ev, 0, sizeof(snd_seq_event_t))4950/**51* \brief set the tag for given event52* \param ev event record53* \param t event tag54*55* This macro sets the tag to the given event record.56*/57#define snd_seq_ev_set_tag(ev,t) \58((ev)->tag = (t))5960/**61* \brief set the explicit destination62* \param ev event record63* \param c destination client id64* \param p destination port id65*66* This macro sets the client and port id numbers to the given event record.67*68* \sa snd_seq_ev_set_subs()69*/70#define snd_seq_ev_set_dest(ev,c,p) \71((ev)->dest.client = (c), (ev)->dest.port = (p))7273/**74* \brief set broadcasting to subscribers75* \param ev event record76*77* This macro sets the destination as the subscribers.78*79* \sa snd_seq_ev_set_dest()80*/81#define snd_seq_ev_set_subs(ev) \82((ev)->dest.client = SND_SEQ_ADDRESS_SUBSCRIBERS,\83(ev)->dest.port = SND_SEQ_ADDRESS_UNKNOWN)8485/**86* \brief set broadcasting to all clients/ports87* \param ev event record88*89* This macro sets the destination as the broadcasting.90*91* \sa snd_seq_ev_set_dest()92*/93#define snd_seq_ev_set_broadcast(ev) \94((ev)->dest.client = SND_SEQ_ADDRESS_BROADCAST,\95(ev)->dest.port = SND_SEQ_ADDRESS_BROADCAST)9697/**98* \brief set the source port99* \param ev event record100* \param p source port id101*102* This macro sets the source port id number.103*/104#define snd_seq_ev_set_source(ev,p) \105((ev)->source.port = (p))106107/**108* \brief set direct passing mode (without queued)109* \param ev event instance110*111* This macro sets the event to the direct passing mode112* to be delivered immediately without queueing.113*114* \sa snd_seq_ev_schedule_tick(), snd_seq_ev_schedule_real()115*/116#define snd_seq_ev_set_direct(ev) \117((ev)->queue = SND_SEQ_QUEUE_DIRECT)118119/**120* \brief set tick-scheduling mode on queue121* \param ev event instance122* \param q queue id to schedule123* \param relative relative time-stamp if non-zero124* \param ttick tick time-stamp to be delivered125*126* This macro sets the scheduling of the event in the127* MIDI tick mode.128*129* \sa snd_seq_ev_schedule_real(), snd_seq_ev_set_direct()130*/131#define snd_seq_ev_schedule_tick(ev, q, relative, ttick) \132((ev)->flags &= ~(SND_SEQ_TIME_STAMP_MASK | SND_SEQ_TIME_MODE_MASK),\133(ev)->flags |= SND_SEQ_TIME_STAMP_TICK,\134(ev)->flags |= (relative) ? SND_SEQ_TIME_MODE_REL : SND_SEQ_TIME_MODE_ABS,\135(ev)->time.tick = (ttick),\136(ev)->queue = (q))137138/**139* \brief set real-time-scheduling mode on queue140* \param ev event instance141* \param q queue id to schedule142* \param relative relative time-stamp if non-zero143* \param rtime time-stamp to be delivered144*145* This macro sets the scheduling of the event in the146* realtime mode.147*148* \sa snd_seq_ev_schedule_tick(), snd_seq_ev_set_direct()149*/150#define snd_seq_ev_schedule_real(ev, q, relative, rtime) \151((ev)->flags &= ~(SND_SEQ_TIME_STAMP_MASK | SND_SEQ_TIME_MODE_MASK),\152(ev)->flags |= SND_SEQ_TIME_STAMP_REAL,\153(ev)->flags |= (relative) ? SND_SEQ_TIME_MODE_REL : SND_SEQ_TIME_MODE_ABS,\154(ev)->time.time = *(rtime),\155(ev)->queue = (q))156157/**158* \brief set event priority159* \param ev event instance160* \param high_prior 1 for high priority mode161*/162#define snd_seq_ev_set_priority(ev, high_prior) \163((ev)->flags &= ~SND_SEQ_PRIORITY_MASK,\164(ev)->flags |= (high_prior) ? SND_SEQ_PRIORITY_HIGH : SND_SEQ_PRIORITY_NORMAL)165166/**167* \brief set fixed data168* \param ev event instance169*170* Sets the event length mode as fixed size.171*172* \sa snd_seq_ev_set_variable(), snd_seq_ev_set_varusr()173*/174#define snd_seq_ev_set_fixed(ev) \175((ev)->flags &= ~SND_SEQ_EVENT_LENGTH_MASK,\176(ev)->flags |= SND_SEQ_EVENT_LENGTH_FIXED)177178/**179* \brief set variable data180* \param ev event instance181* \param datalen length of the external data182* \param dataptr pointer of the external data183*184* Sets the event length mode as variable length and stores the data.185*186* \sa snd_seq_ev_set_fixed(), snd_seq_ev_set_varusr()187*/188#define snd_seq_ev_set_variable(ev, datalen, dataptr) \189((ev)->flags &= ~SND_SEQ_EVENT_LENGTH_MASK,\190(ev)->flags |= SND_SEQ_EVENT_LENGTH_VARIABLE,\191(ev)->data.ext.len = (datalen),\192(ev)->data.ext.ptr = (dataptr))193194/**195* \brief set varusr data196* \param ev event instance197* \param datalen length of the external data198* \param dataptr pointer of the external data199*200* Sets the event length mode as variable user-space data and stores the data.201*202* \sa snd_seq_ev_set_fixed(), snd_seq_ev_set_variable()203*/204#define snd_seq_ev_set_varusr(ev, datalen, dataptr) \205((ev)->flags &= ~SND_SEQ_EVENT_LENGTH_MASK,\206(ev)->flags |= SND_SEQ_EVENT_LENGTH_VARUSR,\207(ev)->data.ext.len = (datalen),\208(ev)->data.ext.ptr = (dataptr))209210/**211* \brief set queue controls212* \param ev event record213* \param typ event type214* \param q queue id215* \param val control value216*/217#define snd_seq_ev_set_queue_control(ev, typ, q, val) \218((ev)->type = (typ),\219snd_seq_ev_set_dest(ev, SND_SEQ_CLIENT_SYSTEM, SND_SEQ_PORT_SYSTEM_TIMER),\220(ev)->data.queue.queue = (q),\221(ev)->data.queue.param.value = (val))222223/**224* \brief set the start queue event225* \param ev event record226* \param q queue id to start227*228* \sa snd_seq_ev_set_queue_stop(), snd_seq_ev_set_queue_continue()229*/230#define snd_seq_ev_set_queue_start(ev, q) \231snd_seq_ev_set_queue_control(ev, SND_SEQ_EVENT_START, q, 0)232233/**234* \brief set the stop queue event235* \param ev event record236* \param q queue id to stop237*238* \sa snd_seq_ev_set_queue_start(), snd_seq_ev_set_queue_continue()239*/240#define snd_seq_ev_set_queue_stop(ev, q) \241snd_seq_ev_set_queue_control(ev, SND_SEQ_EVENT_STOP, q, 0)242243/**244* \brief set the stop queue event245* \param ev event record246* \param q queue id to continue247*248* \sa snd_seq_ev_set_queue_start(), snd_seq_ev_set_queue_stop()249*/250#define snd_seq_ev_set_queue_continue(ev, q) \251snd_seq_ev_set_queue_control(ev, SND_SEQ_EVENT_CONTINUE, q, 0)252253/**254* \brief set the stop queue event255* \param ev event record256* \param q queue id to change tempo257* \param val the new tempo value258*/259#define snd_seq_ev_set_queue_tempo(ev, q, val) \260snd_seq_ev_set_queue_control(ev, SND_SEQ_EVENT_TEMPO, q, val)261262/**263* \brief set the real-time position of a queue264* \param ev event record265* \param q queue id to change tempo266* \param rtime the new real-time pointer267*/268#define snd_seq_ev_set_queue_pos_real(ev, q, rtime) \269((ev)->type = SND_SEQ_EVENT_SETPOS_TIME,\270snd_seq_ev_set_dest(ev, SND_SEQ_CLIENT_SYSTEM, SND_SEQ_PORT_SYSTEM_TIMER),\271(ev)->data.queue.queue = (q),\272(ev)->data.queue.param.time.time = *(rtime))273274/**275* \brief set the tick-time position of a queue276* \param ev event record277* \param q queue id to change tempo278* \param ttime the new tick-time279*/280#define snd_seq_ev_set_queue_pos_tick(ev, q, ttime) \281((ev)->type = SND_SEQ_EVENT_SETPOS_TICK,\282snd_seq_ev_set_dest(ev, SND_SEQ_CLIENT_SYSTEM, SND_SEQ_PORT_SYSTEM_TIMER),\283(ev)->data.queue.queue = (q),\284(ev)->data.queue.param.time.tick = (ttime))285286/* set and send a queue control event */287int snd_seq_control_queue(snd_seq_t *seq, int q, int type, int value, snd_seq_event_t *ev);288289/**290* \brief start the specified queue291* \param seq sequencer handle292* \param q queue id to start293* \param ev optional event record (see #snd_seq_control_queue)294*/295#define snd_seq_start_queue(seq, q, ev) \296snd_seq_control_queue(seq, q, SND_SEQ_EVENT_START, 0, ev)297298/**299* \brief stop the specified queue300* \param seq sequencer handle301* \param q queue id to stop302* \param ev optional event record (see #snd_seq_control_queue)303*/304#define snd_seq_stop_queue(seq, q, ev) \305snd_seq_control_queue(seq, q, SND_SEQ_EVENT_STOP, 0, ev)306307/**308* \brief continue the specified queue309* \param seq sequencer handle310* \param q queue id to continue311* \param ev optional event record (see #snd_seq_control_queue)312*/313#define snd_seq_continue_queue(seq, q, ev) \314snd_seq_control_queue(seq, q, SND_SEQ_EVENT_CONTINUE, 0, ev)315316/**317* \brief change the tempo of the specified queue318* \param seq sequencer handle319* \param q queue id320* \param tempo the new tempo value321* \param ev optional event record (see #snd_seq_control_queue)322*/323#define snd_seq_change_queue_tempo(seq, q, tempo, ev) \324snd_seq_control_queue(seq, q, SND_SEQ_EVENT_TEMPO, tempo, ev)325326/* create a port - simple version - return the port number */327int snd_seq_create_simple_port(snd_seq_t *seq, const char *name,328unsigned int caps, unsigned int type);329/* delete the port */330int snd_seq_delete_simple_port(snd_seq_t *seq, int port);331332/* simple subscription between this port and another port333(w/o exclusive & time conversion)334*/335int snd_seq_connect_from(snd_seq_t *seq, int my_port, int src_client, int src_port);336int snd_seq_connect_to(snd_seq_t *seq, int my_port, int dest_client, int dest_port);337int snd_seq_disconnect_from(snd_seq_t *seq, int my_port, int src_client, int src_port);338int snd_seq_disconnect_to(snd_seq_t *seq, int my_port, int dest_client, int dest_port);339340/*341* set client information342*/343int snd_seq_set_client_name(snd_seq_t *seq, const char *name);344int snd_seq_set_client_event_filter(snd_seq_t *seq, int event_type);345int snd_seq_set_client_pool_output(snd_seq_t *seq, size_t size);346int snd_seq_set_client_pool_output_room(snd_seq_t *seq, size_t size);347int snd_seq_set_client_pool_input(snd_seq_t *seq, size_t size);348/* sync output queue */349int snd_seq_sync_output_queue(snd_seq_t *seq);350351/*352* parse the given string and get the sequencer address353*/354int snd_seq_parse_address(snd_seq_t *seq, snd_seq_addr_t *addr, const char *str);355356/*357* reset client input/output pool358*/359int snd_seq_reset_pool_output(snd_seq_t *seq);360int snd_seq_reset_pool_input(snd_seq_t *seq);361362/**363* \brief set note event364* \param ev event record365* \param ch channel number366* \param key note key367* \param vel velocity368* \param dur duration (in tick or msec)369*/370#define snd_seq_ev_set_note(ev, ch, key, vel, dur) \371((ev)->type = SND_SEQ_EVENT_NOTE,\372snd_seq_ev_set_fixed(ev),\373(ev)->data.note.channel = (ch),\374(ev)->data.note.note = (key),\375(ev)->data.note.velocity = (vel),\376(ev)->data.note.duration = (dur))377378/**379* \brief set note-on event380* \param ev event record381* \param ch channel number382* \param key note key383* \param vel velocity384*/385#define snd_seq_ev_set_noteon(ev, ch, key, vel) \386((ev)->type = SND_SEQ_EVENT_NOTEON,\387snd_seq_ev_set_fixed(ev),\388(ev)->data.note.channel = (ch),\389(ev)->data.note.note = (key),\390(ev)->data.note.velocity = (vel))391392/**393* \brief set note-off event394* \param ev event record395* \param ch channel number396* \param key note key397* \param vel velocity398*/399#define snd_seq_ev_set_noteoff(ev, ch, key, vel) \400((ev)->type = SND_SEQ_EVENT_NOTEOFF,\401snd_seq_ev_set_fixed(ev),\402(ev)->data.note.channel = (ch),\403(ev)->data.note.note = (key),\404(ev)->data.note.velocity = (vel))405406/**407* \brief set key-pressure event408* \param ev event record409* \param ch channel number410* \param key note key411* \param vel velocity412*/413#define snd_seq_ev_set_keypress(ev,ch,key,vel) \414((ev)->type = SND_SEQ_EVENT_KEYPRESS,\415snd_seq_ev_set_fixed(ev),\416(ev)->data.note.channel = (ch),\417(ev)->data.note.note = (key),\418(ev)->data.note.velocity = (vel))419420/**421* \brief set MIDI controller event422* \param ev event record423* \param ch channel number424* \param cc controller number425* \param val control value426*/427#define snd_seq_ev_set_controller(ev,ch,cc,val) \428((ev)->type = SND_SEQ_EVENT_CONTROLLER,\429snd_seq_ev_set_fixed(ev),\430(ev)->data.control.channel = (ch),\431(ev)->data.control.param = (cc),\432(ev)->data.control.value = (val))433434/**435* \brief set program change event436* \param ev event record437* \param ch channel number438* \param val program number439*/440#define snd_seq_ev_set_pgmchange(ev,ch,val) \441((ev)->type = SND_SEQ_EVENT_PGMCHANGE,\442snd_seq_ev_set_fixed(ev),\443(ev)->data.control.channel = (ch),\444(ev)->data.control.value = (val))445446/**447* \brief set pitch-bend event448* \param ev event record449* \param ch channel number450* \param val pitch bend; zero centered from -8192 to 8191451*/452#define snd_seq_ev_set_pitchbend(ev,ch,val) \453((ev)->type = SND_SEQ_EVENT_PITCHBEND,\454snd_seq_ev_set_fixed(ev),\455(ev)->data.control.channel = (ch),\456(ev)->data.control.value = (val))457458/**459* \brief set channel pressure event460* \param ev event record461* \param ch channel number462* \param val channel pressure value463*/464#define snd_seq_ev_set_chanpress(ev,ch,val) \465((ev)->type = SND_SEQ_EVENT_CHANPRESS,\466snd_seq_ev_set_fixed(ev),\467(ev)->data.control.channel = (ch),\468(ev)->data.control.value = (val))469470/**471* \brief set sysex event472* \param ev event record473* \param datalen length of sysex data474* \param dataptr sysex data pointer475*476* the sysex data must contain the start byte 0xf0 and the end byte 0xf7.477*/478#define snd_seq_ev_set_sysex(ev,datalen,dataptr) \479((ev)->type = SND_SEQ_EVENT_SYSEX,\480snd_seq_ev_set_variable(ev, datalen, dataptr))481482/** \} */483484#ifdef __cplusplus485}486#endif487488#endif /* __ALSA_SEQMID_H */489490491492