void xapi_open_midi(void *d) { #ifdef HAVE_MIDI char *mp; if (d && strlen(d)>0) mp=d; else mp="-1"; // midiid ? if (midi_connected()) remote_printf(441,"MIDI port already connected."); midi_open(mp); if (midi_connected()) { remote_printf(100,"MIDI connected."); strncpy(midiid,mp,32); midiid[31]=0; } else remote_printf(440,"MIDI open failed."); #else remote_printf(499,"midi not available."); #endif }
void xapi_detect_midi(void *d) { #ifdef HAVE_MIDI midi_open("-1"); if (midi_connected()) remote_printf(100,"MIDI connected."); else remote_printf(440,"MIDI open failed."); #else remote_printf(499,"midi not available."); #endif }
static int oscb_midiconnect (const char *path, const char *types, lo_arg **argv, int argc, lo_message msg, void *user_data){ #ifdef HAVE_MIDI char *mp; if (&argv[0]->s && strlen(&argv[0]->s)>0) mp=&argv[0]->s; else mp="-1"; midi_open(mp); if (midi_connected()) { strncpy(midiid,mp,32); // XXX we need a better idea for 'xapi_reopen_midi() midiid[31]=0; } #endif return(0); }
void xapi_midi_status(void *d) { #ifdef HAVE_MIDI // FIXME: we shall return "200,midiid=XXX" // and "100 not connected" ?? as in jack connected // BUT: // midiid can be <int> (portmidi) or string (alsa midi) if (midi_connected()) remote_printf(100,"midi connected."); else remote_printf(199,"midi not connected."); #else remote_printf(499,"midi not available."); #endif }
void xapi_psync(void *d) { int ss =0; #if defined (HAVE_LTCSMPTE) || defined (HAVE_LTC) if (ltcjack_connected()) ss=3; else #endif #ifdef HAVE_MIDI if (midi_connected()) ss=2; else #endif if (jack_connected()) ss=1; remote_printf(201,"syncsource=%i",ss); }
int main (int argc, char **argv) { int run; char *filename = NULL; long frame, pframe; program_name = argv[0]; if (argc>3) usage(1); if (argc==3) { filename=argv[2]; frames=atol(argv[1]); } else if (argc>1) filename=argv[1]; if (frames < 1 || duration < 1) usage(1); if (!filename) usage(1); framerate = (double) frames / (double) duration; struct timeval tv; fd_set set; //TODO: trap some signals.. -> run=0; if (jack) { open_jack(); run= jack_connected(); } else{ #ifdef HAVE_MIDI midi_open(midiid); #endif run= midi_connected(); } printf ("jack disconnect\n"); printf ("load %s\n",filename); printf ("window mouse off\n"); printf ("window letterbox on\n"); printf ("window fullscreen on\n"); // printf ("window resize 880x545\n"); printf ("osd font /usr/share/fonts/truetype/freefont/FreeMonoBold.ttf\n"); printf ("osd off\n"); printf ("osd smpte 100\n"); printf ("set fps %.0f\n",framerate); pframe=-1; while (run) { tv.tv_sec = 0; tv.tv_usec = 1000000/framerate; FD_ZERO(&set); if (readfromstdin) FD_SET(0, &set); if (select(0+readfromstdin, &set, NULL, NULL, &tv) ) if (readfromstdin) { size_t rv; char buf[BUFSIZ]; if ((rv=read(0,buf,BUFSIZ)) > 0) { if (!strncmp(buf,"exit",3)) { printf ("quit\n"); run=0; }else write(1,buf,rv); } } if (jack) frame= jack_poll_frame(NULL); #ifdef HAVE_MIDI else frame= midi_poll_frame(); #else else exit (1); #endif if (pframe!=frame) printf ("seek %li\n",frame); pframe=frame; fflush(stdout); }