Update of /cvsroot/pure-data/pd/src
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14406
Modified Files:
Tag: devel_0_39
s_midi.c m_glob.c
Log Message:
getmidiindev & getmidioutdev messages to query the midi backend by messages
to the pd receiver
Index: s_midi.c
===================================================================
RCS file: /cvsroot/pure-data/pd/src/s_midi.c,v
retrieving revision 1.4.4.1.2.5
retrieving revision 1.4.4.1.2.6
diff -C2 -d -r1.4.4.1.2.5 -r1.4.4.1.2.6
*** s_midi.c 12 Apr 2006 17:36:10 -0000 1.4.4.1.2.5
--- s_midi.c 25 Jul 2006 01:41:40 -0000 1.4.4.1.2.6
***************
*** 18,22 ****
#include <winsock.h>
#include <sys/types.h>
! #include <sys/timeb.h>
#include <wtypes.h>
#endif
--- 18,22 ----
#include <winsock.h>
#include <sys/types.h>
! #include <sys/timeb.h>
#include <wtypes.h>
#endif
***************
*** 290,294 ****
parserp = parser + portno;
outlet_setstacklim();
!
if (byte >= 0xf8)
inmidi_realtimein(portno, byte);
--- 290,294 ----
parserp = parser + portno;
outlet_setstacklim();
!
if (byte >= 0xf8)
inmidi_realtimein(portno, byte);
***************
*** 364,368 ****
inmidi_sysex(portno, byte);
break;
!
/* other kinds of messages are just dropped here. We'll
need another status byte before we start letting MIDI in
--- 364,368 ----
inmidi_sysex(portno, byte);
break;
!
/* other kinds of messages are just dropped here. We'll
need another status byte before we start letting MIDI in
***************
*** 376,380 ****
}
}
! }
midi_intail = (midi_intail + 1 == MIDIQSIZE ? 0 : midi_intail + 1);
}
--- 376,380 ----
}
}
! }
midi_intail = (midi_intail + 1 == MIDIQSIZE ? 0 : midi_intail + 1);
}
***************
*** 495,499 ****
if (n < 2)
strcpy(buf, "{}");
!
}
void sys_get_midi_params(int *pnmidiindev, int *pmidiindev,
--- 495,499 ----
if (n < 2)
strcpy(buf, "{}");
!
}
void sys_get_midi_params(int *pnmidiindev, int *pmidiindev,
***************
*** 503,510 ****
*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];
}
--- 503,510 ----
*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];
}
***************
*** 516,523 ****
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];
}
--- 516,523 ----
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];
}
***************
*** 526,530 ****
{
#ifdef USEAPI_ALSA
! midi_alsa_init();
#endif
#ifdef USEAPI_OSS
--- 526,530 ----
{
#ifdef USEAPI_ALSA
! midi_alsa_init();
#endif
#ifdef USEAPI_OSS
***************
*** 533,545 ****
if (enable)
#ifdef USEAPI_ALSA
! if (sys_midiapi == API_ALSA)
! sys_alsa_do_open_midi(nmidiindev, midiindev, nmidioutdev, midioutdev);
! else
#endif /* ALSA */
! sys_do_open_midi(nmidiindev, midiindev, nmidioutdev, midioutdev);
sys_save_midi_params(nmidiindev, midiindev,
nmidioutdev, midioutdev);
! sys_vgui("set pd_whichmidiapi %d\n", sys_midiapi);
}
--- 533,545 ----
if (enable)
#ifdef USEAPI_ALSA
! if (sys_midiapi == API_ALSA)
! sys_alsa_do_open_midi(nmidiindev, midiindev, nmidioutdev, midioutdev);
! else
#endif /* ALSA */
! sys_do_open_midi(nmidiindev, midiindev, nmidioutdev, midioutdev);
sys_save_midi_params(nmidiindev, midiindev,
nmidioutdev, midioutdev);
! sys_vgui("set pd_whichmidiapi %d\n", sys_midiapi);
}
***************
*** 683,713 ****
midiindev3 = (nindev > 2 && midiindev[2]>= 0 ? midiindev[2]+1 : 0);
midiindev4 = (nindev > 3 && midiindev[3]>= 0 ? midiindev[3]+1 : 0);
! midioutdev1 = (noutdev > 0 && midioutdev[0]>=0 ? midioutdev[0]+1 : 0);
! midioutdev2 = (noutdev > 1 && midioutdev[1]>=0 ? midioutdev[1]+1 : 0);
! midioutdev3 = (noutdev > 2 && midioutdev[2]>=0 ? midioutdev[2]+1 : 0);
! midioutdev4 = (noutdev > 3 && midioutdev[3]>=0 ? midioutdev[3]+1 : 0);
#ifdef USEAPI_ALSA
! if (sys_midiapi == API_ALSA)
! sprintf(buf,
! "pdtk_alsa_midi_dialog %%s \
%s %d %d %d %d %s %d %d %d %d \
%d 1\n",
! indevliststring,
! midiindev1, midiindev2, midiindev3, midiindev4,
! outdevliststring,
! midioutdev1, midioutdev2, midioutdev3, midioutdev4,
! (flongform != 0));
! else
#endif
! sprintf(buf,
"pdtk_midi_dialog %%s \
%s %d %d %d %d %s %d %d %d %d \
%d\n",
! indevliststring,
! midiindev1, midiindev2, midiindev3, midiindev4,
! outdevliststring,
! midioutdev1, midioutdev2, midioutdev3, midioutdev4,
! (flongform != 0));
gfxstub_deleteforkey(0);
gfxstub_new(&glob_pdobject, (void *)glob_midi_properties, buf);
--- 683,713 ----
midiindev3 = (nindev > 2 && midiindev[2]>= 0 ? midiindev[2]+1 : 0);
midiindev4 = (nindev > 3 && midiindev[3]>= 0 ? midiindev[3]+1 : 0);
! midioutdev1 = (noutdev > 0 && midioutdev[0]>=0 ? midioutdev[0]+1 : 0);
! midioutdev2 = (noutdev > 1 && midioutdev[1]>=0 ? midioutdev[1]+1 : 0);
! midioutdev3 = (noutdev > 2 && midioutdev[2]>=0 ? midioutdev[2]+1 : 0);
! midioutdev4 = (noutdev > 3 && midioutdev[3]>=0 ? midioutdev[3]+1 : 0);
#ifdef USEAPI_ALSA
! if (sys_midiapi == API_ALSA)
! sprintf(buf,
! "pdtk_alsa_midi_dialog %%s \
%s %d %d %d %d %s %d %d %d %d \
%d 1\n",
! indevliststring,
! midiindev1, midiindev2, midiindev3, midiindev4,
! outdevliststring,
! midioutdev1, midioutdev2, midioutdev3, midioutdev4,
! (flongform != 0));
! else
#endif
! sprintf(buf,
"pdtk_midi_dialog %%s \
%s %d %d %d %d %s %d %d %d %d \
%d\n",
! indevliststring,
! midiindev1, midiindev2, midiindev3, midiindev4,
! outdevliststring,
! midioutdev1, midioutdev2, midioutdev3, midioutdev4,
! (flongform != 0));
gfxstub_deleteforkey(0);
gfxstub_new(&glob_pdobject, (void *)glob_midi_properties, buf);
***************
*** 747,762 ****
alsadevin = atom_getintarg(8, argc, argv);
alsadevout = atom_getintarg(9, argc, argv);
!
#ifdef USEAPI_ALSA
if (sys_midiapi == API_ALSA)
! {
sys_alsa_close_midi();
! sys_open_midi(alsadevin, newmidiindev, alsadevout, newmidioutdev, 1);
! }
else
#endif
! {
sys_close_midi();
sys_open_midi(nindev, newmidiindev, noutdev, newmidioutdev, 1);
! }
}
--- 747,836 ----
alsadevin = atom_getintarg(8, argc, argv);
alsadevout = atom_getintarg(9, argc, argv);
!
#ifdef USEAPI_ALSA
if (sys_midiapi == API_ALSA)
! {
sys_alsa_close_midi();
! sys_open_midi(alsadevin, newmidiindev, alsadevout, newmidioutdev, 1);
! }
else
#endif
! {
sys_close_midi();
sys_open_midi(nindev, newmidiindev, noutdev, newmidioutdev, 1);
! }
! }
!
! /* tb { */
!
! void glob_midi_getindevs(t_pd *dummy)
! {
! char buf[1024 + 2 * MAXNDEV*(DEVDESCSIZE+4)];
!
! /* these are the devices you're using: */
! int nindev, midiindev[MAXMIDIINDEV];
! int noutdev, midioutdev[MAXMIDIOUTDEV];
! int midiindev1, midiindev2, midiindev3, midiindev4,
! midioutdev1, midioutdev2, midioutdev3, midioutdev4;
!
! /* these are all the devices on your system: */
! char indevlist[MAXNDEV*DEVDESCSIZE], outdevlist[MAXNDEV*DEVDESCSIZE];
! int nindevs = 0, noutdevs = 0, i;
!
! char indevliststring[MAXNDEV*(DEVDESCSIZE+4)+80],
! outdevliststring[MAXNDEV*(DEVDESCSIZE+4)+80];
!
! t_atom argv[MAXNDEV];
! char str[DEVDESCSIZE];
!
! t_symbol * selector = gensym("midiindev");
! t_symbol * pd = gensym("pd");
!
! midi_getdevs(indevlist, &nindevs, outdevlist, &noutdevs,
! MAXNDEV, DEVDESCSIZE);
!
! 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);
! }
!
! void glob_midi_getoutdevs(t_pd *dummy)
! {
! char buf[1024 + 2 * MAXNDEV*(DEVDESCSIZE+4)];
!
! /* these are the devices you're using: */
! int nindev, midiindev[MAXMIDIINDEV];
! int noutdev, midioutdev[MAXMIDIOUTDEV];
! int midiindev1, midiindev2, midiindev3, midiindev4,
! midioutdev1, midioutdev2, midioutdev3, midioutdev4;
!
! /* these are all the devices on your system: */
! char indevlist[MAXNDEV*DEVDESCSIZE], outdevlist[MAXNDEV*DEVDESCSIZE];
! int nindevs = 0, noutdevs = 0, i;
!
! char indevliststring[MAXNDEV*(DEVDESCSIZE+4)+80],
! outdevliststring[MAXNDEV*(DEVDESCSIZE+4)+80];
!
! t_atom argv[MAXNDEV];
! char str[DEVDESCSIZE];
!
! t_symbol * selector = gensym("midioutdev");
! t_symbol * pd = gensym("pd");
!
! midi_getdevs(indevlist, &nindevs, outdevlist, &noutdevs,
! MAXNDEV, DEVDESCSIZE);
!
! 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);
}
Index: m_glob.c
===================================================================
RCS file: /cvsroot/pure-data/pd/src/m_glob.c,v
retrieving revision 1.4.4.2.2.10
retrieving revision 1.4.4.2.2.11
diff -C2 -d -r1.4.4.2.2.10 -r1.4.4.2.2.11
*** m_glob.c 27 Jun 2006 15:47:46 -0000 1.4.4.2.2.10
--- m_glob.c 25 Jul 2006 01:41:40 -0000 1.4.4.2.2.11
***************
*** 48,51 ****
--- 48,53 ----
void glob_audio_getcurrent_devices(void);
void glob_audio_asio_latencies(t_pd * dummy, t_float f);
+ void glob_midi_getindevs(t_pd *dummy);
+ void glob_midi_getoutdevs(t_pd *dummy);
/* tb } */
***************
*** 85,93 ****
if (s == gensym("xrun"))
return;
! if (s == gensym("audio_started"))
return;
if (s == gensym("sys_lock_timeout"))
return;
!
startpost("%s: unknown message %s ", class_getname(pd_class(x)),
s->s_name);
--- 87,99 ----
if (s == gensym("xrun"))
return;
! if (s == gensym("audio_started"))
return;
if (s == gensym("sys_lock_timeout"))
return;
! if (s == gensym("midiindev"))
! return;
! if (s == gensym("midioutdev"))
! return;
!
startpost("%s: unknown message %s ", class_getname(pd_class(x)),
s->s_name);
***************
*** 117,123 ****
void glob_update_class_list (t_pd *self, t_symbol *cb_recv, t_symbol *cb_sel) {
int n = pd_objectmaker->c_nmethod;
! hashkey k; hashvalue v;
sys_gui("global class_list; set class_list {");
! hash_foreach(k,v,class_table) sys_vgui("%s ", ((t_symbol *)k)->s_name);
sys_gui("}\n");
sys_vgui("%s %s\n",cb_recv->s_name, cb_sel->s_name);
--- 123,129 ----
void glob_update_class_list (t_pd *self, t_symbol *cb_recv, t_symbol *cb_sel) {
int n = pd_objectmaker->c_nmethod;
! hashkey k; hashvalue v;
sys_gui("global class_list; set class_list {");
! hash_foreach(k,v,class_table) sys_vgui("%s ", ((t_symbol *)k)->s_name);
sys_gui("}\n");
sys_vgui("%s %s\n",cb_recv->s_name, cb_sel->s_name);
***************
*** 181,189 ****
class_addmethod(glob_pdobject, (t_method)glob_tooltips,
gensym("tooltips"), A_DEFFLOAT, 0);
! /* tb: message-based audio configuration { */
// class_addmethod(glob_pdobject, (t_method)glob_audio_samplerate,
// gensym("audio-samplerate"), A_DEFFLOAT, 0);
// class_addmethod(glob_pdobject, (t_method)glob_audio_delay,
! // gensym("audio-delay"), A_DEFFLOAT, 0);
// class_addmethod(glob_pdobject, (t_method)glob_audio_dacblocksize,
// gensym("audio-dacblocksize"), A_DEFFLOAT, 0);
--- 187,195 ----
class_addmethod(glob_pdobject, (t_method)glob_tooltips,
gensym("tooltips"), A_DEFFLOAT, 0);
! /* tb: message-based audio configuration { */
// class_addmethod(glob_pdobject, (t_method)glob_audio_samplerate,
// gensym("audio-samplerate"), A_DEFFLOAT, 0);
// class_addmethod(glob_pdobject, (t_method)glob_audio_delay,
! // gensym("audio-delay"), A_DEFFLOAT, 0);
// class_addmethod(glob_pdobject, (t_method)glob_audio_dacblocksize,
// gensym("audio-dacblocksize"), A_DEFFLOAT, 0);
***************
*** 195,214 ****
// gensym("audio-device-in"), A_GIMME, 0);
// class_addmethod(glob_pdobject, (t_method)glob_audio_device_out,
! // gensym("audio-device-out"), A_GIMME, 0);
class_addmethod(glob_pdobject, (t_method)glob_audio_getaudioindevices,
! gensym("getaudioindev"), A_GIMME, 0);
class_addmethod(glob_pdobject, (t_method)glob_audio_getaudiooutdevices,
gensym("getaudiooutdev"), A_GIMME, 0);
class_addmethod(glob_pdobject, (t_method)glob_audio_getaudioindevinfo,
! gensym("getaudioindevinfo"), A_FLOAT, 0);
class_addmethod(glob_pdobject, (t_method)glob_audio_getaudiooutdevinfo,
! gensym("getaudiooutdevinfo"), A_FLOAT, 0);
class_addmethod(glob_pdobject, (t_method)glob_audio_testaudiosetting,
! gensym("testaudiosetting"), A_GIMME, 0);
class_addmethod(glob_pdobject, (t_method)glob_audio_getcurrent_devices,
gensym("getaudiodevice"), 0);
! class_addmethod(glob_pdobject, (t_method)glob_audio_asio_latencies,
gensym("getasiolatencies"), A_DEFFLOAT, 0);
! /* tb } */
#ifdef DESIRE
class_addmethod(glob_pdobject, (t_method)glob_update_class_list,
--- 201,223 ----
// gensym("audio-device-in"), A_GIMME, 0);
// class_addmethod(glob_pdobject, (t_method)glob_audio_device_out,
! // gensym("audio-device-out"), A_GIMME, 0);
class_addmethod(glob_pdobject, (t_method)glob_audio_getaudioindevices,
! gensym("getaudioindev"), A_GIMME, 0);
class_addmethod(glob_pdobject, (t_method)glob_audio_getaudiooutdevices,
gensym("getaudiooutdev"), A_GIMME, 0);
class_addmethod(glob_pdobject, (t_method)glob_audio_getaudioindevinfo,
! gensym("getaudioindevinfo"), A_FLOAT, 0);
class_addmethod(glob_pdobject, (t_method)glob_audio_getaudiooutdevinfo,
! gensym("getaudiooutdevinfo"), A_FLOAT, 0);
class_addmethod(glob_pdobject, (t_method)glob_audio_testaudiosetting,
! gensym("testaudiosetting"), A_GIMME, 0);
class_addmethod(glob_pdobject, (t_method)glob_audio_getcurrent_devices,
gensym("getaudiodevice"), 0);
! class_addmethod(glob_pdobject, (t_method)glob_audio_asio_latencies,
gensym("getasiolatencies"), A_DEFFLOAT, 0);
! class_addmethod(glob_pdobject, (t_method)glob_midi_getoutdevs, gensym("getmidioutdev"), 0);
! class_addmethod(glob_pdobject, (t_method)glob_midi_getindevs, gensym("getmidiindev"), 0);
!
! /* tb } */
#ifdef DESIRE
class_addmethod(glob_pdobject, (t_method)glob_update_class_list,