Update of /cvsroot/pure-data/pd/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29845
Modified Files: Tag: desiredata s_midi.c Log Message: cleanup
Index: s_midi.c =================================================================== RCS file: /cvsroot/pure-data/pd/src/s_midi.c,v retrieving revision 1.4.4.1.2.12.2.7 retrieving revision 1.4.4.1.2.12.2.8 diff -C2 -d -r1.4.4.1.2.12.2.7 -r1.4.4.1.2.12.2.8 *** s_midi.c 28 Jun 2007 06:21:23 -0000 1.4.4.1.2.12.2.7 --- s_midi.c 28 Jun 2007 16:50:36 -0000 1.4.4.1.2.12.2.8 *************** *** 24,29 **** #include <signal.h>
! typedef struct _midiqelem ! { double q_time; int q_portno; --- 24,28 ---- #include <signal.h>
! typedef struct _midiqelem { double q_time; int q_portno; *************** *** 57,83 **** static double sys_whenupdate;
! void sys_initmidiqueue( void) ! { sys_midiinittime = clock_getlogicaltime(); sys_dactimeminusrealtime = sys_adctimeminusrealtime = 0; }
! /* this is called from the OS dependent code from time to time when we ! think we know the delay (outbuftime) in seconds, at which the last-output ! audio sample will go out the door. */ ! void sys_setmiditimediff(double inbuftime, double outbuftime) ! { ! double dactimeminusrealtime = ! .001 * clock_gettimesince(sys_midiinittime) ! - outbuftime - sys_getrealtime(); ! double adctimeminusrealtime = ! .001 * clock_gettimesince(sys_midiinittime) ! + inbuftime - sys_getrealtime(); ! if (dactimeminusrealtime > sys_newdactimeminusrealtime) ! sys_newdactimeminusrealtime = dactimeminusrealtime; ! if (adctimeminusrealtime > sys_newadctimeminusrealtime) ! sys_newadctimeminusrealtime = adctimeminusrealtime; ! if (sys_getrealtime() > sys_whenupdate) ! { sys_dactimeminusrealtime = sys_newdactimeminusrealtime; sys_adctimeminusrealtime = sys_newadctimeminusrealtime; --- 56,73 ---- static double sys_whenupdate;
! void sys_initmidiqueue (void) { sys_midiinittime = clock_getlogicaltime(); sys_dactimeminusrealtime = sys_adctimeminusrealtime = 0; }
! /* this is called from the OS dependent code from time to time when we ! think we know the delay (outbuftime) in seconds, at which the last-output ! audio sample will go out the door. */ ! void sys_setmiditimediff(double inbuftime, double outbuftime) { ! double dactimeminusrealtime = .001 * clock_gettimesince(sys_midiinittime) - outbuftime - sys_getrealtime(); ! double adctimeminusrealtime = .001 * clock_gettimesince(sys_midiinittime) + inbuftime - sys_getrealtime(); ! if (dactimeminusrealtime > sys_newdactimeminusrealtime) sys_newdactimeminusrealtime = dactimeminusrealtime; ! if (adctimeminusrealtime > sys_newadctimeminusrealtime) sys_newadctimeminusrealtime = adctimeminusrealtime; ! if (sys_getrealtime() > sys_whenupdate) { sys_dactimeminusrealtime = sys_newdactimeminusrealtime; sys_adctimeminusrealtime = sys_newadctimeminusrealtime; *************** *** 91,119 **** 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); --- 81,99 ---- 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); *************** *** 121,125 **** midi_outqueue[midi_outtail].q_byte2, midi_outqueue[midi_outtail].q_byte3); ! } midi_outtail = (midi_outtail + 1 == MIDIQSIZE ? 0 : midi_outtail + 1); } --- 101,105 ---- midi_outqueue[midi_outtail].q_byte2, midi_outqueue[midi_outtail].q_byte3); ! } midi_outtail = (midi_outtail + 1 == MIDIQSIZE ? 0 : midi_outtail + 1); } *************** *** 127,132 **** /* #define TEST_DEJITTER */
! void sys_pollmidioutqueue( void) ! { #ifdef TEST_DEJITTER static int db = 0; --- 107,111 ---- /* #define TEST_DEJITTER */
! void sys_pollmidioutqueue (void) { #ifdef TEST_DEJITTER static int db = 0; *************** *** 137,145 **** db = 0; #endif ! while (midi_outhead != midi_outtail) ! { #ifdef TEST_DEJITTER ! if (!db) ! { post("out: del %f, midiRT %f logicaltime %f, RT %f dacminusRT %f", (midi_outqueue[midi_outtail].q_time - midirealtime), --- 116,122 ---- db = 0; #endif ! while (midi_outhead != midi_outtail) { #ifdef TEST_DEJITTER ! if (!db) { post("out: del %f, midiRT %f logicaltime %f, RT %f dacminusRT %f", (midi_outqueue[midi_outtail].q_time - midirealtime), *************** *** 212,223 **** }
! void outmidi_mclk(int portno) ! { ! sys_queuemidimess(portno, 1, 0xf8, 0,0); ! }
/* ------------------------- MIDI input queue handling ------------------ */ ! typedef struct midiparser ! { int mp_status; int mp_gotbyte1; --- 189,196 ---- }
! void outmidi_mclk(int portno) {sys_queuemidimess(portno, 1, 0xf8, 0,0);}
/* ------------------------- MIDI input queue handling ------------------ */ ! typedef struct midiparser { int mp_status; int mp_gotbyte1; *************** *** 248,252 **** #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; --- 221,225 ---- #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; *************** *** 277,282 **** int chan = (parserp->mp_status & 0xf); int byte1 = parserp->mp_byte1, gotbyte1 = parserp->mp_gotbyte1; ! switch (cmd) ! { case MIDINOTEOFF: if (gotbyte1) inmidi_noteon(portno, chan, byte1, 0), parserp->mp_gotbyte1 = 0; --- 250,254 ---- int chan = (parserp->mp_status & 0xf); int byte1 = parserp->mp_byte1, gotbyte1 = parserp->mp_gotbyte1; ! switch (cmd) { case MIDINOTEOFF: if (gotbyte1) inmidi_noteon(portno, chan, byte1, 0), parserp->mp_gotbyte1 = 0; *************** *** 320,325 **** }
! void sys_pollmidiinqueue( void) ! { #ifdef TEST_DEJITTER static int db = 0; --- 292,296 ---- }
! void sys_pollmidiinqueue (void) { #ifdef TEST_DEJITTER static int db = 0; *************** *** 330,335 **** db = 0; #endif ! while (midi_inhead != midi_intail) ! { #ifdef TEST_DEJITTER if (!db) { --- 301,305 ---- db = 0; #endif ! while (midi_inhead != midi_intail) { #ifdef TEST_DEJITTER if (!db) { *************** *** 379,383 **** }
! void sys_pollmidiqueue( void) { #if 0 static double lasttime; --- 349,353 ---- }
! void sys_pollmidiqueue (void) { #if 0 static double lasttime; *************** *** 399,407 ****
#ifdef USEAPI_ALSA ! void midi_alsa_init( void); #endif #ifndef USEAPI_PORTMIDI #ifdef USEAPI_OSS ! void midi_oss_init( void); #endif #endif --- 369,377 ----
#ifdef USEAPI_ALSA ! void midi_alsa_init (void); #endif #ifndef USEAPI_PORTMIDI #ifdef USEAPI_OSS ! void midi_oss_init (void); #endif #endif *************** *** 414,419 ****
! void sys_get_midi_apis(char *buf) ! { int n = 0; strcpy(buf, "{ "); --- 384,388 ----
! void sys_get_midi_apis(char *buf) { int n = 0; strcpy(buf, "{ ");