Update of /cvsroot/pure-data/pd/extra/loop~ In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21746/loop~
Added Files: Tag: devel_0_39 loop~.c makefile test-loop~.pd Log Message: missing extra files
--- NEW FILE: test-loop~.pd --- #N canvas 33 0 680 609 12; #X floatatom 52 262 0 0 0 0 - - -; #X obj 261 346 print~; #X msg 47 373 bang; #X msg 274 313 bang; #X obj 52 306 loop~; #X floatatom 102 245 0 0 0 0 - - -; #N canvas 0 0 450 300 graph1 0; #X array array1 44100 float 0; #X coords 0 10 44100 0 200 150 1; #X restore 65 17 graph; #X msg 43 204 ; array1 resize 44100; #X obj 25 401 tabwrite~ array1; #X msg 208 371 bang; #X obj 176 402 tabwrite~ array1; #X msg 194 261 bang; #X obj 204 347 print~; #X msg 217 314 bang; #N canvas 0 0 450 300 graph1 0; #X array array2 150000 float 0; #X coords 0 1 150000 -1 200 150 1; #X restore 332 398 graph; #X msg 326 274 ; array2 resize 150000; #X obj 103 529 tabread4~ array2; #X obj 64 481 *~; #X obj 107 581 dac~; #X obj 105 552 hip~ 5; #X obj 123 482 samphold~; #X obj 102 506 +~; #X floatatom 106 430 0 0 0 0 - - -; #X obj 108 453 *~ 1000; #X obj 312 215 soundfiler; #X msg 330 170 read ../doc/sound/bell.aiff array2; #X msg 330 193 read ../doc/sound/vocal.aiff array2; #X connect 0 0 4 0; #X connect 2 0 8 0; #X connect 3 0 1 0; #X connect 4 0 12 0; #X connect 4 0 17 0; #X connect 4 0 8 0; #X connect 4 0 20 1; #X connect 4 1 10 0; #X connect 4 1 1 0; #X connect 4 1 17 1; #X connect 5 0 4 1; #X connect 9 0 10 0; #X connect 11 0 4 0; #X connect 13 0 12 0; #X connect 16 0 19 0; #X connect 17 0 21 0; #X connect 19 0 18 0; #X connect 19 0 18 1; #X connect 20 0 21 1; #X connect 21 0 16 0; #X connect 22 0 23 0; #X connect 23 0 20 0; #X connect 25 0 24 0; #X connect 26 0 24 0;
--- NEW FILE: makefile --- NAME=loop~ CSYM=loop_tilde
current: pd_linux
# ----------------------- NT -----------------------
pd_nt: $(NAME).dll
.SUFFIXES: .dll
PDNTCFLAGS = /W3 /WX /DNT /DPD /nologo VC="C:\Program Files\Microsoft Visual Studio\Vc98"
PDNTINCLUDE = /I. /I....\src /I$(VC)\include
PDNTLDIR = $(VC)\lib PDNTLIB = $(PDNTLDIR)\libc.lib \ $(PDNTLDIR)\oldnames.lib \ $(PDNTLDIR)\kernel32.lib \ ....\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: $(NAME).pd_linux
.SUFFIXES: .pd_linux
LINUXCFLAGS = -DPD -O2 -funroll-loops -fomit-frame-pointer -fPIC \ -Wall -W -Wshadow -Wstrict-prototypes \ -Wno-unused -Wno-parentheses -Wno-switch $(CFLAGS)
LINUXINCLUDE = -I../../src
.c.pd_linux: $(CC) $(LINUXCFLAGS) $(LINUXINCLUDE) -o $*.o -c $*.c ld -export_dynamic -shared -o $*.pd_linux $*.o -lc -lm strip --strip-unneeded $*.pd_linux rm -f $*.o
# ----------------------- Mac OSX -----------------------
pd_darwin: $(NAME).pd_darwin
.SUFFIXES: .pd_darwin
DARWINCFLAGS = -DPD -O2 -Wall -W -Wshadow -Wstrict-prototypes \ -Wno-unused -Wno-parentheses -Wno-switch
.c.pd_darwin: $(CC) $(DARWINCFLAGS) $(LINUXINCLUDE) -o $*.o -c $*.c $(CC) -bundle -undefined suppress -flat_namespace -o $*.pd_darwin $*.o rm -f $*.o
# ----------------------------------------------------------
clean: rm -f *.o *.pd_* so_locations
--- NEW FILE: loop~.c --- /* loop~ -- loop generator for sampling */
/* Copyright 1997-1999 Miller Puckette. Permission is granted to use this software for any purpose provided you keep this copyright notice intact.
THE AUTHOR AND HIS EMPLOYERS MAKE NO WARRANTY, EXPRESS OR IMPLIED, IN CONNECTION WITH THIS SOFTWARE.
This file is downloadable from http://www.crca.ucsd.edu/~msp .
*/
#ifdef PD #include "m_pd.h" #endif
typedef struct _loopctl { double l_phase; float l_invwindow; float l_window; int l_resync; } t_loopctl;
static void loopctl_run(t_loopctl *x, float *transposein, float *windowin, float *rawout, float *windowout, int n) { float window, invwindow; double phase = x->l_phase; if (x->l_resync) { window = *windowin; if (window < 0) { if (window > -1) window = -1; invwindow = -1/window; } else { if (window < 1) window = 1; invwindow = 1/window; } x->l_resync = 0; } else { window = x->l_window; phase = x->l_phase; invwindow = x->l_invwindow; } while (n--) { double phaseinc = invwindow * *transposein++; double newphase; float nwind = *windowin++; if (phaseinc >= 1 || phaseinc < 0) phaseinc = 0; newphase = phase + phaseinc; if (newphase >= 1) { window = nwind; if (window < 0) { if (window > -1) window = -1; invwindow = -1/window; } else { if (window < 1) window = 1; invwindow = 1/window; } newphase -= 1.; } phase = newphase; *rawout++ = (float)phase; *windowout++ = window; } x->l_invwindow = invwindow; x->l_window = window; x->l_phase = phase; }
static void loopctl_init(t_loopctl *x) { x->l_window = 1; x->l_invwindow = 1; x->l_phase = 0; }
static void loopctl_set(t_loopctl *x, float val) { if (val < 0 || val > 1) val = 0; x->l_phase = val; x->l_resync = 1; }
#ifdef PD
typedef struct _loop { t_object x_obj; t_float x_f; t_loopctl x_loopctl; } t_loop;
static t_class *loop_class;
static void *loop_new(void) { t_loop *x = (t_loop *)pd_new(loop_class); loopctl_init(&x->x_loopctl); inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_signal, &s_signal); outlet_new(&x->x_obj, gensym("signal")); outlet_new(&x->x_obj, gensym("signal")); return (x); }
static t_int *loop_perform(t_int *w) { t_loopctl *ctl = (t_loopctl *)(w[1]); t_float *in1 = (t_float *)(w[2]); t_float *in2 = (t_float *)(w[3]); t_float *out1 = (t_float *)(w[4]); t_float *out2 = (t_float *)(w[5]); int n = (int)(w[6]); loopctl_run(ctl, in1, in2, out1, out2, n); return (w+7); }
static void loop_dsp(t_loop *x, t_signal **sp) { dsp_add(loop_perform, 6, &x->x_loopctl, sp[0]->s_vec, sp[1]->s_vec, sp[2]->s_vec, sp[3]->s_vec, sp[0]->s_n); }
static void loop_set(t_loop *x, t_floatarg val) { loopctl_set(&x->x_loopctl, val); }
static void loop_bang(t_loop *x) { loopctl_set(&x->x_loopctl, 0); }
void loop_tilde_setup(void) { loop_class = class_new(gensym("loop~"), (t_newmethod)loop_new, 0, sizeof(t_loop), 0, 0); class_addmethod(loop_class, (t_method)loop_dsp, gensym("dsp"), A_CANT, 0); CLASS_MAINSIGNALIN(loop_class, t_loop, x_f); class_addmethod(loop_class, (t_method)loop_set, gensym("set"), A_DEFFLOAT, 0); class_addbang(loop_class, loop_bang); }
#endif /* PD */