[PD-cvs] supercollider/k_sc~ gendasc.py,NONE,1.1 help-k_sc~.pd,NONE,1.1 k_sc~.c,NONE,1.1 makefile,NONE,1.1

ksvalast at users.sourceforge.net ksvalast at users.sourceforge.net
Tue Jan 20 17:54:09 CET 2004


Update of /cvsroot/pure-data/supercollider/k_sc~
In directory sc8-pr-cvs1:/tmp/cvs-serv7284

Added Files:
	gendasc.py help-k_sc~.pd k_sc~.c makefile 
Log Message:
Various tools to make supercollider more convenient to use within PD

--- NEW FILE: gendasc.py ---
#!/usr/bin/env python

#/* --------------------------- gendasc  ----------------------------------- */
#/*   ;; 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.  */
#/*                                                                              */
#/* ---------------------------------------------------------------------------- */


import sys,string,xreadlines


path=sys.argv[1]
if path[-1]=="/":
    filename=path+"d_dac.c"
else:
    filename=path+"/"+"d_dac.c"


success=0
for line in xreadlines.xreadlines(open(filename,"r")):
    line=string.replace(line,'adc','from_sc')
    line=string.replace(line,'dac','to_sc')
    line=string.replace(line,"(t_newmethod)from_sc_new","(t_newmethod)from_sc_newnew")
    line=string.replace(line,"(t_newmethod)to_sc_new","(t_newmethod)to_sc_newnew")
    sys.stdout.write(line)
    if line=='#include "m_pd.h"\n':
        print 'static void *from_sc_newnew(t_symbol *s, int argc, t_atom *argv);'
        print 'static void *to_sc_newnew(t_symbol *s, int argc, t_atom *argv);'
        success=1

if success==0:
    print "Fix gendasc.py script."




--- NEW FILE: help-k_sc~.pd ---
#N canvas 0 0 450 300 10;
#X obj 197 62 from_sc~;
#X obj 292 84 to_sc~;
#X obj 285 43 osc~ 500;
#X obj 200 131 dac~;
#X connect 0 0 3 0;
#X connect 0 1 3 1;
#X connect 2 0 1 0;

--- NEW FILE: k_sc~.c ---
/* --------------------------- 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 <stdio.h>
#include <stdbool.h>
#include <jack/jack.h>


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;lokke<num_sc_in;lokke++){
    char temp[500];
    char temp2[500];
    sprintf(temp,"pure_data_0:output%d",lokke+num_outs);
    sprintf(temp2,"SuperCollider:in_%d",lokke+1);
    jack_connect(client,temp,temp2);
    sprintf(temp,"alsa_pcm:capture_%d",lokke+1);
    jack_disconnect(client,temp,temp2);
  }
  for(lokke=0;lokke<num_sc_out;lokke++){
    char temp[500];
    char temp2[500];
    sprintf(temp,"pure_data_0:input%d",lokke+num_ins);
    sprintf(temp2,"SuperCollider:out_%d",lokke+1);
    jack_connect(client,temp2,temp);
    sprintf(temp,"alsa_pcm:playback_%d",lokke+1);
    jack_disconnect(client,temp2,temp);
  }

  inited=true;

 nosupercolliderportsfound:
  jack_client_close(client);


 apiwasnotjack:
  return;
}

static void *from_sc_newnew(t_symbol *s, int argc, t_atom *argv){
  int lokke;
  t_from_sc *x;
  setupjack();
  x=from_sc_new(s,argc,argv);

  for(lokke=0;lokke<x->x_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;lokke<x->x_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();
}

--- NEW FILE: makefile ---
NAME=k_sc~
CSYM=k_sc_tilde

current: pd_linux

# ----------------------- NT -----------------------

pd_nt: $(NAME).dll

.SUFFIXES: .dll

PDNTCFLAGS = /W3 /WX /O2 /G6 /DNT /DPD /nologo
VC="C:\Programme\Microsoft Visual Studio\VC98"

PDNTINCLUDE = /I. /Ic:\pd\tcl\include /Ic:\pd\src /I$(VC)\include /Iinclude

PDNTLDIR = $(VC)\Lib
PDNTLIB = $(PDNTLDIR)\libc.lib \
	$(PDNTLDIR)\oldnames.lib \
	$(PDNTLDIR)\kernel32.lib \
	$(PDNTLDIR)\user32.lib \
	$(PDNTLDIR)\uuid.lib \
	c:\pd\bin\pd.lib \

.c.dll:
	cl $(PDNTCFLAGS) $(PDNTINCLUDE) /c $*.c
	link /dll /export:$(CSYM)_setup $*.obj $(PDNTLIB)

# ----------------------- IRIX 5.x -----------------------

pd_irix5: $(NAME).pd_irix5

.SUFFIXES: .pd_irix5

SGICFLAGS5 = -o32 -DPD -DUNIX -DIRIX -O2

SGIINCLUDE =  -I../../src

.c.pd_irix5:
	cc $(SGICFLAGS5) $(SGIINCLUDE) -o $*.o -c $*.c
	ld -elf -shared -rdata_shared -o $*.pd_irix5 $*.o
	rm $*.o

# ----------------------- IRIX 6.x -----------------------

pd_irix6: $(NAME).pd_irix6

.SUFFIXES: .pd_irix6

SGICFLAGS6 = -n32 -DPD -DUNIX -DIRIX -DN32 -woff 1080,1064,1185 \
	-OPT:roundoff=3 -OPT:IEEE_arithmetic=3 -OPT:cray_ivdep=true \
	-Ofast=ip32

.c.pd_irix6:
	cc $(SGICFLAGS6) $(SGIINCLUDE) -o $*.o -c $*.c
	ld -n32 -IPA -shared -rdata_shared -o $*.pd_irix6 $*.o
	rm $*.o

# ----------------------- LINUX i386 -----------------------

pd_linux: fromto.c $(NAME).pd_linux

.SUFFIXES: .pd_linux

LINUXCFLAGS = -DPD -DUNIX -O2 -funroll-loops -fomit-frame-pointer \
    -Wall -W -Wshadow -Wstrict-prototypes \
    -Wno-unused -Wno-parentheses -Wno-switch

PDSRCDIR=../../src
LINUXINCLUDE =  -I$(PDSRCDIR)

.c.pd_linux: fromto,c
	gcc $(LINUXCFLAGS) $(LINUXINCLUDE) -g -o $*.o -c $*.c
	ld -export_dynamic  -shared -o $*.pd_linux $*.o -lc -lm -ljack
	strip --strip-unneeded $*.pd_linux
	rm -f $*.o ../$*.pd_linux
	ln -s $*/$*.pd_linux ..
	ln -sf $*/$*.pd_linux ../from_sc~.pd_linux
	ln -sf $*/$*.pd_linux ../to_sc~.pd_linux

# ----------------------------------------------------------

fromto.c: gendasc.py
	./gendasc.py $(PDSRCDIR) >fromto.c

install:
	cp help-*.pd ../../doc/5.reference

clean:
	rm -f *.o *.pd_* so_locations fromto.c *~






More information about the Pd-cvs mailing list