diff options
author | Ed Kelly <edkelly@users.sourceforge.net> | 2006-11-24 13:45:33 +0000 |
---|---|---|
committer | Ed Kelly <edkelly@users.sourceforge.net> | 2006-11-24 13:45:33 +0000 |
commit | 0c0b07d3bff68484d554b33d7693117863404d2a (patch) | |
tree | 141dec89b30d2153f610bf02a3827bfe0e381e2e /polymap | |
parent | eacf70f4603c669a003f502e84a7d28435368344 (diff) |
This commit was generated by cvs2svn to compensate for changes in r6421,
which included commits to RCS files with non-trunk default branches.
svn path=/trunk/externals/ekext/; revision=6422
Diffstat (limited to 'polymap')
-rwxr-xr-x | polymap/help-polymap.pd | 62 | ||||
-rwxr-xr-x | polymap/makefile | 105 | ||||
-rwxr-xr-x | polymap/polymap.c | 206 |
3 files changed, 373 insertions, 0 deletions
diff --git a/polymap/help-polymap.pd b/polymap/help-polymap.pd new file mode 100755 index 0000000..292f95e --- /dev/null +++ b/polymap/help-polymap.pd @@ -0,0 +1,62 @@ +#N canvas 0 0 690 434 10; +#X obj 502 26 sieve; +#X obj 545 26 maskxor; +#X obj 26 26 polymap; +#X obj 438 26 polystat; +#X text 82 26 two-dimensional polyphony-restricted map. see also; +#X text 23 47 Poly map contains a 32x32 matrix in which values may +be stored. However \, only a set number of these values may be stored +as set by the right inlet \, and if this total is reached no more may +be stored until one is set to 0 again.; +#X floatatom 338 258 5 1 16 1 max_poly - -; +#X obj 92 334 polymap 3; +#X msg 45 199 note 4 2 1; +#X msg 68 233 note 10 4 0.756; +#X msg 77 250 note 11 4 1; +#X msg 57 216 note 6 8 3; +#X floatatom 116 364 5 0 0 3 new_y - -; +#X msg 223 199 note 4 2 0; +#X msg 230 216 note 6 8 0; +#X msg 237 233 note 10 4 0; +#X msg 244 250 note 11 4 0; +#X floatatom 170 364 5 0 0 3 polyphony - -; +#X floatatom 61 364 5 0 0 3 freed_x - -; +#X obj 226 361 print overflow; +#X text 24 149 noteons; +#X msg 337 297 print; +#X msg 337 317 print32; +#X text 379 297 print first 16x16; +#X text 392 317 print whole matrix; +#X msg 337 277 clear; +#X msg 18 165 note 1 1 1; +#X msg 32 182 note 2 2 1; +#X text 377 277 clear matrix; +#X msg 337 235 note 1 0 1; +#X msg 209 165 note 1 1 0; +#X msg 216 182 note 2 2 0; +#X text 416 235 voice_x and voice_y both start at 1; +#X text 158 335 initialization argument sets maximum polyphony; +#X text 23 100 Values are stored as messages in the form [note x y +value( where value is either 0 or some other value.; +#X text 217 147 noteoffs; +#X connect 6 0 7 1; +#X connect 7 0 18 0; +#X connect 7 1 12 0; +#X connect 7 2 17 0; +#X connect 7 3 19 0; +#X connect 8 0 7 0; +#X connect 9 0 7 0; +#X connect 10 0 7 0; +#X connect 11 0 7 0; +#X connect 13 0 7 0; +#X connect 14 0 7 0; +#X connect 15 0 7 0; +#X connect 16 0 7 0; +#X connect 21 0 7 0; +#X connect 22 0 7 0; +#X connect 25 0 7 0; +#X connect 26 0 7 0; +#X connect 27 0 7 0; +#X connect 29 0 7 0; +#X connect 30 0 7 0; +#X connect 31 0 7 0; diff --git a/polymap/makefile b/polymap/makefile new file mode 100755 index 0000000..cfe340f --- /dev/null +++ b/polymap/makefile @@ -0,0 +1,105 @@ +current: + echo make pd_linux, pd_nt, pd_irix5, pd_irix6 or pd_darwin, then make install + +clean: ; rm -f *.pd_* *.o + +# ----------------------- NT ----------------------- + +pd_nt: polymap.dll + +INSTALL_PREFIX="C:\pd\extra" +EXT=dll +.SUFFIXES: .obj .dll + +PDNTCFLAGS = /W3 /WX /DNT /DPD /nologo +VC="D:\Program Files\Microsoft Visual Studio\Vc98" + +PDNTINCLUDE = /I. /I\tcl\include /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:$*_setup $*.obj $(PDNTLIB) + +# ----------------------- IRIX 5.x ----------------------- + +pd_irix5: polymap.pd_irix5 + +INSTALL_PREFIX=/usr/local +EXT=pd_irix5 +.SUFFIXES: .pd_irix5 + +SGICFLAGS5 = -o32 -DPD -DUNIX -DIRIX -O2 + +SGIINCLUDE = -I/usr/local/include + +.c.pd_irix5: + cc $(SGICFLAGS5) $(SGIINCLUDE) -o $*.o -c $*.c + ld -elf -shared -rdata_shared -o $*.pd_irix5 $*.o + rm $*.o + +# ----------------------- IRIX 5.x ----------------------- + +pd_irix6: polymap.pd_irix6 + +INSTALL_PREFIX=/usr/local +EXT=pd_irix6 +.SUFFIXES: .pd_irix6 + +SGICFLAGS5 = -o32 -DPD -DUNIX -DIRIX -O2 + +SGIINCLUDE = -I/usr/local/include + +.c.pd_irix6: + cc $(SGICFLAGS5) $(SGIINCLUDE) -o $*.o -c $*.c + ld -elf -shared -rdata_shared -o $*.pd_irix6 $*.o + rm $*.o + +# ----------------------- LINUX i386 ----------------------- + +pd_linux: polymap.pd_linux + +INSTALL_PREFIX=/usr/local +EXT=pd_linux +.SUFFIXES: .pd_linux + +LINUXCFLAGS = -DPD -O2 -funroll-loops -fomit-frame-pointer \ + -Wall -W -Wshadow -Wstrict-prototypes -Werror \ + -Wno-unused -Wno-parentheses -Wno-switch + +LINUXINCLUDE = -I/usr/local/include + +.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 $*.o + +# ----------------------- Mac OSX ----------------------- + +pd_darwin: polymap.pd_darwin + +INSTALL_PREFIX=/usr/local +EXT=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 + +# ---------------------------------------------- + +install:: + install -d $(INSTALL_PREFIX)/lib/pd/extra +# install -m 644 *.$(EXT) $(INSTALL_PREFIX)/lib/pd/externs + -install -m 644 polymap.$(EXT) $(INSTALL_PREFIX)/lib/pd/extra + install -m 644 *.pd $(INSTALL_PREFIX)/lib/pd/doc/5.reference diff --git a/polymap/polymap.c b/polymap/polymap.c new file mode 100755 index 0000000..02192b1 --- /dev/null +++ b/polymap/polymap.c @@ -0,0 +1,206 @@ +#include "m_pd.h" +#include <math.h> +#include <string.h> +#define MAXPOLY 32 +#define POLYMAP 512 + +/* The polymap is a two-dimensional array, but here instead of this we have a one dimensional array of length MAXPOLY^2 */ + +static t_class *polymap_class; + +typedef struct _map +{ + t_atom polybins[MAXPOLY]; + t_atom polymap[POLYMAP]; + t_atom note[3]; +} t_map; + +typedef struct _polymap +{ + t_object x_obj; + t_map x_map; + t_float maxpoly, polynow; + t_outlet *note, *new, *poly, *overflow; +} t_polymap; + + +/* perhaps polymap_note could be called from the sieve function, thus only setting up a matrix when a relevant sequencer is mentioned */ +void polymap_note(t_polymap *x, t_floatarg whosent, t_floatarg whoam, t_floatarg ono) +{ + int voicenow, mapindex, voicepoly, whosentme; + SETFLOAT(&x->x_map.note[0], whosent); + SETFLOAT(&x->x_map.note[1], whoam); + SETFLOAT(&x->x_map.note[2], ono); + whosentme = (int)whosent; + mapindex = (int)((whosent-1)+(whoam-1)*32); + if(ono==0) + { + voicenow = atom_getfloatarg(mapindex, POLYMAP, x->x_map.polymap); + if(voicenow>0&&mapindex>=0) + { + voicepoly = atom_getfloatarg(whosentme, MAXPOLY, x->x_map.polybins); + voicepoly--; + x->polynow--; + SETFLOAT(&x->x_map.polybins[whosentme], voicepoly); + SETFLOAT(&x->x_map.polymap[mapindex], 0); + outlet_float(x->poly, x->polynow); + if(x->polynow<x->maxpoly) + { + outlet_float(x->note, whosentme); + } + } + else outlet_list(x->overflow, &s_list, 3, x->x_map.note); + } + else + { + voicenow = atom_getfloatarg(mapindex, POLYMAP, x->x_map.polymap); + if(voicenow==0&&x->polynow<x->maxpoly&&mapindex>=0) + { + voicepoly = atom_getfloatarg(whosentme, MAXPOLY, x->x_map.polybins); + voicepoly++; + x->polynow++; + SETFLOAT(&x->x_map.polybins[whosentme], voicepoly); + SETFLOAT(&x->x_map.polymap[mapindex], 1); + outlet_float(x->poly, x->polynow); + outlet_float(x->new, whoam); + } + else if(voicenow==0) outlet_list(x->overflow, &s_list, 3, x->x_map.note); + } +} + +void polymap_print(t_polymap *x) +{ + int a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, indx; + post("polymap - first 16x16"); + post(" 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16"); + for(indx=0;indx<16;indx++) + { + a = atom_getfloatarg((indx*32), POLYMAP, x->x_map.polymap); + b = atom_getfloatarg((indx*32)+1, POLYMAP, x->x_map.polymap); + c = atom_getfloatarg((indx*32)+2, POLYMAP, x->x_map.polymap); + d = atom_getfloatarg((indx*32)+3, POLYMAP, x->x_map.polymap); + e = atom_getfloatarg((indx*32)+4, POLYMAP, x->x_map.polymap); + f = atom_getfloatarg((indx*32)+5, POLYMAP, x->x_map.polymap); + g = atom_getfloatarg((indx*32)+6, POLYMAP, x->x_map.polymap); + h = atom_getfloatarg((indx*32)+7, POLYMAP, x->x_map.polymap); + i = atom_getfloatarg((indx*32)+8, POLYMAP, x->x_map.polymap); + j = atom_getfloatarg((indx*32)+9, POLYMAP, x->x_map.polymap); + k = atom_getfloatarg((indx*32)+10, POLYMAP, x->x_map.polymap); + l = atom_getfloatarg((indx*32)+11, POLYMAP, x->x_map.polymap); + m = atom_getfloatarg((indx*32)+12, POLYMAP, x->x_map.polymap); + n = atom_getfloatarg((indx*32)+13, POLYMAP, x->x_map.polymap); + o = atom_getfloatarg((indx*32)+14, POLYMAP, x->x_map.polymap); + p = atom_getfloatarg((indx*32)+15, POLYMAP, x->x_map.polymap); + if(indx<9) + post("%d :%d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d", indx+1, a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p); + else if(indx>=9) + post("%d:%d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d", indx+1, a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p); + } +} + +void polymap_print32(t_polymap *x) +{ + int a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, aa, bb, cc, dd, ee, ff, gg, hh, ii, jj, kk, ll, mm, nn, oo, pp, indx; + post("polymap - all 32x32"); + post(" 2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32"); + post(" 1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 "); + for(indx=0;indx<32;indx++) + { + a = atom_getfloatarg((indx*32), POLYMAP, x->x_map.polymap); + b = atom_getfloatarg((indx*32)+1, POLYMAP, x->x_map.polymap); + c = atom_getfloatarg((indx*32)+2, POLYMAP, x->x_map.polymap); + d = atom_getfloatarg((indx*32)+3, POLYMAP, x->x_map.polymap); + e = atom_getfloatarg((indx*32)+4, POLYMAP, x->x_map.polymap); + f = atom_getfloatarg((indx*32)+5, POLYMAP, x->x_map.polymap); + g = atom_getfloatarg((indx*32)+6, POLYMAP, x->x_map.polymap); + h = atom_getfloatarg((indx*32)+7, POLYMAP, x->x_map.polymap); + i = atom_getfloatarg((indx*32)+8, POLYMAP, x->x_map.polymap); + j = atom_getfloatarg((indx*32)+9, POLYMAP, x->x_map.polymap); + k = atom_getfloatarg((indx*32)+10, POLYMAP, x->x_map.polymap); + l = atom_getfloatarg((indx*32)+11, POLYMAP, x->x_map.polymap); + m = atom_getfloatarg((indx*32)+12, POLYMAP, x->x_map.polymap); + n = atom_getfloatarg((indx*32)+13, POLYMAP, x->x_map.polymap); + o = atom_getfloatarg((indx*32)+14, POLYMAP, x->x_map.polymap); + p = atom_getfloatarg((indx*32)+15, POLYMAP, x->x_map.polymap); + aa = atom_getfloatarg((indx*32)+16, POLYMAP, x->x_map.polymap); + bb = atom_getfloatarg((indx*32)+17, POLYMAP, x->x_map.polymap); + cc = atom_getfloatarg((indx*32)+18, POLYMAP, x->x_map.polymap); + dd = atom_getfloatarg((indx*32)+19, POLYMAP, x->x_map.polymap); + ee = atom_getfloatarg((indx*32)+20, POLYMAP, x->x_map.polymap); + ff = atom_getfloatarg((indx*32)+21, POLYMAP, x->x_map.polymap); + gg = atom_getfloatarg((indx*32)+22, POLYMAP, x->x_map.polymap); + hh = atom_getfloatarg((indx*32)+23, POLYMAP, x->x_map.polymap); + ii = atom_getfloatarg((indx*32)+24, POLYMAP, x->x_map.polymap); + jj = atom_getfloatarg((indx*32)+25, POLYMAP, x->x_map.polymap); + kk = atom_getfloatarg((indx*32)+26, POLYMAP, x->x_map.polymap); + ll = atom_getfloatarg((indx*32)+27, POLYMAP, x->x_map.polymap); + mm = atom_getfloatarg((indx*32)+28, POLYMAP, x->x_map.polymap); + nn = atom_getfloatarg((indx*32)+29, POLYMAP, x->x_map.polymap); + oo = atom_getfloatarg((indx*32)+30, POLYMAP, x->x_map.polymap); + pp = atom_getfloatarg((indx*32)+31, POLYMAP, x->x_map.polymap); + if(indx<9) + post("%d :%d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d", indx+1, a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,aa,bb,cc,dd,ee,ff,gg,hh,ii,jj,kk,ll,mm,nn,oo,pp); + else if(indx>=9) + post("%d:%d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d", indx+1, a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,aa,bb,cc,dd,ee,ff,gg,hh,ii,jj,kk,ll,mm,nn,oo,pp); + } +} + +void polymap_clear(t_polymap *x) +{ + int i; + for(i=0;i<POLYMAP;i++) + { + SETFLOAT(&x->x_map.polymap[i], 0); + } + for(i=0;i<MAXPOLY;i++) + { + SETFLOAT(&x->x_map.polybins[i], 0); + } + for(i=0;i<2;i++) + { + SETFLOAT(&x->x_map.note[i], 0); + } + x->polynow=0; + outlet_float(x->poly, x->polynow); +} + +void *polymap_new(t_floatarg poly) +{ + t_polymap *x = (t_polymap *)pd_new(polymap_class); + int i; + for(i=0;i<POLYMAP;i++) + { + SETFLOAT(&x->x_map.polymap[i], 0); + } + for(i=0;i<MAXPOLY;i++) + { + SETFLOAT(&x->x_map.polybins[i], 0); + } + for(i=0;i<2;i++) + { + SETFLOAT(&x->x_map.note[i], 0); + } + x->maxpoly = poly > 0 ? poly : 1; + floatinlet_new(&x->x_obj, &x->maxpoly); + x->note = outlet_new(&x->x_obj, &s_float); + x->new = outlet_new(&x->x_obj, &s_float); + x->poly = outlet_new(&x->x_obj, &s_float); + x->overflow = outlet_new(&x->x_obj, &s_list); + return (void *)x; +} + +void polymap_setup(void) +{ + polymap_class = class_new(gensym("polymap"), + (t_newmethod)polymap_new, + 0, sizeof(t_polymap), + 0, A_DEFFLOAT, 0); + post("|. . . . . . . . .polymap. . . . . . . . .|"); + post("|_- polyphonic chain reaction regulator -_|"); + post("| . . . . . .Edward Kelly 2006. . . . . . |"); + class_sethelpsymbol(polymap_class, gensym("help-polymap")); + class_addmethod(polymap_class, (t_method)polymap_note, gensym("note"), A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT, 0); + class_addmethod(polymap_class, (t_method)polymap_clear, gensym("clear"), A_DEFFLOAT, 0); + class_addmethod(polymap_class, (t_method)polymap_print, gensym("print"), A_DEFFLOAT, 0); + class_addmethod(polymap_class, (t_method)polymap_print32, gensym("print32"), A_DEFFLOAT, 0); +} |