Update of /cvsroot/pure-data/pd/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21781
Modified Files: Tag: desiredata s_midi.c Log Message: cleanup; removed prefixes of t_midiqelem
Index: s_midi.c =================================================================== RCS file: /cvsroot/pure-data/pd/src/s_midi.c,v retrieving revision 1.4.4.1.2.12.2.9 retrieving revision 1.4.4.1.2.12.2.10 diff -C2 -d -r1.4.4.1.2.12.2.9 -r1.4.4.1.2.12.2.10 *** s_midi.c 9 Jul 2007 18:01:30 -0000 1.4.4.1.2.12.2.9 --- s_midi.c 10 Jul 2007 06:20:48 -0000 1.4.4.1.2.12.2.10 *************** *** 25,36 **** #include <signal.h>
! typedef struct _midiqelem { ! double q_time; ! int q_portno; ! unsigned char q_onebyte; ! unsigned char q_byte1; ! unsigned char q_byte2; ! unsigned char q_byte3; ! } t_midiqelem;
#define MIDIQSIZE 1024 --- 25,36 ---- #include <signal.h>
! struct t_midiqelem { ! double time; ! int portno; ! unsigned char onebyte; ! unsigned char byte1; ! unsigned char byte2; ! unsigned char byte3; ! };
#define MIDIQSIZE 1024 *************** *** 57,61 **** static double sys_whenupdate;
! void sys_initmidiqueue (void) { sys_midiinittime = clock_getlogicaltime(); sys_dactimeminusrealtime = sys_adctimeminusrealtime = 0; --- 57,61 ---- static double sys_whenupdate;
! void sys_initmidiqueue() { sys_midiinittime = clock_getlogicaltime(); sys_dactimeminusrealtime = sys_adctimeminusrealtime = 0; *************** *** 82,105 **** going out, based on how much "system time" has elapsed since the last time sys_setmiditimediff got called. */ ! static double sys_getmidioutrealtime (void) {return sys_getrealtime() + sys_dactimeminusrealtime;} ! static double sys_getmidiinrealtime (void) {return sys_getrealtime() + sys_adctimeminusrealtime;}
! static void sys_putnext (void) { ! int portno = midi_outqueue[midi_outtail].q_portno; #ifdef USEAPI_ALSA if (sys_midiapi == API_ALSA) { ! if (midi_outqueue[midi_outtail].q_onebyte) ! sys_alsa_putmidibyte(portno, midi_outqueue[midi_outtail].q_byte1); ! else sys_alsa_putmidimess(portno, midi_outqueue[midi_outtail].q_byte1, ! midi_outqueue[midi_outtail].q_byte2, ! midi_outqueue[midi_outtail].q_byte3); } else #endif /* ALSA */ { ! if (midi_outqueue[midi_outtail].q_onebyte) ! sys_putmidibyte(portno, midi_outqueue[midi_outtail].q_byte1); ! else sys_putmidimess(portno, midi_outqueue[midi_outtail].q_byte1, ! midi_outqueue[midi_outtail].q_byte2, ! midi_outqueue[midi_outtail].q_byte3); } midi_outtail = (midi_outtail + 1 == MIDIQSIZE ? 0 : midi_outtail + 1); --- 82,105 ---- going out, based on how much "system time" has elapsed since the last time sys_setmiditimediff got called. */ ! static double sys_getmidioutrealtime() {return sys_getrealtime() + sys_dactimeminusrealtime;} ! static double sys_getmidiinrealtime () {return sys_getrealtime() + sys_adctimeminusrealtime;}
! static void sys_putnext () { ! int portno = midi_outqueue[midi_outtail].portno; #ifdef USEAPI_ALSA if (sys_midiapi == API_ALSA) { ! if (midi_outqueue[midi_outtail].onebyte) ! sys_alsa_putmidibyte(portno, midi_outqueue[midi_outtail].byte1); ! else sys_alsa_putmidimess(portno, midi_outqueue[midi_outtail].byte1, ! midi_outqueue[midi_outtail].byte2, ! midi_outqueue[midi_outtail].byte3); } else #endif /* ALSA */ { ! if (midi_outqueue[midi_outtail].onebyte) ! sys_putmidibyte(portno, midi_outqueue[midi_outtail].byte1); ! else sys_putmidimess(portno, midi_outqueue[midi_outtail].byte1, ! midi_outqueue[midi_outtail].byte2, ! midi_outqueue[midi_outtail].byte3); } midi_outtail = (midi_outtail + 1 == MIDIQSIZE ? 0 : midi_outtail + 1); *************** *** 108,112 **** /* #define TEST_DEJITTER */
! void sys_pollmidioutqueue (void) { #ifdef TEST_DEJITTER static int db = 0; --- 108,112 ---- /* #define TEST_DEJITTER */
! void sys_pollmidioutqueue() { #ifdef TEST_DEJITTER static int db = 0; *************** *** 114,119 **** double midirealtime = sys_getmidioutrealtime(); #ifdef TEST_DEJITTER ! if (midi_outhead == midi_outtail) ! db = 0; #endif while (midi_outhead != midi_outtail) { --- 114,118 ---- double midirealtime = sys_getmidioutrealtime(); #ifdef TEST_DEJITTER ! if (midi_outhead == midi_outtail) db = 0; #endif while (midi_outhead != midi_outtail) { *************** *** 121,125 **** if (!db) { post("out: del %f, midiRT %f logicaltime %f, RT %f dacminusRT %f", ! (midi_outqueue[midi_outtail].q_time - midirealtime), midirealtime, .001 * clock_gettimesince(sys_midiinittime), sys_getrealtime(), sys_dactimeminusrealtime); --- 120,124 ---- if (!db) { post("out: del %f, midiRT %f logicaltime %f, RT %f dacminusRT %f", ! (midi_outqueue[midi_outtail].time - midirealtime), midirealtime, .001 * clock_gettimesince(sys_midiinittime), sys_getrealtime(), sys_dactimeminusrealtime); *************** *** 127,131 **** } #endif ! if (midi_outqueue[midi_outtail].q_time <= midirealtime) sys_putnext(); else break; --- 126,130 ---- } #endif ! if (midi_outqueue[midi_outtail].time <= midirealtime) sys_putnext(); else break; *************** *** 138,148 **** /* if FIFO is full flush an element to make room */ if (newhead == midi_outtail) sys_putnext(); ! midi_outqueue[midi_outhead].q_portno = portno; ! midi_outqueue[midi_outhead].q_onebyte = onebyte; ! midi_outqueue[midi_outhead].q_byte1 = a; ! midi_outqueue[midi_outhead].q_byte2 = b; ! midi_outqueue[midi_outhead].q_byte3 = c; ! midi_outqueue[midi_outhead].q_time = ! .001 * clock_gettimesince(sys_midiinittime); midi_outhead = newhead; sys_pollmidioutqueue(); --- 137,146 ---- /* if FIFO is full flush an element to make room */ if (newhead == midi_outtail) sys_putnext(); ! midi_outqueue[midi_outhead].portno = portno; ! midi_outqueue[midi_outhead].onebyte = onebyte; ! midi_outqueue[midi_outhead].byte1 = a; ! midi_outqueue[midi_outhead].byte2 = b; ! midi_outqueue[midi_outhead].byte3 = c; ! midi_outqueue[midi_outhead].time = .001 * clock_gettimesince(sys_midiinittime); midi_outhead = newhead; sys_pollmidioutqueue(); *************** *** 222,229 **** #define MIDIRESET 0xff /* 0 */
! static void sys_dispatchnextmidiin (void) { static t_midiparser parser[MAXMIDIINDEV], *parserp; ! int portno = midi_inqueue[midi_intail].q_portno, byte = midi_inqueue[midi_intail].q_byte1; ! if (!midi_inqueue[midi_intail].q_onebyte) bug("sys_dispatchnextmidiin"); if (portno < 0 || portno >= MAXMIDIINDEV) bug("sys_dispatchnextmidiin 2"); parserp = parser + portno; --- 220,227 ---- #define MIDIRESET 0xff /* 0 */
! static void sys_dispatchnextmidiin() { static t_midiparser parser[MAXMIDIINDEV], *parserp; ! int portno = midi_inqueue[midi_intail].portno, byte = midi_inqueue[midi_intail].byte1; ! if (!midi_inqueue[midi_intail].onebyte) bug("sys_dispatchnextmidiin"); if (portno < 0 || portno >= MAXMIDIINDEV) bug("sys_dispatchnextmidiin 2"); parserp = parser + portno; *************** *** 293,297 **** }
! void sys_pollmidiinqueue (void) { #ifdef TEST_DEJITTER static int db = 0; --- 291,295 ---- }
! void sys_pollmidiinqueue() { #ifdef TEST_DEJITTER static int db = 0; *************** *** 306,310 **** if (!db) { post("in del %f, logicaltime %f, RT %f adcminusRT %f", ! (midi_inqueue[midi_intail].q_time - logicaltime), logicaltime, sys_getrealtime(), sys_adctimeminusrealtime); db = 1; --- 304,308 ---- if (!db) { post("in del %f, logicaltime %f, RT %f adcminusRT %f", ! (midi_inqueue[midi_intail].time - logicaltime), logicaltime, sys_getrealtime(), sys_adctimeminusrealtime); db = 1; *************** *** 312,321 **** #endif #if 0 ! if (midi_inqueue[midi_intail].q_time <= logicaltime - 0.007) ! post("late %f", 1000 * (logicaltime - midi_inqueue[midi_intail].q_time)); #endif ! if (midi_inqueue[midi_intail].q_time <= logicaltime) { #if 0 ! post("diff %f", 1000* (logicaltime - midi_inqueue[midi_intail].q_time)); #endif sys_dispatchnextmidiin(); --- 310,319 ---- #endif #if 0 ! if (midi_inqueue[midi_intail].time <= logicaltime - 0.007) ! post("late %f", 1000 * (logicaltime - midi_inqueue[midi_intail].time)); #endif ! if (midi_inqueue[midi_intail].time <= logicaltime) { #if 0 ! post("diff %f", 1000* (logicaltime - midi_inqueue[midi_intail].time)); #endif sys_dispatchnextmidiin(); *************** *** 342,354 **** sys_dispatchnextmidiin(); } ! midi_inqueue[midi_inhead].q_portno = portno; ! midi_inqueue[midi_inhead].q_onebyte = 1; ! midi_inqueue[midi_inhead].q_byte1 = byte; ! midi_inqueue[midi_inhead].q_time = sys_getmidiinrealtime(); midi_inhead = newhead; sys_pollmidiinqueue(); }
! void sys_pollmidiqueue (void) { #if 0 static double lasttime; --- 340,352 ---- sys_dispatchnextmidiin(); } ! midi_inqueue[midi_inhead].portno = portno; ! midi_inqueue[midi_inhead].onebyte = 1; ! midi_inqueue[midi_inhead].byte1 = byte; ! midi_inqueue[midi_inhead].time = sys_getmidiinrealtime(); midi_inhead = newhead; sys_pollmidiinqueue(); }
! void sys_pollmidiqueue() { #if 0 static double lasttime; *************** *** 370,382 ****
#ifdef USEAPI_ALSA ! void midi_alsa_init (void); #endif #ifndef USEAPI_PORTMIDI #ifdef USEAPI_OSS ! void midi_oss_init (void); #endif #endif
! /* last requested parameters */ static int midi_nmidiindev; static int midi_midiindev[MAXMIDIINDEV]; --- 368,380 ----
#ifdef USEAPI_ALSA ! void midi_alsa_init(); #endif #ifndef USEAPI_PORTMIDI #ifdef USEAPI_OSS ! void midi_oss_init(); #endif #endif
! /* last requested parameters */ static int midi_nmidiindev; static int midi_midiindev[MAXMIDIINDEV]; *************** *** 384,388 **** static int midi_midioutdev[MAXMIDIOUTDEV];
- void sys_get_midi_apis(char *buf) { int n = 0; --- 382,385 ---- *************** *** 393,415 **** #endif strcat(buf, "}"); - /* then again, if only one API (or none) we don't offer any choice. */ - if (n < 2) - strcpy(buf, "{}"); - } void sys_get_midi_params(int *pnmidiindev, int *pmidiindev, int *pnmidioutdev, int *pmidioutdev) { ! int i; ! *pnmidiindev = midi_nmidiindev; ! for (i = 0; i < MAXMIDIINDEV; i++) pmidiindev[i] = midi_midiindev[i]; ! *pnmidioutdev = midi_nmidioutdev; ! for (i = 0; i < MAXMIDIOUTDEV; i++) pmidioutdev[i] = midi_midioutdev[i]; }
static void sys_save_midi_params(int nmidiindev, int *midiindev, int nmidioutdev, int *midioutdev) { ! int i; ! midi_nmidiindev = nmidiindev; ! for (i = 0; i < MAXMIDIINDEV; i++) midi_midiindev[i] = midiindev[i]; ! midi_nmidioutdev = nmidioutdev; ! for (i = 0; i < MAXMIDIOUTDEV; i++) midi_midioutdev[i] = midioutdev[i]; }
--- 390,402 ---- #endif strcat(buf, "}"); } void sys_get_midi_params(int *pnmidiindev, int *pmidiindev, int *pnmidioutdev, int *pmidioutdev) { ! *pnmidiindev = midi_nmidiindev; for (int i=0; i<MAXMIDIINDEV; i++) pmidiindev [i] = midi_midiindev[i]; ! *pnmidioutdev = midi_nmidioutdev; for (int i=0; i<MAXMIDIOUTDEV; i++) pmidioutdev[i] = midi_midioutdev[i]; }
static void sys_save_midi_params(int nmidiindev, int *midiindev, int nmidioutdev, int *midioutdev) { ! midi_nmidiindev = nmidiindev; for (int i=0; i<MAXMIDIINDEV; i++) midi_midiindev [i] = midiindev[i]; ! midi_nmidioutdev = nmidioutdev; for (int i=0; i<MAXMIDIOUTDEV; i++) midi_midioutdev[i] = midioutdev[i]; }
*************** *** 435,439 ****
/* open midi using whatever parameters were last used */ ! void sys_reopen_midi(void) { int nmidiindev, midiindev[MAXMIDIINDEV]; int nmidioutdev, midioutdev[MAXMIDIOUTDEV]; --- 422,426 ----
/* open midi using whatever parameters were last used */ ! void sys_reopen_midi() { int nmidiindev, midiindev[MAXMIDIINDEV]; int nmidioutdev, midioutdev[MAXMIDIOUTDEV]; *************** *** 446,453 **** #define DEVONSET 1 /* To agree with command line flags, normally start at 1 */
! void sys_listmididevs(void) { char indevlist[MAXNDEV*DEVDESCSIZE], outdevlist[MAXNDEV*DEVDESCSIZE]; ! int nindevs = 0, noutdevs = 0, i; ! #ifdef USEAPI_ALSA if (sys_midiapi == API_ALSA) --- 433,439 ---- #define DEVONSET 1 /* To agree with command line flags, normally start at 1 */
! void sys_listmididevs() { char indevlist[MAXNDEV*DEVDESCSIZE], outdevlist[MAXNDEV*DEVDESCSIZE]; ! int nindevs = 0, noutdevs = 0; #ifdef USEAPI_ALSA if (sys_midiapi == API_ALSA) *************** *** 456,469 **** #endif /* ALSA */ midi_getdevs(indevlist, &nindevs, outdevlist, &noutdevs, MAXNDEV, DEVDESCSIZE); - if (!nindevs) post("no midi input devices found"); else { post("MIDI input devices:"); ! for (i = 0; i < nindevs; i++) post("%d. %s", i+1, indevlist + i * DEVDESCSIZE); } if (!noutdevs) post("no midi output devices found"); else { post("MIDI output devices:"); ! for (i = 0; i < noutdevs; i++) post("%d. %s", i+DEVONSET, outdevlist + i * DEVDESCSIZE); } } --- 442,454 ---- #endif /* ALSA */ midi_getdevs(indevlist, &nindevs, outdevlist, &noutdevs, MAXNDEV, DEVDESCSIZE); if (!nindevs) post("no midi input devices found"); else { post("MIDI input devices:"); ! for (int i=0; i<nindevs; i++) post("%d. %s", i+1, indevlist + i * DEVDESCSIZE); } if (!noutdevs) post("no midi output devices found"); else { post("MIDI output devices:"); ! for (int i=0; i<noutdevs; i++) post("%d. %s", i+DEVONSET, outdevlist + i * DEVDESCSIZE); } } *************** *** 503,507 **** extern t_class *glob_pdobject;
! /* start an midi settings dialog window */ void glob_midi_properties(t_pd *dummy, t_floatarg flongform) { /* these are the devices you're using: */ --- 488,492 ---- extern t_class *glob_pdobject;
! /* start an midi settings dialog window */ void glob_midi_properties(t_pd *dummy, t_floatarg flongform) { /* these are the devices you're using: */ *************** *** 583,603 **** char str[DEVDESCSIZE]; int f = ac ? (int)atom_getfloatarg(0,ac,av) : -1; ! t_symbol * selector = gensym("midiindev"); ! t_symbol * pd = gensym("pd"); midi_getdevs(indevlist, &nindevs, outdevlist, &noutdevs, MAXNDEV, DEVDESCSIZE); if (f < 0) { ! int i; ! for (i = 0; i != nindevs ;++i) { ! t_symbol * sym; strcpy(str, indevlist + i * DEVDESCSIZE); ! sym = gensym(str); ! SETSYMBOL(argv+i, sym); } typedmess(pd->s_thing, selector, nindevs, argv); } else if (f < nindevs) { - t_symbol * sym; strcpy(str, indevlist + f * DEVDESCSIZE); ! sym = gensym(str); ! SETSYMBOL(argv, sym); typedmess(pd->s_thing, selector, 1, argv); } --- 568,583 ---- char str[DEVDESCSIZE]; int f = ac ? (int)atom_getfloatarg(0,ac,av) : -1; ! t_symbol *selector = gensym("midiindev"); ! t_symbol *pd = gensym("pd"); midi_getdevs(indevlist, &nindevs, outdevlist, &noutdevs, MAXNDEV, DEVDESCSIZE); if (f < 0) { ! for (int i=0; i<nindevs; i++) { strcpy(str, indevlist + i * DEVDESCSIZE); ! SETSYMBOL(argv+i, gensym(str)); } typedmess(pd->s_thing, selector, nindevs, argv); } else if (f < nindevs) { strcpy(str, indevlist + f * DEVDESCSIZE); ! SETSYMBOL(argv, gensym(str)); typedmess(pd->s_thing, selector, 1, argv); } *************** *** 611,631 **** char str[DEVDESCSIZE]; int f = ac ? (int)atom_getfloatarg(0,ac,av) : -1; ! t_symbol * selector = gensym("midioutdev"); ! t_symbol * pd = gensym("pd"); midi_getdevs(indevlist, &nindevs, outdevlist, &noutdevs, MAXNDEV, DEVDESCSIZE); if (f < 0) { ! int i; ! for (i = 0; i != noutdevs ;++i) { ! t_symbol * sym; ! strcpy(str, outdevlist + i * DEVDESCSIZE); ! sym = gensym(str); ! SETSYMBOL(argv+i, sym); } typedmess(pd->s_thing, selector, noutdevs, argv); } else if (f < noutdevs) { ! t_symbol * sym; ! strcpy(str, outdevlist + f * DEVDESCSIZE); ! sym = gensym(str); ! SETSYMBOL(argv, sym); typedmess(pd->s_thing, selector, 1, argv); } --- 591,606 ---- char str[DEVDESCSIZE]; int f = ac ? (int)atom_getfloatarg(0,ac,av) : -1; ! t_symbol *selector = gensym("midioutdev"); ! t_symbol *pd = gensym("pd"); midi_getdevs(indevlist, &nindevs, outdevlist, &noutdevs, MAXNDEV, DEVDESCSIZE); if (f < 0) { ! for (int i=0; i<noutdevs; i++) { ! strcpy(str, outdevlist + i*DEVDESCSIZE); ! SETSYMBOL(argv+i, gensym(str)); } typedmess(pd->s_thing, selector, noutdevs, argv); } else if (f < noutdevs) { ! strcpy(str, outdevlist + f*DEVDESCSIZE); ! SETSYMBOL(argv, gensym(str)); typedmess(pd->s_thing, selector, 1, argv); } *************** *** 637,647 **** int noutdev, midioutdev[MAXMIDIOUTDEV]; t_atom argv[MAXNDEV]; - int i; sys_get_midi_params(&nindev, midiindev, &noutdev, midioutdev); ! for (i = 0; i < nindev; i++) SETFLOAT(argv+i, midiindev[i]); typedmess(gensym("pd")->s_thing, gensym("midicurrentindev"), nindev, argv); }
- void glob_midi_getcurrentoutdevs(t_pd *dummy) { /* these are the devices you're using: */ --- 612,620 ---- int noutdev, midioutdev[MAXMIDIOUTDEV]; t_atom argv[MAXNDEV]; sys_get_midi_params(&nindev, midiindev, &noutdev, midioutdev); ! for (int i=0; i<nindev; i++) SETFLOAT(argv+i, midiindev[i]); typedmess(gensym("pd")->s_thing, gensym("midicurrentindev"), nindev, argv); }
void glob_midi_getcurrentoutdevs(t_pd *dummy) { /* these are the devices you're using: */ *************** *** 649,656 **** int noutdev, midioutdev[MAXMIDIOUTDEV]; t_atom argv[MAXNDEV]; - int i; sys_get_midi_params(&nindev, midiindev, &noutdev, midioutdev); ! for (i = 0; i < noutdev; i++) SETFLOAT(argv+i, midioutdev[i]); typedmess(gensym("pd")->s_thing, gensym("midicurrentoutdev"), noutdev, argv); } - --- 622,627 ---- int noutdev, midioutdev[MAXMIDIOUTDEV]; t_atom argv[MAXNDEV]; sys_get_midi_params(&nindev, midiindev, &noutdev, midioutdev); ! for (int i=0; i<noutdev; i++) SETFLOAT(argv+i, midioutdev[i]); typedmess(gensym("pd")->s_thing, gensym("midicurrentoutdev"), noutdev, argv); }