Update of /cvsroot/pure-data/pd/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2440
Modified Files: Tag: devel_0_38 s_audio.c m_glob.c Log Message: message-based access to audio-api
Index: s_audio.c =================================================================== RCS file: /cvsroot/pure-data/pd/src/s_audio.c,v retrieving revision 1.5.4.4 retrieving revision 1.5.4.5 diff -C2 -d -r1.5.4.4 -r1.5.4.5 *** s_audio.c 14 Dec 2004 15:56:43 -0000 1.5.4.4 --- s_audio.c 27 Dec 2004 16:02:33 -0000 1.5.4.5 *************** *** 965,966 **** --- 965,1178 ---- #endif } + + + /* tb: message-based audio configuration { */ + void glob_audio_samplerate(t_pd * dummy, t_float f) + { + int naudioindev; + int audioindev[MAXAUDIOINDEV]; + int audiochindev[MAXAUDIOINDEV]; + int naudiooutdev; + int audiooutdev[MAXAUDIOOUTDEV]; + int audiochoutdev[MAXAUDIOOUTDEV]; + int rate; /* dummy */ + int dacblocksize; + int advance; + int scheduler; + + if (f == sys_getsr()) + return; + + sys_get_audio_params(&naudioindev, audioindev, audiochindev, + &naudiooutdev, audiooutdev, audiochoutdev, + &rate, &dacblocksize, &advance, &scheduler); + sys_close_audio(); + sys_open_audio(naudioindev, audioindev, naudioindev, audiochindev, + naudiooutdev, audiooutdev, naudiooutdev, audiochoutdev, + (int)f, dacblocksize, advance, scheduler, 1); + } + + void glob_audio_delay(t_pd * dummy, t_float f) + { + int naudioindev; + int audioindev[MAXAUDIOINDEV]; + int audiochindev[MAXAUDIOINDEV]; + int naudiooutdev; + int audiooutdev[MAXAUDIOOUTDEV]; + int audiochoutdev[MAXAUDIOOUTDEV]; + int rate; + int dacblocksize; + int advance; /* dummy */ + int scheduler; + + if ((int)f == audio_advance) + return; + + sys_get_audio_params(&naudioindev, audioindev, audiochindev, + &naudiooutdev, audiooutdev, audiochoutdev, + &rate, &dacblocksize, &advance, &scheduler); + sys_close_audio(); + sys_open_audio(naudioindev, audioindev, naudioindev, audiochindev, + naudiooutdev, audiooutdev, naudiooutdev, audiochoutdev, + rate, dacblocksize, (int) f, scheduler, 1); + } + + void glob_audio_dacblocksize(t_pd * dummy, t_float f) + { + int naudioindev; + int audioindev[MAXAUDIOINDEV]; + int audiochindev[MAXAUDIOINDEV]; + int naudiooutdev; + int audiooutdev[MAXAUDIOOUTDEV]; + int audiochoutdev[MAXAUDIOOUTDEV]; + int rate; + int dacblocksize; /* dummy */ + int advance; + int scheduler; + + if ((int)f == audio_dacblocksize) + return; + + sys_get_audio_params(&naudioindev, audioindev, audiochindev, + &naudiooutdev, audiooutdev, audiochoutdev, + &rate, &dacblocksize, &advance, &scheduler); + sys_close_audio(); + sys_open_audio(naudioindev, audioindev, naudioindev, audiochindev, + naudiooutdev, audiooutdev, naudiooutdev, audiochoutdev, + rate, (int)f, advance, scheduler, 1); + } + + void glob_audio_scheduler(t_pd * dummy, t_float f) + { + int naudioindev; + int audioindev[MAXAUDIOINDEV]; + int audiochindev[MAXAUDIOINDEV]; + int naudiooutdev; + int audiooutdev[MAXAUDIOOUTDEV]; + int audiochoutdev[MAXAUDIOOUTDEV]; + int rate; + int dacblocksize; + int advance; + int scheduler; /* dummy */ + + if ((int)f == sys_callbackscheduler) + return; + + scheduler = (f != 0) ? 1 : 0; + + sys_get_audio_params(&naudioindev, audioindev, audiochindev, + &naudiooutdev, audiooutdev, audiochoutdev, + &rate, &dacblocksize, &advance, &scheduler); + sys_close_audio(); + sys_open_audio(naudioindev, audioindev, naudioindev, audiochindev, + naudiooutdev, audiooutdev, naudiooutdev, audiochoutdev, + rate, dacblocksize, advance, scheduler, 1); + + if (scheduler != sys_callbackscheduler) + { + if (scheduler == 1) + post("switched to callback-based scheduler"); + else + post("switched to traditional scheduler"); + } + else + post("couldn't change scheduler"); + } + + + void glob_audio_device(t_pd * dummy, t_symbol *s, int argc, t_atom *argv) + { + int naudioindev; + int audioindev[MAXAUDIOINDEV]; + int audiochindev[MAXAUDIOINDEV]; + int naudiooutdev; + int audiooutdev[MAXAUDIOOUTDEV]; + int audiochoutdev[MAXAUDIOOUTDEV]; + int rate; + int dacblocksize; + int advance; + int scheduler; + + int i; + + sys_get_audio_params(&naudioindev, audioindev, audiochindev, + &naudiooutdev, audiooutdev, audiochoutdev, + &rate, &dacblocksize, &advance, &scheduler); + + naudiooutdev = naudioindev = (int)atom_getfloatarg(0, argc, argv); + for (i = 0; i != MAXAUDIOINDEV; i=i+2) + { + audiooutdev[i] = audioindev[i] = atom_getfloatarg(i+1, argc, argv); + audiochoutdev[i] = audiochindev[i] = atom_getfloatarg(i+2, argc, argv); + } + + sys_close_audio(); + sys_open_audio(naudioindev, audioindev, naudioindev, audiochindev, + naudiooutdev, audiooutdev, naudiooutdev, audiochoutdev, + rate, dacblocksize, advance, scheduler, 1); + } + + void glob_audio_device_in(t_pd * dummy, t_symbol *s, int argc, t_atom *argv) + { + int naudioindev; + int audioindev[MAXAUDIOINDEV]; + int audiochindev[MAXAUDIOINDEV]; + int naudiooutdev; + int audiooutdev[MAXAUDIOOUTDEV]; + int audiochoutdev[MAXAUDIOOUTDEV]; + int rate; + int dacblocksize; + int advance; + int scheduler; + + int i; + + sys_get_audio_params(&naudioindev, audioindev, audiochindev, + &naudiooutdev, audiooutdev, audiochoutdev, + &rate, &dacblocksize, &advance, &scheduler); + + naudioindev = (int)atom_getfloatarg(0, argc, argv); + for (i = 0; i != MAXAUDIOINDEV; i=i+2) + { + audioindev[i] = atom_getfloatarg(i+1, argc, argv); + audiochindev[i] = atom_getfloatarg(i+2, argc, argv); + } + + sys_close_audio(); + sys_open_audio(naudioindev, audioindev, naudioindev, audiochindev, + naudiooutdev, audiooutdev, naudiooutdev, audiochoutdev, + rate, dacblocksize, advance, scheduler, 1); + } + + void glob_audio_device_out(t_pd * dummy, t_symbol *s, int argc, t_atom *argv) + { + int naudioindev; + int audioindev[MAXAUDIOINDEV]; + int audiochindev[MAXAUDIOINDEV]; + int naudiooutdev; + int audiooutdev[MAXAUDIOOUTDEV]; + int audiochoutdev[MAXAUDIOOUTDEV]; + int rate; + int dacblocksize; + int advance; + int scheduler; + + int i; + + sys_get_audio_params(&naudioindev, audioindev, audiochindev, + &naudiooutdev, audiooutdev, audiochoutdev, + &rate, &dacblocksize, &advance, &scheduler); + + naudiooutdev = (int)atom_getfloatarg(0, argc, argv); + for (i = 0; i != MAXAUDIOOUTDEV; i=i+2) + { + audiooutdev[i] = atom_getfloatarg(i+1, argc, argv); + audiochoutdev[i] = atom_getfloatarg(i+2, argc, argv); + } + + sys_close_audio(); + sys_open_audio(naudioindev, audioindev, naudioindev, audiochindev, + naudiooutdev, audiooutdev, naudiooutdev, audiochoutdev, + rate, dacblocksize, advance, scheduler, 1); + } + /* tb } */
Index: m_glob.c =================================================================== RCS file: /cvsroot/pure-data/pd/src/m_glob.c,v retrieving revision 1.4.4.1 retrieving revision 1.4.4.2 diff -C2 -d -r1.4.4.1 -r1.4.4.2 *** m_glob.c 5 Nov 2004 14:27:46 -0000 1.4.4.1 --- m_glob.c 27 Dec 2004 16:02:34 -0000 1.4.4.2 *************** *** 32,35 **** --- 32,44 ---- void glob_savepreferences(t_pd *dummy); void glob_tooltips(t_pd *dummy, t_float f); + /* tb: message-based audio configuration { */ + void glob_audio_samplerate(t_pd * dummy, t_float f); + void glob_audio_delay(t_pd * dummy, t_float f); + void glob_audio_dacblocksize(t_pd * dummy, t_float f); + void glob_audio_scheduler(t_pd * dummy, t_float f); + void glob_audio_device(t_pd * dummy, t_symbol *s, int argc, t_atom *argv); + void glob_audio_device_in(t_pd * dummy, t_symbol *s, int argc, t_atom *argv); + void glob_audio_device_out(t_pd * dummy, t_symbol *s, int argc, t_atom *argv); + /* tb } */
void alsa_resync( void); *************** *** 112,115 **** --- 121,140 ---- 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); + class_addmethod(glob_pdobject, (t_method)glob_audio_scheduler, + gensym("audio-scheduler"), A_DEFFLOAT, 0); + class_addmethod(glob_pdobject, (t_method)glob_audio_device, + gensym("audio-device"), A_GIMME, 0); + class_addmethod(glob_pdobject, (t_method)glob_audio_device_in, + gensym("audio-device-in"), A_GIMME, 0); + class_addmethod(glob_pdobject, (t_method)glob_audio_device_out, + gensym("audio-device-out"), A_GIMME, 0); + /* tb } */ #ifdef UNIX class_addmethod(glob_pdobject, (t_method)glob_watchdog,