From 5a2a3440f0c4558258c19a694e1c5d550db06a37 Mon Sep 17 00:00:00 2001 From: "Kjetil S. Matheussen" Date: Tue, 20 Jan 2004 16:56:23 +0000 Subject: Various tools to make supercollider more convenient to use within PD svn path=/trunk/; revision=1271 --- supercollider/k_sc~/k_sc~.c | 147 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 147 insertions(+) create mode 100644 supercollider/k_sc~/k_sc~.c (limited to 'supercollider/k_sc~/k_sc~.c') diff --git a/supercollider/k_sc~/k_sc~.c b/supercollider/k_sc~/k_sc~.c new file mode 100644 index 00000000..2b743ad9 --- /dev/null +++ b/supercollider/k_sc~/k_sc~.c @@ -0,0 +1,147 @@ +/* --------------------------- k_sc~ ----------------------------------- */ +/* ;; Kjetil S. Matheussen, 2004. */ +/* */ +/* This program is free software; you can redistribute it and/or */ +/* modify it under the terms of the GNU General Public License */ +/* as published by the Free Software Foundation; either version 2 */ +/* of the License, or (at your option) any later version. */ +/* */ +/* This program is distributed in the hope that it will be useful, */ +/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ +/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ +/* GNU General Public License for more details. */ +/* */ +/* You should have received a copy of the GNU General Public License */ +/* along with this program; if not, write to the Free Software */ +/* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +/* */ +/* ---------------------------------------------------------------------------- */ + + + +#include "fromto.c" + +#include +#include +#include + + +static int num_ins=0; +static int num_outs=0; + +static int getnumjackchannels(jack_client_t *client,char *regstring){ + int lokke=0; + const char **ports=jack_get_ports(client,regstring,"",0); + if(ports==NULL) return 0; + while(ports[lokke]!=NULL){ + lokke++; + } + return lokke; +} + +static void setupjack(void){ + static bool inited=false; + int lokke; + int num_sc_in,num_sc_out; + + jack_client_t *client; + + if(inited==true) return; + + if(sys_audioapi!=API_JACK){ + post("Error. k_sc~ will not work without jack as the sound API."); + goto apiwasnotjack; + } + + client=jack_client_new("k_sc_tilde"); + + num_sc_in=getnumjackchannels(client,"SuperCollider:in_*"); + num_sc_out=getnumjackchannels(client,"SuperCollider:out_*"); + + if(num_sc_in==0 || num_sc_out==0){ + post("Error. No Supercollider jack ports found."); + goto nosupercolliderportsfound; + } + + num_ins=sys_get_inchannels(); + num_outs=sys_get_outchannels(); + + { + int t1[1]={0}; + int t2[1]={0}; + int t3[1]={num_sc_out+num_ins}; + int t4[1]={num_sc_in+num_outs}; + sys_close_audio(); + sys_open_audio(1,t1, + 1,t3, + 1,t2, + 1,t4, + sys_getsr(),sys_schedadvance/1000,1); + } + + for(lokke=0;lokkex_n;lokke++){ + x->x_vec[lokke]+=num_outs; + } + return x; +} + +static void *to_sc_newnew(t_symbol *s, int argc, t_atom *argv){ + int lokke; + t_to_sc *x; + setupjack(); + x=to_sc_new(s,argc,argv); + + for(lokke=0;lokkex_n;lokke++){ + x->x_vec[lokke]+=num_ins; + } + return x; +} + + +static void k_sc_tilde_setup(void){ + d_to_sc_setup(); +} + + +void from_sc_tilde_setup(void){ + k_sc_tilde_setup(); +} + +void to_sc_tilde_setup(void){ + k_sc_tilde_setup(); +} -- cgit v1.2.1