Update of /cvsroot/pure-data/pd/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28067
Modified Files: Tag: desiredata s_midi_pm.c Log Message: cleanup
Index: s_midi_pm.c =================================================================== RCS file: /cvsroot/pure-data/pd/src/s_midi_pm.c,v retrieving revision 1.4.4.1.2.8.2.2 retrieving revision 1.4.4.1.2.8.2.3 diff -C2 -d -r1.4.4.1.2.8.2.2 -r1.4.4.1.2.8.2.3 *** s_midi_pm.c 28 Jun 2007 05:29:19 -0000 1.4.4.1.2.8.2.2 --- s_midi_pm.c 24 Jul 2007 02:23:28 -0000 1.4.4.1.2.8.2.3 *************** *** 29,50 ****
void sys_do_open_midi(int nmidiin, int *midiinvec, int nmidiout, int *midioutvec) { - int i = 0, j, devno; PmError err; Pt_Start(1, 0, 0); /* start a timer with millisecond accuracy */ mac_nmidiindev = 0; ! for (i = 0; i < nmidiin; i++) { int found = 0,count = Pm_CountDevices(); ! for (j = 0, devno = 0; j < count && !found; j++) { const PmDeviceInfo *info = Pm_GetDeviceInfo(j); if (info->input) { if (devno == midiinvec[i]) { ! err = Pm_OpenInput(&mac_midiindevlist[mac_nmidiindev], ! j, NULL, 100, NULL, NULL); ! if (err != pmNoError) ! post("could not open midi input %d (%s): %s", j, info->name, Pm_GetErrorText(err)); ! else { ! if (sys_verbose) post("Midi Input (%s) opened.", info->name); ! mac_nmidiindev++; ! } found = 1; } --- 29,44 ----
void sys_do_open_midi(int nmidiin, int *midiinvec, int nmidiout, int *midioutvec) { PmError err; Pt_Start(1, 0, 0); /* start a timer with millisecond accuracy */ mac_nmidiindev = 0; ! for (int i=0; i<nmidiin; i++) { int found = 0,count = Pm_CountDevices(); ! for (int j=0, devno=0; j<count && !found; j++) { const PmDeviceInfo *info = Pm_GetDeviceInfo(j); if (info->input) { if (devno == midiinvec[i]) { ! err = Pm_OpenInput(&mac_midiindevlist[mac_nmidiindev],j,NULL,100,NULL,NULL); ! if (err != pmNoError) post("could not open midi input %d (%s): %s", j, info->name, Pm_GetErrorText(err)); ! else {mac_nmidiindev++; if (sys_verbose) post("Midi Input (%s) opened.", info->name);} found = 1; } *************** *** 55,71 **** } mac_nmidioutdev = 0; ! for (i = 0; i < nmidiout; i++) { int found = 0,count = Pm_CountDevices(); ! for (j = 0, devno = 0; j < count && !found; j++) { const PmDeviceInfo *info = Pm_GetDeviceInfo(j); if (info->output) { if (devno == midioutvec[i]) { err = Pm_OpenOutput(&mac_midioutdevlist[mac_nmidioutdev],j,NULL,0,NULL,NULL,0); ! if (err != pmNoError) ! post("could not open midi output %d (%s): %s",j,info->name,Pm_GetErrorText(err)); ! else { ! if (sys_verbose) post("Midi Output (%s) opened.",info->name); ! mac_nmidioutdev++; ! } found = 1; } --- 49,61 ---- } mac_nmidioutdev = 0; ! for (int i=0; i<nmidiout; i++) { int found = 0,count = Pm_CountDevices(); ! for (int j=0, devno=0; j<count && !found; j++) { const PmDeviceInfo *info = Pm_GetDeviceInfo(j); if (info->output) { if (devno == midioutvec[i]) { err = Pm_OpenOutput(&mac_midioutdevlist[mac_nmidioutdev],j,NULL,0,NULL,NULL,0); ! if (err != pmNoError) post("could not open midi output %d (%s): %s",j,info->name,Pm_GetErrorText(err)); ! else {mac_nmidioutdev++; if (sys_verbose) post("Midi Output (%s) opened.",info->name);} found = 1; } *************** *** 77,85 **** }
! void sys_close_midi (void) { ! int i; ! for (i = 0; i < mac_nmidiindev; i++) Pm_Close(mac_midiindevlist[i]); mac_nmidiindev = 0; ! for (i = 0; i < mac_nmidioutdev; i++) Pm_Close(mac_midioutdevlist[i]); mac_nmidioutdev = 0; } --- 67,74 ---- }
! void sys_close_midi () { ! for (int i=0; i< mac_nmidiindev; i++) Pm_Close(mac_midiindevlist[i]); mac_nmidiindev = 0; ! for (int i=0; i<mac_nmidioutdev; i++) Pm_Close(mac_midioutdevlist[i]); mac_nmidioutdev = 0; } *************** *** 156,163 **** }
! void sys_poll_midi(void) { ! int i, j; PmEvent buffer; ! for (i = 0; i < mac_nmidiindev; i++) { int nmess = Pm_Read(mac_midiindevlist[i], &buffer, 1); if (nmess > 0) { --- 145,151 ---- }
! void sys_poll_midi() { PmEvent buffer; ! for (int i=0; i<mac_nmidiindev; i++) { int nmess = Pm_Read(mac_midiindevlist[i], &buffer, 1); if (nmess > 0) { *************** *** 166,170 **** if(status == 0xf0 || !(status&0x80)) { /* sysex header or data */ ! for(j = 0; j < 4; ++j,msg >>= 8) { int data = msg&0xff; sys_midibytein(i, data); --- 154,158 ---- if(status == 0xf0 || !(status&0x80)) { /* sysex header or data */ ! for(int j=0; j<4; ++j,msg >>= 8) { int data = msg&0xff; sys_midibytein(i, data); *************** *** 208,214 **** #if 0 /* lifted from pa_devs.c in portaudio */ ! void sys_listmididevs(void) { ! int i,j; ! for (i = 0; i < Pm_CountDevices(); i++) { const PmDeviceInfo *info = Pm_GetDeviceInfo(i); printf("%d: %s, %s", i, info->interf, info->name); --- 196,201 ---- #if 0 /* lifted from pa_devs.c in portaudio */ ! void sys_listmididevs() { ! for (int i=0; i<Pm_CountDevices(); i++) { const PmDeviceInfo *info = Pm_GetDeviceInfo(i); printf("%d: %s, %s", i, info->interf, info->name); *************** *** 221,237 ****
void midi_getdevs(char *indevlist, int *nindevs, char *outdevlist, int *noutdevs, int maxndev, int devdescsize) { ! int i, nindev = 0, noutdev = 0; ! for (i = 0; i < Pm_CountDevices(); i++) { const PmDeviceInfo *info = Pm_GetDeviceInfo(i); ! /* post("%d: %s, %s (%d,%d)", i, info->interf, info->name, ! info->input, info->output); */ ! if (info->input && nindev < maxndev) { ! strcpy(indevlist + nindev * devdescsize, info->name); ! nindev++; ! } ! if (info->output && noutdev < maxndev) { ! strcpy(outdevlist + noutdev * devdescsize, info->name); ! noutdev++; ! } } *nindevs = nindev; --- 208,217 ----
void midi_getdevs(char *indevlist, int *nindevs, char *outdevlist, int *noutdevs, int maxndev, int devdescsize) { ! int nindev=0, noutdev=0; ! for (int i=0; i<Pm_CountDevices(); i++) { const PmDeviceInfo *info = Pm_GetDeviceInfo(i); ! /* post("%d: %s, %s (%d,%d)", i, info->interf, info->name,info->input, info->output); */ ! if (info->input && nindev < maxndev) {strcpy(indevlist + nindev * devdescsize, info->name); nindev++;} ! if (info->output && noutdev < maxndev) {strcpy(outdevlist + noutdev * devdescsize, info->name); noutdev++;} } *nindevs = nindev;