Update of /cvsroot/pure-data/pd/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31620
Modified Files: Tag: devel_0_39 m_glob.c s_audio.c Log Message: new messges to pd: getaudioindev: sends "audioindev $(audioindevs)" to receiver pd getaudiooutdev: sends "audiooutdev $(audiooutdevs)" to receiver pd
if followed by a float argument, it will return the Nth audio device (index starting at 1)
Index: m_glob.c =================================================================== RCS file: /cvsroot/pure-data/pd/src/m_glob.c,v retrieving revision 1.4.4.2.2.2 retrieving revision 1.4.4.2.2.3 diff -C2 -d -r1.4.4.2.2.2 -r1.4.4.2.2.3 *** m_glob.c 21 Aug 2005 11:28:24 -0000 1.4.4.2.2.2 --- m_glob.c 24 Mar 2006 21:36:40 -0000 1.4.4.2.2.3 *************** *** 34,37 **** --- 34,39 ---- void glob_tooltips(t_pd *dummy, t_float f); /* tb: message-based audio configuration { */ + void glob_audio_getaudioindevices(t_pd * dummy, t_float f); + void glob_audio_getaudiooutdevices(t_pd * dummy, t_float f); void glob_audio_samplerate(t_pd * dummy, t_float f); void glob_audio_delay(t_pd * dummy, t_float f); *************** *** 64,67 **** --- 66,74 ---- int i; char str[80]; + if (s == gensym("audioindevices")) + return; + if (s == gensym("audiooutdevices")) + return; + startpost("%s: unknown message %s ", class_getname(pd_class(x)), s->s_name); *************** *** 141,144 **** --- 148,155 ---- 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_DEFFLOAT, 0); + class_addmethod(glob_pdobject, (t_method)glob_audio_getaudiooutdevices, + gensym("getaudiooutdev"), A_DEFFLOAT, 0); /* tb } */ #ifdef UNIX
Index: s_audio.c =================================================================== RCS file: /cvsroot/pure-data/pd/src/s_audio.c,v retrieving revision 1.5.4.16.2.7 retrieving revision 1.5.4.16.2.8 diff -C2 -d -r1.5.4.16.2.7 -r1.5.4.16.2.8 *** s_audio.c 24 Mar 2006 15:56:30 -0000 1.5.4.16.2.7 --- s_audio.c 24 Mar 2006 21:36:40 -0000 1.5.4.16.2.8 *************** *** 592,597 **** #define DEVDESCSIZE 80
! /* tb: removed static flag */ ! EXTERN void audio_getdevs(char *indevlist, int *nindevs, char *outdevlist, int *noutdevs, int *canmulti, int maxndev, int devdescsize) --- 592,596 ---- #define DEVDESCSIZE 80
! static void audio_getdevs(char *indevlist, int *nindevs, char *outdevlist, int *noutdevs, int *canmulti, int maxndev, int devdescsize) *************** *** 1235,1238 **** --- 1234,1349 ---- }
+ + void glob_audio_getaudioindevices(t_pd * dummy, t_float f) + { + float flongform = 0; + char buf[1024 + 2 * MAXNDEV*(DEVDESCSIZE+4)]; + /* these are the devices you're using: */ + int naudioindev, audioindev[MAXAUDIOINDEV], chindev[MAXAUDIOINDEV]; + int naudiooutdev, audiooutdev[MAXAUDIOOUTDEV], choutdev[MAXAUDIOOUTDEV]; + int audioindev1, audioindev2, audioindev3, audioindev4, + audioinchan1, audioinchan2, audioinchan3, audioinchan4, + audiooutdev1, audiooutdev2, audiooutdev3, audiooutdev4, + audiooutchan1, audiooutchan2, audiooutchan3, audiooutchan4; + int rate, dacblocksize, advance, scheduler; + /* these are all the devices on your system: */ + char indevlist[MAXNDEV*DEVDESCSIZE], outdevlist[MAXNDEV*DEVDESCSIZE]; + int nindevs = 0, noutdevs = 0, canmulti = 0, i; + + char indevliststring[MAXNDEV*(DEVDESCSIZE+4)+80], + outdevliststring[MAXNDEV*(DEVDESCSIZE+4)+80]; + + char str[DEVDESCSIZE]; + + t_atom argv[MAXNDEV]; + t_symbol * selector = gensym("audioindevice"); + t_symbol * pd = gensym("pd"); + + audio_getdevs(indevlist, &nindevs, outdevlist, &noutdevs, &canmulti, + MAXNDEV, DEVDESCSIZE); + + sys_get_audio_params(&naudioindev, audioindev, chindev, &naudiooutdev, + audiooutdev, choutdev, &rate, &dacblocksize, + &advance, &scheduler); + + 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 <= (float) nindevs && f > 0) + { + t_symbol * sym; + strcpy(str, indevlist + ((int)f - 1) * DEVDESCSIZE); + sym = gensym(str); + SETSYMBOL(argv+1+(int)(f), sym); + typedmess(pd->s_thing, selector, 1, argv); + } + } + + void glob_audio_getaudiooutdevices(t_pd * dummy, float f) + { + float flongform = 0; + char buf[1024 + 2 * MAXNDEV*(DEVDESCSIZE+4)]; + /* these are the devices you're using: */ + int naudioindev, audioindev[MAXAUDIOINDEV], chindev[MAXAUDIOINDEV]; + int naudiooutdev, audiooutdev[MAXAUDIOOUTDEV], choutdev[MAXAUDIOOUTDEV]; + int audioindev1, audioindev2, audioindev3, audioindev4, + audioinchan1, audioinchan2, audioinchan3, audioinchan4, + audiooutdev1, audiooutdev2, audiooutdev3, audiooutdev4, + audiooutchan1, audiooutchan2, audiooutchan3, audiooutchan4; + int rate, dacblocksize, advance, scheduler; + /* these are all the devices on your system: */ + char indevlist[MAXNDEV*DEVDESCSIZE], outdevlist[MAXNDEV*DEVDESCSIZE]; + int nindevs = 0, noutdevs = 0, canmulti = 0, i; + + char indevliststring[MAXNDEV*(DEVDESCSIZE+4)+80], + outdevliststring[MAXNDEV*(DEVDESCSIZE+4)+80]; + + char str[DEVDESCSIZE]; + + t_atom argv[MAXNDEV]; + t_symbol * selector = gensym("audiooutdevices"); + t_symbol * pd = gensym("pd"); + + audio_getdevs(indevlist, &nindevs, outdevlist, &noutdevs, &canmulti, + MAXNDEV, DEVDESCSIZE); + + sys_get_audio_params(&naudioindev, audioindev, chindev, &naudiooutdev, + audiooutdev, choutdev, &rate, &dacblocksize, + &advance, &scheduler); + + 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 <= (float) noutdevs && f > 0) + { + t_symbol * sym; + strcpy(str, outdevlist + ((int)f - 1) * DEVDESCSIZE); + sym = gensym(str); + SETSYMBOL(argv+1+(int)(f), sym); + typedmess(pd->s_thing, selector, 1, argv); + } + } + + /* tb } */