cxc-0.5.2/0000755000076500007650000000000012076107607010757 5ustar hanshanscxc-0.5.2/ascseq.c0000644000076500007650000000664412076107577012422 0ustar hanshans/* ascii-sequencer input lists, strings, anythings, output every characters ascii code jdl@xdv.org 2002 */ #include "m_pd.h" #include #include #include #define MAXMSGLEN 1024 #define LISTSEL "list" t_class *ascseq_class; typedef struct ascseq { t_object x_obj; t_clock *x_clock; double x_targettime; double x_prevtime; t_float x_grain; char x_bla[MAXMSGLEN]; int x_toklen; int x_tokcur; } t_ascseq; static void ascseq_tick(t_ascseq *x) { double timenow = clock_getsystime(); double msectogo = - clock_gettimesince(x->x_targettime); int chr; // post("ascseq: timenow: %f",timenow); if(x->x_tokcur >= x->x_toklen) { clock_unset(x->x_clock); x->x_tokcur = 0; return; } else { chr = x->x_bla[x->x_tokcur]; // post("tokcur: %c",chr); x->x_tokcur++; outlet_float(x->x_obj.ob_outlet, chr); clock_delay(x->x_clock,x->x_grain); } } void ascseq_anything(t_ascseq *x, t_symbol* s, t_int argc, t_atom* argv) { int i = argc; int chr, cnt, len; char tmp[MAXMSGLEN]; double timenow = clock_getlogicaltime(); chr = 0; cnt = 0; len = 0; x->x_bla[0] = '\0'; //symbol_string(s->s_name, tmp, 1024); if(!strstr(s->s_name,LISTSEL)) { strcat(x->x_bla,s->s_name); // post("tmp: %s",x->x_bla); } while (i--) { atom_string(argv, tmp, 1024); strcat(x->x_bla,tmp); // post("ascseq.c: argsize: %d",cnt); // post("ascseq.c: bla: %s",bla); argv++; } x->x_prevtime = timenow; x->x_targettime = clock_getsystimeafter(x->x_grain); x->x_toklen = strlen(x->x_bla); ascseq_tick(x); /* for(cnt=0;cntx_bla[cnt]; */ /* outlet_float(x->x_obj.ob_outlet, chr); */ /* } */ } void ascseq_symbol(t_ascseq *x, t_symbol *s) { t_atom* a = NULL; ascseq_anything(x, s, 0, a); } void ascseq_float(t_ascseq *x, t_floatarg f) { int chr, cnt, len; double timenow = clock_getlogicaltime(); chr = 0; cnt = 0; len = 0; x->x_bla[0] = '\0'; x->x_prevtime = timenow; x->x_targettime = clock_getsystimeafter(x->x_grain); sprintf(x->x_bla,"%f",f); x->x_toklen = strlen(x->x_bla); ascseq_tick(x); /* for(cnt=0;cntx_bla[cnt]; */ /* outlet_float(x->x_obj.ob_outlet, chr); */ /* // clock_delay(x->x_clock,1000.); */ /* } */ } static void ascseq_ft1(t_ascseq *x, t_floatarg g) { if (g < 0) g = 0; if (!g) g = 0; x->x_grain = g; } void ascseq_free(t_ascseq *x) { clock_free(x->x_clock); // post("ascseq_free"); } void *ascseq_new(t_floatarg f) { t_ascseq *x = (t_ascseq *)pd_new(ascseq_class); ascseq_ft1(x,f); x->x_clock = clock_new(x, (t_method)ascseq_tick); x->x_targettime = x->x_prevtime = clock_getlogicaltime(); inlet_new(&x->x_obj, &x->x_obj.ob_pd, gensym("float"), gensym("ft1")); outlet_new(&x->x_obj, &s_float); return (void *)x; } void ascseq_setup(void) { // post("ascseq_setup"); ascseq_class = class_new(gensym("ascseq"), (t_newmethod)ascseq_new, (t_method)ascseq_free, sizeof(t_ascseq), 0, A_DEFFLOAT, 0); class_addlist(ascseq_class, ascseq_anything); class_addanything(ascseq_class,ascseq_anything); class_addfloat(ascseq_class, ascseq_float); class_addmethod(ascseq_class, (t_method)ascseq_ft1, gensym("ft1"), A_FLOAT, 0); class_addsymbol(ascseq_class, ascseq_symbol); } cxc-0.5.2/mean~-help.pd0000644000076500007650000000632312076107577013362 0ustar hanshans#N canvas 0 31 690 382 10; #X obj 64 102 noise~; #X obj 463 105 mean~ blir; #X obj 21 262 table blir; #N canvas 162 270 331 246 fillary 0; #X obj 34 53 until; #X obj 34 79 count; #X msg 85 27 bang; #X obj 34 105 - 1; #X obj 34 130 t b f; #X obj 34 166 random_fl -1 1; #X obj 162 16 loadbang; #X obj 192 64 utime; #X obj 200 100 +; #X msg 200 124 seed \$1; #X obj 162 39 t b b b; #X obj 232 13 inlet; #X obj 120 65 t b b; #X msg 34 27 1000; #X msg 132 108 set \$1; #X obj 280 13 inlet; #X obj 178 165 random_icg -1 1; #X obj 34 192 tabwrite blor; #X connect 0 0 1 0; #X connect 1 0 3 0; #X connect 2 0 1 1; #X connect 3 0 4 0; #X connect 4 0 5 0; #X connect 4 1 17 1; #X connect 5 0 17 0; #X connect 6 0 10 0; #X connect 7 0 8 0; #X connect 7 1 8 1; #X connect 8 0 9 0; #X connect 9 0 5 0; #X connect 9 0 16 0; #X connect 10 0 12 0; #X connect 10 1 7 0; #X connect 11 0 12 0; #X connect 12 0 13 0; #X connect 12 1 2 0; #X connect 13 0 0 0; #X connect 14 0 13 0; #X connect 15 0 14 0; #X connect 16 0 17 0; #X restore 152 241 pd fillary; #X obj 21 175 tabwrite~ blir; #X msg 21 147 bang; #X obj 356 102 samplerate~; #X floatatom 356 126 5 0 0 0 - - -; #X obj 356 80 loadbang; #X floatatom 463 129 8 0 0 0 - - -; #X obj 64 150 +~ 0.1; #X floatatom 101 127 5 0 0 0 - - -; #X msg 152 218 bang; #X text 44 30 mean~ ; #X floatatom 160 160 5 0 0 0 - - -; #X obj 160 183 t f f; #X text 206 163 set arraysize; #X text 529 130 mean; #X text 43 10 this is supposed to calculate the signal mean of an array. ; #X msg 463 82 mean; #X msg 503 82 ad; #X msg 534 82 sd; #X obj 462 35 mean 1 2 3; #X floatatom 462 59 5 0 0 0 - - -; #X msg 462 13 1 2 3.6677; #X floatatom 271 305 8 0 0 0 - - -; #X msg 316 228 mean; #X msg 350 228 ad; #X obj 21 291 table blor; #X floatatom 341 325 10 0 0 0 - - -; #X floatatom 461 326 10 0 0 0 - - -; #X obj 392 150 loadbang; #X obj 316 272 t f f f; #X text 542 36 pd's mean; #X text 544 115 dont need this; #X msg 392 218 set \$1; #X obj 392 194 symbol; #X msg 392 173 blir; #X msg 429 173 blor; #X msg 20 214 \; blir resize \$1 \;; #X msg 113 270 \; blor resize \$1 \;; #X obj 460 304 cxstddev blir; #X obj 342 304 cxavgdev blir; #X obj 316 251 cxmean blir; #N canvas 739 383 494 344 META 0; #X text 12 125 HELP_PATCH_AUTHORS Jonathan Wilkes revised the patch to conform to the PDDP template for Pd version 0.42.; #X text 12 25 LICENSE GPL v2; #X text 12 105 AUTHOR jdl@xdv.org; #X text 12 85 OUTLET_0 float; #X text 12 45 DESCRIPTION normal distribution mean; #X text 12 65 INLET_0 signal mean ad sd; #X text 12 5 KEYWORDS signal array; #X restore 633 337 pd META; #X connect 0 0 10 0; #X connect 1 0 9 0; #X connect 5 0 4 0; #X connect 6 0 7 0; #X connect 8 0 6 0; #X connect 10 0 4 0; #X connect 11 0 10 1; #X connect 12 0 3 0; #X connect 14 0 15 0; #X connect 15 0 39 0; #X connect 15 0 40 0; #X connect 15 1 3 1; #X connect 19 0 1 0; #X connect 20 0 1 0; #X connect 21 0 1 0; #X connect 22 0 23 0; #X connect 24 0 22 0; #X connect 26 0 43 0; #X connect 27 0 43 0; #X connect 31 0 38 0; #X connect 32 0 25 0; #X connect 32 1 42 0; #X connect 32 2 41 0; #X connect 35 0 41 0; #X connect 35 0 42 0; #X connect 35 0 43 0; #X connect 36 0 35 0; #X connect 37 0 36 0; #X connect 38 0 36 0; #X connect 41 0 30 0; #X connect 42 0 29 0; #X connect 43 0 32 0; cxc-0.5.2/random_icg-help.pd0000644000076500007650000001530512076107577014346 0ustar hanshans#N canvas 0 31 966 505 10; #X msg 197 150 bang; #X floatatom 244 150 5 0 0 0 - - -; #X floatatom 197 218 10 0 0 0 - - -; #X floatatom 53 162 5 0 0 0 - - -; #X msg 54 111 bang; #X floatatom 289 152 5 0 0 0 - - -; #X obj 53 135 random 100; #X msg 427 151 bang; #X floatatom 474 151 5 0 0 0 - - -; #X floatatom 427 219 10 0 0 0 - - -; #X floatatom 519 153 5 0 0 0 - - -; #X obj 196 183 random1 0 1; #X obj 426 184 random_fl 0 1; #X msg 672 152 bang; #X floatatom 719 152 5 0 0 0 - - -; #X floatatom 672 220 10 0 0 0 - - -; #X floatatom 764 154 5 0 0 0 - - -; #X obj 671 185 random_icg 0 1; #X msg 197 276 bang; #X floatatom 244 276 5 0 0 0 - - -; #X floatatom 197 344 10 0 0 0 - - -; #X floatatom 289 278 5 0 0 0 - - -; #X text 193 251 random_icg lowerlimit \, upperlimit; #X msg 368 288 help; #X text 253 10 the random number generatorse; #X obj 539 406 dist_normal; #X msg 540 356 bang; #X obj 579 357 metro 100; #X obj 579 337 tgl 15 0 empty empty empty 20 8 0 8 -262144 -1 -1 0 1; #X obj 196 309 random_tw 0 1; #X floatatom 637 334 5 0 0 0 - - -; #N canvas 0 0 600 400 streamview 0; #N canvas 0 0 450 300 (subpatch) 0; #X array randstream 100 float 0; #X coords 0 2 99 -2 200 140 1; #X restore 92 222 graph; #X obj 146 144 tabwrite randstream; #X obj 200 63 count; #X obj 200 88 % 100; #X obj 156 28 t f b; #X obj 49 15 inlet; #X connect 2 0 3 0; #X connect 3 0 1 1; #X connect 4 0 1 0; #X connect 4 1 2 0; #X connect 5 0 4 0; #X restore 570 433 pd streamview; #N canvas 306 24 679 400 distview 0; #N canvas 0 0 450 300 (subpatch) 0; #X array randview1 100 float 0; #X coords 0 200 99 0 400 200 1; #X restore 248 31 graph; #X obj 28 26 inlet; #X obj 45 355 tabwrite randview1; #X obj 136 201 * 100; #X obj 136 225 int; #X obj 136 153 + 2; #X obj 45 280 tabread randview1; #X obj 136 176 / 4; #X obj 136 250 t f f; #X obj 45 304 t f b; #X obj 45 329 + 1; #X obj 136 129 t f; #X connect 1 0 11 0; #X connect 3 0 4 0; #X connect 4 0 8 0; #X connect 5 0 7 0; #X connect 6 0 9 0; #X connect 7 0 3 0; #X connect 8 0 6 0; #X connect 8 1 2 1; #X connect 9 0 10 0; #X connect 10 0 2 0; #X connect 11 0 5 0; #X restore 550 458 pd distview; #X obj 540 381 t b; #X floatatom 477 430 5 0 0 0 - - -; #N canvas 0 0 600 400 seedit 0; #X msg 284 154 seed \$1; #X obj 284 107 utime; #X msg 304 74 bang; #X obj 254 28 loadbang; #X obj 284 130 * 1e+06; #X obj 360 167 until; #X msg 455 156 bang; #X obj 359 194 random 2.14748e+08; #X msg 359 267 seed \$1; #X msg 385 294 seed \$1; #X msg 412 318 seed \$1; #X msg 439 267 seed \$1; #X msg 466 293 seed \$1; #X obj 254 50 t b b; #X obj 195 155 print seed1; #X obj 143 360 outlet; #X obj 204 361 outlet; #X obj 264 361 outlet; #X obj 317 361 outlet; #X obj 367 361 outlet; #X text 35 9 seed one random obj \, which generates the seeds for all the others.; #X obj 359 218 serialize 6; #X msg 360 140 6; #X obj 359 242 unpack f f f f f f; #X msg 485 317 seed \$1; #X obj 420 359 outlet; #X connect 0 0 7 0; #X connect 1 1 4 0; #X connect 2 0 1 0; #X connect 3 0 13 0; #X connect 4 0 0 0; #X connect 4 0 14 0; #X connect 5 0 7 0; #X connect 6 0 7 0; #X connect 7 0 21 0; #X connect 8 0 15 0; #X connect 9 0 16 0; #X connect 10 0 17 0; #X connect 11 0 18 0; #X connect 12 0 19 0; #X connect 13 0 22 0; #X connect 13 1 1 0; #X connect 21 0 23 0; #X connect 22 0 5 0; #X connect 23 0 8 0; #X connect 23 1 9 0; #X connect 23 2 10 0; #X connect 23 3 11 0; #X connect 23 4 12 0; #X connect 23 5 24 0; #X connect 24 0 25 0; #X restore 258 33 pd seedit; #X text 37 79 std pd random; #X text 197 124 linear congruential generator; #X text 197 77 creation arguments for the extra randoms are:; #X text 205 92 \, defaults to 0 respectively RAND_MAX; #X text 545 17 see also:; #X obj 545 40 utime; #X text 428 129 another lcg method ..; #X text 668 127 inverse linear congruential generator; #X text 536 249 normal distribution mean 0 and dist 1; #X text 536 264 right now it uses random1 for the actual rand values ; #X text 537 278 but later on it should take one of the randoms as creation argument \, so yu can specify which generator is being used.; #X text 198 106 they all output floats); #X text 540 311 also \, there is some burst at the upper and lower limits; #N canvas 622 668 592 356 signalversions 0; #X obj 68 131 random1~; #N canvas 0 0 450 300 (subpatch) 0; #X array \$0-randomix_test 64 float 1; #A 0 -0.599965 0.178987 -0.501604 -1.10592 0.426163 -0.481499 -0.553236 0.0961931 0.554738 -0.695487 0.541875 -0.415309 -0.419922 -0.871908 0.0688377 -1.03721 -0.136159 -0.207339 -1.18947 -0.25981 -0.628915 -0.826873 0.334755 -0.738558 -0.0926691 -0.262739 0.309148 0.50131 -1.40461 -0.859907 0.621724 -0.888718 0.692579 -1.11799 0.162897 0.116501 -0.390333 0.327364 -0.902445 -0.201419 0.300071 -1.10817 -1.09973 0.34181 -0.0511739 -0.613584 -0.306316 0.433381 -0.154481 -1.17821 -0.428187 -0.449014 -1.04248 -0.906665 0.0687456 -1.08289 0.59097 0.0438875 -1.20429 0.0862183 -0.995607 0.585034 0.205198 -0.337256; #X coords 0 1 63 -1 200 140 1; #X restore 351 23 graph; #X obj 382 183 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0 1; #X floatatom 440 184 5 0 0 0 - - -; #X obj 382 201 metro 100; #X msg 342 201 bang; #X obj 73 295 dac~; #X floatatom 140 220 5 0 0 0 - - -; #X msg 68 58 seed 30000; #X obj 142 131 random_fl~; #X text 120 98 etc ..; #X obj 229 131 random_icg~; #X obj 81 241 fader 75; #X obj 368 239 tabwrite~ \$0-randomix_test; #X connect 0 0 12 0; #X connect 2 0 4 0; #X connect 3 0 4 1; #X connect 4 0 13 0; #X connect 5 0 13 0; #X connect 7 0 12 2; #X connect 8 0 0 0; #X connect 9 0 12 1; #X connect 11 0 12 0; #X connect 11 0 13 0; #X connect 12 0 6 0; #X connect 12 1 6 1; #X restore 98 421 pd signalversions; #N canvas 394 360 494 344 META 0; #X text 12 165 HELP_PATCH_AUTHORS Jonathan Wilkes revised the patch to conform to the PDDP template for Pd version 0.42.; #X text 12 65 INLET_0 bang; #X text 12 25 LICENSE GPL v2; #X text 12 145 AUTHOR jdl@xdv.org; #X text 12 85 INLET_1 float; #X text 12 105 INLET_2 float; #X text 12 125 OUTLET_0 float; #X text 12 45 DESCRIPTION inverse linear congruential generator; #X text 12 5 KEYWORDS control random; #X restore 907 468 pd META; #X connect 0 0 11 0; #X connect 1 0 11 1; #X connect 4 0 6 0; #X connect 5 0 11 2; #X connect 6 0 3 0; #X connect 7 0 12 0; #X connect 8 0 12 1; #X connect 10 0 12 2; #X connect 11 0 2 0; #X connect 12 0 9 0; #X connect 13 0 17 0; #X connect 14 0 17 1; #X connect 16 0 17 2; #X connect 17 0 15 0; #X connect 18 0 29 0; #X connect 19 0 29 1; #X connect 21 0 29 2; #X connect 23 0 29 0; #X connect 25 0 31 0; #X connect 25 0 32 0; #X connect 25 0 34 0; #X connect 26 0 33 0; #X connect 27 0 33 0; #X connect 28 0 27 0; #X connect 29 0 20 0; #X connect 30 0 27 1; #X connect 33 0 25 0; #X connect 35 0 6 0; #X connect 35 1 11 0; #X connect 35 2 12 0; #X connect 35 3 17 0; #X connect 35 4 29 0; cxc-0.5.2/cxavgdev.c0000644000076500007650000000002312076107577012733 0ustar hanshans#include "mean~.c" cxc-0.5.2/x_connective_pd034.diff0000644000076500007650000000113312076107577015213 0ustar hanshans187a188,192 > static void send_set(t_send *x, t_symbol *s) > { > x->x_sym = s; > } > 235a241 > class_addmethod(send_class, (t_method)send_set, gensym("set"), A_SYMBOL, 0); 246a253,259 > static void receive_set(t_receive *x, t_symbol *s) > { > pd_unbind(&x->x_obj.ob_pd, x->x_sym); > x->x_sym = s; > pd_bind(&x->x_obj.ob_pd, s); > } > 294c307 < (t_method)receive_free, sizeof(t_receive), CLASS_NOINLET, A_DEFSYM, 0); --- > (t_method)receive_free, sizeof(t_receive), 0, A_DEFSYM, 0); 301a315 > class_addmethod(receive_class, (t_method)receive_set, gensym("set"), A_SYMBOL, 0); cxc-0.5.2/cxc_split.c0000644000076500007650000000743312076107577013130 0ustar hanshans#include #include #include #include #ifdef _MSC_VER #pragma warning( disable : 4244 ) #pragma warning( disable : 4305 ) #endif /* this is taken from ggee, where the file was hanging around but the object was not funtional. i keep it here for reference since i dont wnat to fix it over and over ;) but its not included in the makefile to avoid namespace clash with ggee.prepend anyhow, i ll just rename it cxc.prepend */ /* ------------------------ split ----------------------------- */ // why have to do this? void split_anything(); static t_class *split_class; typedef struct _split { t_object x_obj; t_symbol* x_splitter; } t_split; void split_symbol(t_split *x, t_symbol *s) { t_atom* a; split_anything(x, s, 0, a); } // move these to generic location later on int split_string_isnum(char* s) { // int isnum = 1; char tc; while((tc = *s++) != '\0') { // tc= s; switch(tc) { case 46: case 48: case 49: case 50: case 51: case 52: case 53: case 54: case 55: case 56: case 57: // post("yo numba: %c", tc); break; default: return 0; break; } } return 1; } void split_anything(t_split *x,t_symbol* s,t_int argc,t_atom* argv) { int i = argc; int j; t_symbol* cur; t_atom a_out[256]; int c_out = 0; t_atom* a = a_out; // char *str; char u[MAXPDSTRING]; char v[MAXPDSTRING]; // char *v; u[0] = '\0'; v[0] = '\0'; int isnum = 1; // float tf; for(j=0; js_name); j++) { u[0] = s->s_name[j]; if(u[0] == x->x_splitter->s_name[0]) { if(v[0] != '\0') { // delimiter is first character // check if string is digits only if(split_string_isnum(v)) { SETFLOAT(a, (float)atof(v)); } else { SETSYMBOL(a, gensym(v)); } a++; c_out++; // reset stuff v[0] = '\0'; isnum = 1; } // v[0] != '\0' } else { strncat(v, u, 1); } // char matches splitter } // have to do this again here, damn. if(split_string_isnum(v)) { SETFLOAT(a, (float)atof(v)); } else { SETSYMBOL(a, gensym(v)); } a++, c_out++; outlet_list(x->x_obj.ob_outlet, &s_list, c_out, (t_atom*)&a_out); // outlet_anything(x->x_obj.ob_outlet,gensym("list"),c_out,(t_atom*)&a_out); } void split_list(t_split *x,t_symbol* s,t_int argc,t_atom* argv) { int i = argc; t_symbol* cur; t_atom a_out[256]; int c_out = 0; t_atom* a = a_out; while (i--) { switch( argv->a_type) { case A_FLOAT: // post("flo: %f",atom_getfloat(argv)); SETFLOAT(a,atom_getfloat(argv)); a++; c_out++; break; case A_SYMBOL: // post("sym: %s",atom_getsymbol(argv)->s_name); SETSYMBOL(a,atom_getsymbol(argv)); a++; c_out++; break; default: post("split.c: unknown type"); } argv++; } outlet_anything(x->x_obj.ob_outlet,x->x_splitter,c_out,(t_atom*)&a_out); //post("done"); } static void *split_new(t_symbol* s) { t_split *x = (t_split *)pd_new(split_class); outlet_new(&x->x_obj, &s_float); if (s != &s_) x->x_splitter = s; else x->x_splitter = gensym("cxc_split"); return (x); } static void split_set(t_split *x, t_symbol *s) { t_symbol *t; // init temp splitter char u[1]; u[0] = '\0'; if(strlen(s->s_name) > 1) { // t = gensym((char*)s->s_name[0]); // post("%d", s->s_name[0]); strncat(u, s->s_name, 1); t = gensym(u); } else t = s; x->x_splitter = t; } void cxc_split_setup(void) { split_class = class_new(gensym("cxc_split"), (t_newmethod)split_new, 0, sizeof(t_split), 0,A_DEFSYM,NULL); // class_addlist(split_class, split_list); class_addanything(split_class,split_anything); class_addmethod(split_class, (t_method)split_set, gensym("set"), A_SYMBOL, 0); class_addsymbol(split_class, split_symbol); } cxc-0.5.2/ixprint-help.pd0000644000076500007650000000115212076107577013734 0ustar hanshans#N canvas 0 31 450 300 10; #X obj 123 115 ixprint; #X msg 122 59 1 2 3; #X obj 173 83 pointer; #X msg 172 54 traverse pd-ixprint-help.pd \, bang; #N canvas 397 200 494 287 META 0; #X text 12 105 HELP_PATCH_AUTHORS Jonathan Wilkes revised the patch to conform to the PDDP template for Pd version 0.42.; #X text 12 65 INLET_0 anything; #X text 12 5 KEYWORDS control deprecated; #X text 12 25 LICENSE GPL v2; #X text 12 45 DESCIPTION print with "print:"; #X text 12 85 AUTHOR jdl@xdv.org; #X restore 396 272 pd META; #X text 112 168 Deprecated: use [print -n]; #X connect 1 0 0 0; #X connect 2 0 0 0; #X connect 3 0 2 0; cxc-0.5.2/delta~-help.pd0000644000076500007650000000416712076107577013537 0ustar hanshans#N canvas 0 31 986 618 10; #X obj 139 177 delta~; #X obj 80 44 noise~; #X obj 83 268 print a; #X obj 143 267 print b; #X obj 329 312 dac~; #X obj 226 47 osc~ 400; #N canvas 0 0 450 300 (subpatch) 0; #X array orig 1000 float 0; #X coords 0 1 999 -1 200 140 1; #X restore 487 66 graph; #N canvas 0 0 450 300 (subpatch) 0; #X array diff 1000 float 0; #X coords 0 1 999 -1 500 360 1; #X restore 421 223 graph; #X obj 129 390 tabwrite~ diff; #X msg 220 340 bang; #X floatatom 225 24 5 0 0 0 - - -; #X obj 139 468 table test; #X msg 139 442 resize 2205; #X obj 242 389 tabwrite~ test; #X obj 243 415 tabwrite~ orig; #X obj 363 515 print; #X msg 320 441 bang; #X obj 316 530 t b; #X obj 302 552 spigot; #X obj 345 528 tgl 15 0 empty empty empty 20 8 0 8 -262144 -1 -1 0 1; #X obj 290 474 tabread~ test; #X obj 171 532 phasor~ 10; #X floatatom 171 510 5 0 0 0 - - -; #X obj 171 556 *~ 2205; #X obj 147 45 phasor~ 1; #X obj 160 93 nop~; #X obj 287 224 metro 100; #X obj 287 198 tgl 15 0 empty empty empty 20 8 0 8 -262144 -1 -1 0 1; #X floatatom 173 18 5 0 0 0 - - -; #X obj 109 77 *~ 0.1; #X floatatom 86 103 5 0 0 0 - - -; #X text 308 36 if this sample is larger than last \, value is positive \, else negative ...; #X text 308 18 delta~: difference between this and last sample; #N canvas 397 200 494 344 META 0; #X text 12 145 HELP_PATCH_AUTHORS Jonathan Wilkes revised the patch to conform to the PDDP template for Pd version 0.42.; #X text 12 5 KEYWORDS signal; #X text 12 105 LIBRARY external cxc; #X text 12 45 DESCRIPTION difference between this and last sample; #X text 12 65 INLET_0 signal; #X text 12 85 OUTLET_0 signal; #X text 12 25 LICENSE GPL v2; #X text 12 125 AUTHOR jdl@xdv.org; #X restore 935 557 pd META; #X connect 0 0 4 1; #X connect 0 0 8 0; #X connect 1 0 29 0; #X connect 9 0 8 0; #X connect 9 0 13 0; #X connect 9 0 14 0; #X connect 10 0 5 0; #X connect 17 0 18 0; #X connect 19 0 18 1; #X connect 21 0 23 0; #X connect 22 0 21 0; #X connect 23 0 20 0; #X connect 24 0 25 0; #X connect 25 0 0 0; #X connect 25 0 13 0; #X connect 25 0 14 0; #X connect 26 0 9 0; #X connect 27 0 26 0; #X connect 28 0 24 0; #X connect 29 0 25 0; #X connect 30 0 29 1; cxc-0.5.2/fader.pd0000644000076500007650000000120412076107577012370 0ustar hanshans#N canvas 264 258 450 300 10; #X obj 63 245 outlet~; #X obj 63 76 inlet~; #X obj 253 39 inlet; #X obj 63 216 *~; #X obj 327 22 loadbang; #X obj 327 44 float \$1; #X obj 253 85 / 100; #X obj 143 245 outlet~; #X obj 143 76 inlet~; #X obj 143 216 *~; #X obj 253 132 line~; #X msg 253 109 \$1 50; #X obj 253 153 *~; #X obj 253 173 *~; #X connect 1 0 3 0; #X connect 2 0 6 0; #X connect 3 0 0 0; #X connect 4 0 5 0; #X connect 5 0 6 0; #X connect 6 0 11 0; #X connect 8 0 9 0; #X connect 9 0 7 0; #X connect 10 0 12 0; #X connect 10 0 12 1; #X connect 11 0 10 0; #X connect 12 0 13 0; #X connect 12 0 13 1; #X connect 13 0 9 1; #X connect 13 0 3 1; cxc-0.5.2/ascseq-help.pd0000644000076500007650000000136712076107577013526 0ustar hanshans#N canvas 0 31 409 235 10; #X obj 131 168 print ascseq; #X msg 253 112 bang; #X obj 223 70 random_fl -10000 10000; #X obj 131 118 ascseq 100; #X floatatom 268 137 5 0 0 0 - - -; #X msg 83 34 "abcde 123 dsfjnsdf ewrte 3k4n5 3n hjb5465hj 6"; #N canvas 42 244 494 344 META 0; #X text 12 145 HELP_PATCH_AUTHORS Jonathan Wilkes revised the patch to conform to the PDDP template for Pd version 0.42.; #X text 12 45 DESCRIPTION; #X text 12 65 INLET_0 anything; #X text 12 105 OUTLET_0 float; #X text 12 85 INLET_1 float; #X text 12 25 LICENSE GPL v2; #X text 12 5 KEYWORDS control conversion symbol_op; #X text 12 125 AUTHOR jdl@xdv.org; #X restore 360 214 pd META; #X connect 1 0 2 0; #X connect 2 0 3 0; #X connect 3 0 0 0; #X connect 4 0 3 1; #X connect 5 0 3 0; cxc-0.5.2/random_fl~-help.pd0000644000076500007650000001517112076107577014404 0ustar hanshans#N canvas 0 31 966 505 10; #X msg 197 150 bang; #X floatatom 244 150 5 0 0 0 - - -; #X floatatom 197 218 10 0 0 0 - - -; #X floatatom 53 162 5 0 0 0 - - -; #X msg 54 111 bang; #X floatatom 289 152 5 0 0 0 - - -; #X obj 53 135 random 100; #X msg 427 151 bang; #X floatatom 474 151 5 0 0 0 - - -; #X floatatom 427 219 10 0 0 0 - - -; #X floatatom 519 153 5 0 0 0 - - -; #X obj 196 183 random1 0 1; #X obj 426 184 random_fl 0 1; #X msg 672 152 bang; #X floatatom 719 152 5 0 0 0 - - -; #X floatatom 672 220 10 0 0 0 - - -; #X floatatom 764 154 5 0 0 0 - - -; #X obj 671 185 random_icg 0 1; #X msg 197 276 bang; #X floatatom 244 276 5 0 0 0 - - -; #X floatatom 197 344 10 0 0 0 - - -; #X floatatom 289 278 5 0 0 0 - - -; #X text 193 251 random_icg lowerlimit \, upperlimit; #X msg 368 288 help; #X text 253 10 the random number generatorse; #X obj 539 406 dist_normal; #X msg 540 356 bang; #X obj 579 357 metro 100; #X obj 579 337 tgl 15 0 empty empty empty 20 8 0 8 -262144 -1 -1 0 1; #X obj 196 309 random_tw 0 1; #X floatatom 637 334 5 0 0 0 - - -; #N canvas 0 0 600 400 streamview 0; #N canvas 0 0 450 300 (subpatch) 0; #X array randstream 100 float 0; #X coords 0 2 99 -2 200 140 1; #X restore 92 222 graph; #X obj 146 144 tabwrite randstream; #X obj 200 63 count; #X obj 200 88 % 100; #X obj 156 28 t f b; #X obj 49 15 inlet; #X connect 2 0 3 0; #X connect 3 0 1 1; #X connect 4 0 1 0; #X connect 4 1 2 0; #X connect 5 0 4 0; #X restore 570 433 pd streamview; #N canvas 306 24 679 400 distview 0; #N canvas 0 0 450 300 (subpatch) 0; #X array randview1 100 float 0; #X coords 0 200 99 0 400 200 1; #X restore 248 31 graph; #X obj 28 26 inlet; #X obj 45 355 tabwrite randview1; #X obj 136 201 * 100; #X obj 136 225 int; #X obj 136 153 + 2; #X obj 45 280 tabread randview1; #X obj 136 176 / 4; #X obj 136 250 t f f; #X obj 45 304 t f b; #X obj 45 329 + 1; #X obj 136 129 t f; #X connect 1 0 11 0; #X connect 3 0 4 0; #X connect 4 0 8 0; #X connect 5 0 7 0; #X connect 6 0 9 0; #X connect 7 0 3 0; #X connect 8 0 6 0; #X connect 8 1 2 1; #X connect 9 0 10 0; #X connect 10 0 2 0; #X connect 11 0 5 0; #X restore 550 458 pd distview; #X obj 540 381 t b; #X floatatom 477 430 5 0 0 0 - - -; #N canvas 0 0 600 400 seedit 0; #X msg 284 154 seed \$1; #X obj 284 107 utime; #X msg 304 74 bang; #X obj 254 28 loadbang; #X obj 284 130 * 1e+06; #X obj 360 167 until; #X msg 455 156 bang; #X obj 359 194 random 2.14748e+08; #X msg 359 267 seed \$1; #X msg 385 294 seed \$1; #X msg 412 318 seed \$1; #X msg 439 267 seed \$1; #X msg 466 293 seed \$1; #X obj 254 50 t b b; #X obj 195 155 print seed1; #X obj 143 360 outlet; #X obj 204 361 outlet; #X obj 264 361 outlet; #X obj 317 361 outlet; #X obj 367 361 outlet; #X text 35 9 seed one random obj \, which generates the seeds for all the others.; #X obj 359 218 serialize 6; #X msg 360 140 6; #X obj 359 242 unpack f f f f f f; #X msg 485 317 seed \$1; #X obj 420 359 outlet; #X connect 0 0 7 0; #X connect 1 1 4 0; #X connect 2 0 1 0; #X connect 3 0 13 0; #X connect 4 0 0 0; #X connect 4 0 14 0; #X connect 5 0 7 0; #X connect 6 0 7 0; #X connect 7 0 21 0; #X connect 8 0 15 0; #X connect 9 0 16 0; #X connect 10 0 17 0; #X connect 11 0 18 0; #X connect 12 0 19 0; #X connect 13 0 22 0; #X connect 13 1 1 0; #X connect 21 0 23 0; #X connect 22 0 5 0; #X connect 23 0 8 0; #X connect 23 1 9 0; #X connect 23 2 10 0; #X connect 23 3 11 0; #X connect 23 4 12 0; #X connect 23 5 24 0; #X connect 24 0 25 0; #X restore 258 33 pd seedit; #X text 37 79 std pd random; #X text 197 124 linear congruential generator; #X text 197 77 creation arguments for the extra randoms are:; #X text 205 92 \, defaults to 0 respectively RAND_MAX; #X text 545 17 see also:; #X obj 545 40 utime; #X text 428 129 another lcg method ..; #X text 668 127 inverse linear congruential generator; #X text 536 249 normal distribution mean 0 and dist 1; #X text 536 264 right now it uses random1 for the actual rand values ; #X text 537 278 but later on it should take one of the randoms as creation argument \, so yu can specify which generator is being used.; #X text 198 106 they all output floats); #X text 540 311 also \, there is some burst at the upper and lower limits; #N canvas 242 366 592 356 signalversions 0; #X obj 68 131 random1~; #N canvas 0 0 450 300 (subpatch) 0; #X array \$0-randomix_test 64 float 1; #A 0 -0.599965 0.178987 -0.501604 -1.10592 0.426163 -0.481499 -0.553236 0.0961931 0.554738 -0.695487 0.541875 -0.415309 -0.419922 -0.871908 0.0688377 -1.03721 -0.136159 -0.207339 -1.18947 -0.25981 -0.628915 -0.826873 0.334755 -0.738558 -0.0926691 -0.262739 0.309148 0.50131 -1.40461 -0.859907 0.621724 -0.888718 0.692579 -1.11799 0.162897 0.116501 -0.390333 0.327364 -0.902445 -0.201419 0.300071 -1.10817 -1.09973 0.34181 -0.0511739 -0.613584 -0.306316 0.433381 -0.154481 -1.17821 -0.428187 -0.449014 -1.04248 -0.906665 0.0687456 -1.08289 0.59097 0.0438875 -1.20429 0.0862183 -0.995607 0.585034 0.205198 -0.337256; #X coords 0 1 63 -1 200 140 1; #X restore 351 23 graph; #X obj 382 183 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0 1; #X floatatom 440 184 5 0 0 0 - - -; #X obj 382 201 metro 100; #X msg 342 201 bang; #X obj 73 295 dac~; #X floatatom 140 220 5 0 0 0 - - -; #X msg 68 58 seed 30000; #X obj 142 131 random_fl~; #X text 120 98 etc ..; #X obj 229 131 random_icg~; #X obj 81 241 fader 75; #X obj 369 238 tabwrite~ \$0-randomix_test; #X connect 0 0 12 0; #X connect 2 0 4 0; #X connect 3 0 4 1; #X connect 4 0 13 0; #X connect 5 0 13 0; #X connect 7 0 12 2; #X connect 8 0 0 0; #X connect 9 0 12 1; #X connect 11 0 12 0; #X connect 11 0 13 0; #X connect 12 0 6 0; #X connect 12 1 6 1; #X restore 98 421 pd signalversions; #N canvas 560 294 494 344 META 0; #X text 12 125 HELP_PATCH_AUTHORS Jonathan Wilkes revised the patch to conform to the PDDP template for Pd version 0.42.; #X text 12 25 LICENSE GPL v2; #X text 12 105 AUTHOR jdl@xdv.org; #X text 12 45 DESCRIPTION another lcg method ..; #X text 12 65 INLET_0 seed; #X text 12 85 OUTLET_0 signal; #X text 12 5 KEYWORDS signal random; #X restore 867 464 pd META; #X connect 0 0 11 0; #X connect 1 0 11 1; #X connect 4 0 6 0; #X connect 5 0 11 2; #X connect 6 0 3 0; #X connect 7 0 12 0; #X connect 8 0 12 1; #X connect 10 0 12 2; #X connect 11 0 2 0; #X connect 12 0 9 0; #X connect 13 0 17 0; #X connect 14 0 17 1; #X connect 16 0 17 2; #X connect 17 0 15 0; #X connect 18 0 29 0; #X connect 19 0 29 1; #X connect 21 0 29 2; #X connect 23 0 29 0; #X connect 25 0 31 0; #X connect 25 0 32 0; #X connect 25 0 34 0; #X connect 26 0 33 0; #X connect 27 0 33 0; #X connect 28 0 27 0; #X connect 29 0 20 0; #X connect 30 0 27 1; #X connect 33 0 25 0; #X connect 35 0 6 0; #X connect 35 1 11 0; #X connect 35 2 12 0; #X connect 35 3 17 0; #X connect 35 4 29 0; cxc-0.5.2/cxc.c0000644000076500007650000000433512076107577011713 0ustar hanshans #ifndef VERSION #define VERSION "0.05" #endif #ifndef __DATE__ #define __DATE__ "without using a gnu compiler" #endif #include #include "cxc.h" typedef struct _cxc { t_object x_obj; } t_cxc; static t_class* cxc_class; //void binshift_setup(); void ascwave_setup(); void ascseq_setup(); void ixprint_setup(); //void mixer_setup(); //void makesymbol_setup(); void bfilt_setup(); void bfilt2_setup(); /* void sendOSC_setup(); */ /* void dumpOSC_setup(); */ /* void routeOSC_setup(); */ //void testy_tilde_setup(); //void garlic_tilde_setup(); void cxc_counter_setup(); void reson_tilde_setup(); //void serialize_setup(); void cxc_prepend_setup(); void cxc_split_setup(); void utime_setup(); // RNG's void random1_setup(); void random1_tilde_setup(); // signal version void random_fl_setup(); void random_fl_tilde_setup(); void random_icg_setup(); void random_icg_tilde_setup(); void random_tw_setup(); void dist_normal_setup(); void ENV_setup(); void proc_setup(); void cxmean_setup(); void cxavgdev_setup(); void cxstddev_setup(); void mean_tilde_setup(); void delta_tilde_setup(); static void* cxc_new(t_symbol* s) { t_cxc *x = (t_cxc *)pd_new(cxc_class); return (x); } void cxc_setup(void) { cxc_class = class_new(gensym("cxc"), (t_newmethod)cxc_new, 0, sizeof(t_cxc), 0,0); ixprint_setup(); // binshift_setup(); ascwave_setup(); ascseq_setup(); // mixer_setup(); // makesymbol_setup(); bfilt_setup(); bfilt2_setup(); /* sendOSC_setup(); */ /* dumpOSC_setup(); */ /* routeOSC_setup(); */ cxc_counter_setup(); reson_tilde_setup(); //serialize_setup(); cxc_prepend_setup(); cxc_split_setup(); utime_setup(); // RNG's random1_setup(); random1_tilde_setup(); random_fl_setup(); random_fl_tilde_setup(); random_icg_setup(); random_icg_tilde_setup(); random_tw_setup(); dist_normal_setup(); ENV_setup(); proc_setup(); cxmean_setup(); cxavgdev_setup(); cxstddev_setup(); mean_tilde_setup(); delta_tilde_setup(); post("c : jdl@xdv.org ========================================"); post(" x : ver: "VERSION" ============================================"); post(" c: compiled: "__DATE__" =================================="); // post("\\"); // L; } cxc-0.5.2/x_connective_pd035.diff0000644000076500007650000000065012076107577015217 0ustar hanshans246a247,253 > static void receive_set(t_receive *x, t_symbol *s) > { > pd_unbind(&x->x_obj.ob_pd, x->x_sym); > x->x_sym = s; > pd_bind(&x->x_obj.ob_pd, s); > } > 294c301 < (t_method)receive_free, sizeof(t_receive), CLASS_NOINLET, A_DEFSYM, 0); --- > (t_method)receive_free, sizeof(t_receive), 0, A_DEFSYM, 0); 301a309 > class_addmethod(receive_class, (t_method)receive_set, gensym("set"), A_SYMBOL, 0); cxc-0.5.2/dist_normal.c0000644000076500007650000001071012076107577013443 0ustar hanshans/* (c) 2002:cxc@web.fm randomix: various PRNG's code taken from: http://remus.rutgers.edu/%7Erhoads/Code/code.html let's check it out */ #include #include #include #define SMALLEST_RANGE .0001 #ifndef RAND_MAX #define RAND_MAX 2147483647 #endif static int makeseed(void) { static unsigned int random1_nextseed = 1489853723; random1_nextseed = random1_nextseed * 435898247 + 938284287; return (random1_nextseed & 0x7fffffff); } static int rand_random_fl(seed) { int q; double state; /* The following parameters are recommended settings based on research uncomment the one you want. */ double a = 1389796, m = RAND_MAX; /* static double a = 950975, m = 2147483647; */ /* static double a = 3467255, m = 21474836472; */ /* static double a = 657618, m = 4294967291; */ /* static double a = 93167, m = 4294967291; */ /* static double a = 1345659, m = 4294967291; */ state = seed; state *= a; q = state / m; state -= q*m; return state; } /* -------------------------- dist_normal ------------------------------ */ /* Generate a normal random variable with mean 0 and standard deviation of 1. To adjust to some other distribution, multiply by the standard deviation and add the mean. Box-Muller method note: rand() is a function that returns a uniformly distributed random number from 0 to RAND_MAX */ static t_class *dist_normal_class; typedef struct _dist_normal { t_object x_obj; t_float x_mn; // mean t_float x_dv; // deviation t_float x_u1; t_float x_u2; t_float x_f; // lower limit t_float x_g; // upper limit unsigned int x_state; // current seed } t_dist_normal; static void *dist_normal_new(t_floatarg mn, t_floatarg dv) { t_dist_normal *x = (t_dist_normal *)pd_new(dist_normal_class); x->x_mn = (mn) ? mn : 0; x->x_dv = (dv) ? dv : 1; x->x_u1 = 13; x->x_u2 = 1000; x->x_f = 0; x->x_g = RAND_MAX; //post("cxc/randomix.c: lolim: %f - %f, uplim: %f - %f", x->x_f, f, x->x_g, g); x->x_state = makeseed(); inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_float, gensym("fl1")); // inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_float, gensym("fl2")); //outlet_new(&x->x_obj, &s_float); outlet_new(&x->x_obj, 0); return (x); } static double dist_normal_rand(t_dist_normal *x) { int n = x->x_f; double nval; double m; m = (double)RAND_MAX * 2; // post("cxc/randomix.c: x_state: %d",x->x_state); x->x_state = rand_random_fl(x->x_state); //nval = ((double)x->x_state / m) * (double)(x->x_g - x->x_f) + (double)x->x_f; nval = (double)x->x_state; return (nval); } static void dist_normal_doit(t_dist_normal *x) { static double V2, fac; static int phase = 0; double S, Z, U1, U2, V1; if (phase) Z = V2 * fac; else { do { /* U1 = (double)rand() / RAND_MAX; */ /* U2 = (double)rand() / RAND_MAX; */ U1 = (double)dist_normal_rand(x) / RAND_MAX; U2 = (double)dist_normal_rand(x) / RAND_MAX; // post("cxc/randomix.c: test %f %f %f %f", x->x_u1, x->x_u2, U1, U2); V1 = 2 * U1 - 1; V2 = 2 * U2 - 1; S = V1 * V1 + V2 * V2; } while(S >= 1); fac = sqrt (-2 * log(S) / S); Z = V1 * fac; } phase = 1 - phase; //return Z; outlet_float(x->x_obj.ob_outlet, Z); } static void dist_normal_bang(t_dist_normal *x) { /* post("cxc/randomix.c: dist_normal banged"); */ /* post("cxc/randomix.c: RAND_MAX: %d",RAND_MAX); */ /* post("cxc/randomix.c: test: %f %f", x->x_u1, x->x_u2); */ dist_normal_doit(x); } void dist_normal_low(t_dist_normal *x, t_floatarg mn) { x->x_mn = mn; } void dist_normal_upp(t_dist_normal *x, t_floatarg dv) { x->x_dv = dv; } void dist_normal_float(t_dist_normal *x, t_floatarg r) { outlet_float(x->x_obj.ob_outlet, r); } void dist_normal_list(t_dist_normal *x, t_symbol *s, int argc, t_atom *argv) { outlet_list(x->x_obj.ob_outlet, s, argc, argv); } void dist_normal_setup(void) { dist_normal_class = class_new(gensym("dist_normal"), (t_newmethod)dist_normal_new, 0, sizeof(t_dist_normal), 0, A_DEFFLOAT, A_DEFFLOAT, 0); class_addbang(dist_normal_class, dist_normal_bang); class_addmethod(dist_normal_class, (t_method)dist_normal_low, gensym("fl1"), A_FLOAT, 0); // class_addmethod(dist_normal_class, (t_method)dist_normal_upp, gensym("fl2"), A_FLOAT, 0); class_addlist (dist_normal_class, dist_normal_list); /* class_addmethod(dist_normal_class, (t_method)dist_normal_seed, */ /* gensym("seed"), A_FLOAT, 0); */ } cxc-0.5.2/bfilt-help.pd0000644000076500007650000000223312076107577013340 0ustar hanshans#N canvas 0 31 404 226 10; #X floatatom 85 119 0 0 0 0 - - -; #X obj 57 175 print; #X floatatom 45 120 0 0 0 0 - - -; #X obj 58 146 bfilt 5; #X text 43 16 bfilt (at the moment) is: modulo something + select 0 ; #X floatatom 167 120 0 0 0 0 - - -; #X obj 139 176 print; #X floatatom 127 121 0 0 0 0 - - -; #X obj 140 147 bfilt2 5; #X obj 145 87 metro 100; #X msg 145 68 1; #X text 42 29 bfilt2: real bangfilter: bangs on first inlet \, internal counter \, only outputs every arg2th bang ...; #X msg 169 67 0; #N canvas 176 129 494 344 META 0; #X text 12 165 HELP_PATCH_AUTHORS Jonathan Wilkes revised the patch to conform to the PDDP template for Pd version 0.42.; #X text 12 45 DESCRIPTION bang on first inlet \, internal counter \, only outputs ever arg2th bang; #X text 12 5 KEYWORDS control filter bang_op; #X text 12 85 INLET_0 bang float; #X text 12 105 INLET_1 float; #X text 12 25 LICENSE GPL v2; #X text 12 145 AUTHOR jdl@xdv.org; #X text 12 125 OUTLET_0 bang; #X restore 352 205 pd META; #X connect 0 0 3 1; #X connect 2 0 3 0; #X connect 3 0 1 0; #X connect 5 0 8 1; #X connect 7 0 8 0; #X connect 8 0 6 0; #X connect 9 0 8 0; #X connect 10 0 9 0; #X connect 12 0 9 0; cxc-0.5.2/ENV-help.pd0000644000076500007650000000227212076107577012673 0ustar hanshans#N canvas 0 31 625 314 10; #X obj 147 203 ENV; #X msg 147 163 RAND_MAX; #X floatatom 226 253 10 0 0 0 - - -; #X obj 147 277 print; #X msg 214 164 getenv \$1; #X symbolatom 215 130 10 0 0 0 - - -; #X obj 295 130 symbol; #X msg 311 105 HOSTNAME; #X msg 310 80 USERNAME; #X obj 147 228 route symbol; #X msg 147 253 \$1; #X msg 424 110 USERNAME bla; #X obj 395 202 print pre; #X msg 425 135 HOSTNAME testi; #X msg 312 45 RANDOM; #X text 18 7 get and set environment variables etc ...; #X msg 244 51 DATE; #N canvas 299 125 494 344 META 0; #X text 12 145 HELP_PATCH_AUTHORS Jonathan Wilkes revised the patch to conform to the PDDP template for Pd version 0.42.; #X text 12 65 DESCRIPTION get and set environment variables; #X text 12 85 INLET_0 RAND_MAX getenv; #X text 12 105 OUTLET_0 float symbol; #X text 12 45 LICENSE GPL v2; #X text 12 125 AUTHOR jdl@xdv.org; #X text 12 15 KEYWORDS control filesystem; #X restore 575 293 pd META; #X obj 386 168 cxc_prepend setenv; #X connect 0 0 9 0; #X connect 1 0 0 0; #X connect 4 0 0 0; #X connect 5 0 4 0; #X connect 6 0 4 0; #X connect 7 0 6 0; #X connect 8 0 6 0; #X connect 9 0 10 0; #X connect 9 1 2 0; #X connect 10 0 3 0; #X connect 14 0 6 0; #X connect 16 0 6 0; cxc-0.5.2/random_icg~.c0000644000076500007650000001070212076107577013431 0ustar hanshans/* (c) 2002:cxc@web.fm randomix: various PRNG's code taken from: http://remus.rutgers.edu/%7Erhoads/Code/code.html let's check it out */ #include #include #include #define SMALLEST_RANGE .0001 #ifndef RAND_MAX #define RAND_MAX 2147483647 #endif static int makeseed(void); static int rand_random_icg(int, int); static unsigned int rand_random_icg_INVERSE_seed(int, int); static int makeseed(void) { static unsigned int random1_nextseed = 1489853723; random1_nextseed = random1_nextseed * 435898247 + 938284287; return (random1_nextseed & 0x7fffffff); } static int rand_random_icg(seed, p) { static int a, b, q, r; int state; unsigned int inv; a = 22211, b = 11926380,q = 96685, r = 12518; /* static int p = 2147483053, a = 858993221, b = 1,q = 2, r = 429496611;*/ /* static int p = 2147483053, a = 579, b = 24456079, q = 3708951, r = 424;*/ /* static int p = 2147483053, a = 11972, b = 62187060,q = 179375, r = 5553;*/ /* static int p = 2147483053, a = 21714, b = 94901263,q = 98898, r = 11881;*/ /* static int p = 2147483053, a = 4594, b = 44183289,q = 467453, r = 3971;*/ /* static int p = 2147483647, a = 1288490188, b = 1, q = 1, r = 858993459;*/ /* static int p = 2147483647, a = 9102, b = 36884165, q = 235935, r =3277;*/ /* static int p = 2147483647, a = 14288, b = 758634, q = 150299, r = 11535;*/ /* static int p = 2147483647, a = 21916, b = 71499791, q = 97987, r = 555;*/ /* static int p = 2147483647, a = 28933, b = 59217914, q = 74222, r = 18521;*/ /* static int p = 2147483647, a = 31152, b = 48897674, q = 68935, r = 20527;*/ // state = seed; inv = rand_random_icg_INVERSE_seed(seed, p); state = a*(inv % q) - r*(inv / q) + b; if (state < 0) state += p; else if (state >= state) state -= p; return state; } /* Modular Inversion using the extended Euclidean alg. for GCD */ /***************************************************************/ static unsigned rand_random_icg_INVERSE_seed (int state, int p) { unsigned int q,d; signed int u,v,inv,t; if (state <= 1) return(state); d = p; inv = 0; v = 1; u = state; do { q = d / u; t = d % u; d = u; u = t; t = inv - q*v; inv = v; v = t; } while (u != 0); if (inv < 0 ) inv += p; /* if (1 != d) */ /* post ("inverse_iter: Can't invert !"); */ return(inv); } /* -------------------------- random_icg ------------------------------ */ /* inverse congruential generator. */ static t_class *random_icg_tilde_class; typedef struct _random_icg_tilde { t_object x_obj; t_float x_f; // lower limit t_float x_g; // upper limit t_float x_p; // 1st shared parameter of iter function .. unsigned int x_state; // current seed } t_random_icg_tilde; static void *random_icg_tilde_new() { t_random_icg_tilde *x = (t_random_icg_tilde *)pd_new(random_icg_tilde_class); /* x->x_f = (f) ? f : 0; */ /* x->x_g = (g) ? g : RAND_MAX; */ x->x_p = 2147483053; //post("cxc/randomix.c: lolim: %f - %f, uplim: %f - %f", x->x_f, f, x->x_g, g); x->x_state = makeseed(); outlet_new(&x->x_obj, gensym("signal")); return (x); } static void random_icg_tilde_bang(t_random_icg_tilde *x) { double nval; x->x_state = rand_random_icg(x->x_state, x->x_p); nval = (((x->x_state / x->x_p) - 1) * (double)(x->x_g - x->x_f) + (double)x->x_f); // hakc, why is it out of range? if(nval < (double)x->x_f) { random_icg_tilde_bang(x); } else { outlet_float(x->x_obj.ob_outlet, nval); } } static void random_icg_tilde_seed(t_random_icg_tilde *x, float f, float glob) { x->x_state = f; } static t_int *random_icg_tilde_perform(t_int *w) { t_random_icg_tilde *x = (t_random_icg_tilde *)(w[1]); t_float *out = (t_float *)(w[2]); int n = (int)(w[3]); while (n--) { // generate new noise sample x->x_state = rand_random_icg(x->x_state, x->x_p); *out++ = (t_float)(x->x_state / x->x_p - 1) * 2 - 1; } return (w+4); } static void random_icg_tilde_dsp(t_random_icg_tilde *x, t_signal **sp) { dsp_add(random_icg_tilde_perform, 3, x, sp[0]->s_vec, sp[0]->s_n); } void random_icg_tilde_setup(void) { random_icg_tilde_class = class_new(gensym("random_icg~"), (t_newmethod)random_icg_tilde_new, 0, sizeof(t_random_icg_tilde), 0, A_DEFFLOAT, A_DEFFLOAT, 0); class_addmethod(random_icg_tilde_class, (t_method)random_icg_tilde_seed, gensym("seed"), A_FLOAT, 0); class_addmethod(random_icg_tilde_class, (t_method)random_icg_tilde_dsp, gensym("dsp"), 0); } cxc-0.5.2/reson~.c0000644000076500007650000001022112076107577012451 0ustar hanshans/* * Copyright (c) 1997-1999 Mark Danks. * For information on usage and redistribution, and for a DISCLAIMER OF ALL * WARRANTIES, see the file, "GEM.LICENSE.TERMS" in this distribution. */ /* Original code by Miller Puckette */ /* a non-interpolating reson filter, not very carefully coded... */ /* 11/29/94 modified to do interpolation - M. Danks */ #include "m_pd.h" #include #define BUFSIZE 4096 typedef struct resonctl { float c_freq; float c_samprate; float c_feedback; int c_delayinsamps; float c_fraction; int c_phase; float *c_buf; } t_resonctl; typedef struct sigreson { t_object x_obj; /* header */ t_resonctl *x_ctl; /* pointer to state */ t_resonctl x_cspace; /* garage for state when not in a chain */ } t_sigreson; /* the DSP routine -- called for every n samples of input */ static t_int *cu_reson(t_int *w) { t_float *in1 = (t_float *)(w[1]); t_float *in2 = (t_float *)(w[2]); t_float *out = (t_float *)(w[3]); t_resonctl *x = (t_resonctl *)(w[4]); int n = (int)(w[5]); long i; int writephase = x->c_phase; for (i = 0; i < n; i++) { /* note two tricks: 1. input is read before output * is written, because the routine might be called * in-place; * 2 - a seed of 1E-20 is thrown in to avoid floating * underflow which slows the calculation down. */ int readphase, phase, delayinsamps; float fraction, f, g, freq, freqtemp; float ftemp; freq = *in2++; freqtemp = (freq < 1 ? 1 : freq); ftemp = x->c_samprate/freqtemp; if (ftemp >= BUFSIZE-1) ftemp = BUFSIZE - 1.f; else if (ftemp < 1.0) ftemp = 1.f; delayinsamps = (int)ftemp; fraction = ftemp - delayinsamps; readphase = writephase - delayinsamps; phase = readphase & (BUFSIZE-1); f = x->c_buf[phase] + fraction * (x->c_buf[(phase-1)& (BUFSIZE-1)] - x->c_buf[phase]); g = *in1++; *out++ = x->c_buf[(writephase++) & (BUFSIZE-1)] = g + x->c_feedback * f + 1E-20f; } x->c_phase = writephase & (BUFSIZE-1); return (w+6); } /* sets the reson frequency */ void sigreson_float(t_sigreson *x, t_floatarg f) { float ftemp; x->x_ctl->c_freq = (f < 1 ? 1 : f); ftemp = x->x_ctl->c_samprate/x->x_ctl->c_freq; if (ftemp >= BUFSIZE - 1) ftemp = BUFSIZE - 1.f; else if (ftemp < 1.0) ftemp = 1.f; x->x_ctl->c_delayinsamps = (int)ftemp; x->x_ctl->c_fraction = ftemp - x->x_ctl->c_delayinsamps; } /* routine which FTS calls to put you on the DSP chain or take you off. */ static void sigreson_dsp(t_sigreson *x, t_signal **sp) { x->x_ctl->c_samprate = sp[0]->s_sr; sigreson_float(x, x->x_ctl->c_freq); dsp_add(cu_reson, 5, sp[0]->s_vec, sp[1]->s_vec, sp[2]->s_vec, x->x_ctl, sp[0]->s_n); } static void sigreson_ft1(t_sigreson *x, t_floatarg f) /* sets feedback */ { if (f > .99999) f = .99999f; else if (f < -.99999) f = -.99999f; x->x_ctl->c_feedback = (float)f; } static void sigreson_ff(t_sigreson *x) /* cleanup on free */ { free(x->x_ctl->c_buf); } static t_class *sigreson_class; void *sigreson_new(t_floatarg f, t_floatarg g) { t_sigreson *x = (t_sigreson *)pd_new(sigreson_class); outlet_new(&x->x_obj, &s_signal); /* things in "cspace" are things you'll actually use at DSP time */ x->x_cspace.c_phase = 0; if (!(x->x_cspace.c_buf = (float *)malloc(BUFSIZE * sizeof(float)))) { error("buffer alloc failed"); return (0); } x->x_cspace.c_samprate = 44100.f; /* just a plausible default */ /* control block is in the garage at startup */ x->x_ctl = &x->x_cspace; sigreson_float(x, (t_float)f); /* setup params */ sigreson_ft1(x, g); /* make a "float" inlet */ inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_signal, &s_signal); inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_float, gensym("ft1")); return (x); } void reson_tilde_setup() { sigreson_class = class_new(gensym("reson~"), (t_newmethod)sigreson_new, (t_method)sigreson_ff, sizeof(t_sigreson), 0, A_DEFFLOAT, A_DEFFLOAT, 0); class_addfloat(sigreson_class, (t_method)sigreson_float); class_addmethod(sigreson_class, (t_method)sigreson_ft1, gensym("ft1"), A_FLOAT, 0); class_addmethod(sigreson_class, (t_method)nullfn, &s_signal, A_NULL); class_addmethod(sigreson_class, (t_method)sigreson_dsp, gensym("dsp"), A_NULL); } cxc-0.5.2/random_tw.c0000644000076500007650000001124312076107577013124 0ustar hanshans/* (c) 2002:cxc@web.fm randomix: various PRNG's code taken from: http://remus.rutgers.edu/%7Erhoads/Code/code.html let's check it out */ #include #include #include #define SMALLEST_RANGE .0001 #ifndef RAND_MAX #define RAND_MAX 2147483647 #endif static int makeseed(void) { static unsigned int random1_nextseed = 1489853723; random1_nextseed = random1_nextseed * 435898247 + 938284287; return (random1_nextseed & 0x7fffffff); } /* -------------------------- random_tw ------------------------------ */ /* Combination of three tausworth generators. Has parameters for two different generators. Fast and excellent. */ /* Combination of 3 tausworth generators -- assumes 32-bit integers */ static t_class *random_tw_class; typedef struct _random_tw { t_object x_obj; t_float x_f; // lower limit t_float x_g; // upper limit t_int x_s1; t_int x_s2; t_int x_s3; t_int x_mask1; t_int x_mask2; t_int x_mask3; t_int x_shft1; t_int x_shft2; t_int x_shft3; t_int x_k1; t_int x_k2; t_int x_k3; t_int x_q1; t_int x_q2; t_int x_q3; t_int x_p1; t_int x_p2; t_int x_p3; unsigned int x_state; // current seed } t_random_tw; void random_tw_rand_seed (t_random_tw *x, unsigned int a, unsigned int b, unsigned int c) { static unsigned int zf = 4294967295U; x->x_shft1 = x->x_k1 - x->x_p1; x->x_shft2=x->x_k2-x->x_p2; x->x_shft3=x->x_k3-x->x_p3; x->x_mask1 = zf << (32-x->x_k1); x->x_mask2 = zf << (32-x->x_k2); x->x_mask3 = zf << (32-x->x_k3); if (a > (unsigned int)(1<x_shft1)) x->x_s1 = a; if (b > (unsigned int)(1<x_shft2)) x->x_s2 = b; if (c > (unsigned int)(1<x_shft3)) x->x_s3 = c; // rand(); } static void *random_tw_new(t_floatarg f, t_floatarg g) { t_random_tw *x = (t_random_tw *)pd_new(random_tw_class); x->x_f = (f) ? f : 0; x->x_g = (g) ? g : RAND_MAX; //post("cxc/randomix.c: lolim: %f - %f, uplim: %f - %f", x->x_f, f, x->x_g, g); x->x_state = makeseed(); x->x_s1=390451501; x->x_s2=613566701; x->x_s3=858993401; x->x_k1=31; x->x_k2=29; x->x_k3=28; x->x_q1=13; x->x_q2=2; x->x_q3=3; x->x_p1=12; x->x_p2=4; x->x_p3=17; /* x->x_q1=3; */ /* x->x_q2=2; */ /* x->x_q3=13; */ /* x->x_p1=20; */ /* x->x_p2=16; */ /* x->x_p3=7; */ random_tw_rand_seed(x, makeseed(),makeseed(),makeseed()); inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_float, gensym("fl1")); inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_float, gensym("fl2")); outlet_new(&x->x_obj, &s_float); return (x); } static void random_tw_bang(t_random_tw *x) { unsigned int b; double nval; static unsigned int zf = 4294967295U; b = ((x->x_s1 << x->x_q1)^x->x_s1) >> x->x_shft1; x->x_s1 = ((x->x_s1 & x->x_mask1) << x->x_p1) ^ b; b = ((x->x_s2 << x->x_q2) ^ x->x_s2) >> x->x_shft2; x->x_s2 = ((x->x_s2 & x->x_mask2) << x->x_p2) ^ b; b = ((x->x_s3 << x->x_q3) ^ x->x_s3) >> x->x_shft3; x->x_s3 = ((x->x_s3 & x->x_mask3) << x->x_p3) ^ b; nval = (((double)(x->x_s1 ^ x->x_s2 ^ x->x_s3) / (double)(zf) + 0.5) * (double)(x->x_g - x->x_f) + (double)x->x_f); //nval = ((x->x_state / (double)m) * (double)(x->x_g - x->x_f) + (double)x->x_f); //post("cxc/randomix.c: current rand: %f", nval); outlet_float(x->x_obj.ob_outlet, nval); } void random_tw_low(t_random_tw *x, t_floatarg f) { if(f >= x->x_g) { post("cxc/randomix.c: lower larger than upper, setting to upper - %f = %f", SMALLEST_RANGE, x->x_g - SMALLEST_RANGE); x->x_f = x->x_g - SMALLEST_RANGE; } else x->x_f = f; } void random_tw_upp(t_random_tw *x, t_floatarg f) { if(f <= x->x_f) { post("cxc/randomix.c: upper smaller than lower, setting to lower + %f = %f", SMALLEST_RANGE, x->x_f + SMALLEST_RANGE); x->x_g = x->x_f + SMALLEST_RANGE; } else x->x_g = f; } static void random_tw_seed(t_random_tw *x, float f, float glob) { //x->x_state = f; // questionable .. dont quite get how this one's seeded .. random_tw_rand_seed(x, (int)f, (int)(f*0.455777), (int)f); } static void random_tw_help(t_random_tw *x) { post("RAND_MAX: %d",RAND_MAX); post("range: %f - %f", x->x_f, x->x_g); } void random_tw_setup(void) { random_tw_class = class_new(gensym("random_tw"), (t_newmethod)random_tw_new, 0, sizeof(t_random_tw), 0, A_DEFFLOAT, A_DEFFLOAT, 0); class_addbang(random_tw_class, random_tw_bang); class_addmethod(random_tw_class, (t_method)random_tw_low, gensym("fl1"), A_FLOAT, 0); class_addmethod(random_tw_class, (t_method)random_tw_upp, gensym("fl2"), A_FLOAT, 0); class_addmethod(random_tw_class, (t_method)random_tw_seed, gensym("seed"), A_FLOAT, 0); class_addmethod(random_tw_class, (t_method)random_tw_help, gensym("help"), 0, 0); } cxc-0.5.2/bfilt2.c0000644000076500007650000000213012076107577012307 0ustar hanshans/* bangfilter: = % x plus sel 0 * spaeter: % x plus sel y mit 2 arguments */ #include "m_pd.h" #include static t_class *bfilt2_class; typedef struct _bfilt2 { t_object x_obj; t_float x_f1; t_float x_f2; } t_bfilt2; static void *bfilt2_new(t_floatarg f) { t_bfilt2 *x = (t_bfilt2 *)pd_new(bfilt2_class); outlet_new(&x->x_obj, &s_bang); floatinlet_new(&x->x_obj, &x->x_f2); x->x_f1 = 0; x->x_f2 = f; return (x); } static void bfilt2_bang(t_bfilt2 *x) { int n2 = x->x_f2, result; if (n2 < 0) n2 = -n2; else if (!n2) n2 = 1; x->x_f1++; result = ((int)(x->x_f1)) % n2; if (result == 0) //result += n2; { outlet_bang(x->x_obj.ob_outlet); } //outlet_float(x->x_obj.ob_outlet, (t_float)result); } static void bfilt2_float(t_bfilt2 *x, t_float f) { x->x_f1 = f; bfilt2_bang(x); } void bfilt2_setup() { bfilt2_class = class_new(gensym("bfilt2"), (t_newmethod)bfilt2_new, 0, sizeof(t_bfilt2), 0, A_DEFFLOAT, 0); class_addbang(bfilt2_class, bfilt2_bang); class_addfloat(bfilt2_class, (t_method)bfilt2_float); } cxc-0.5.2/bfilt2-help.pd0000644000076500007650000000223212076107577013421 0ustar hanshans#N canvas 0 31 404 226 10; #X floatatom 85 119 0 0 0 0 - - -; #X obj 57 175 print; #X floatatom 45 120 0 0 0 0 - - -; #X obj 58 146 bfilt 5; #X text 43 16 bfilt (at the moment) is: modulo something + select 0 ; #X floatatom 167 120 0 0 0 0 - - -; #X obj 139 176 print; #X floatatom 127 121 0 0 0 0 - - -; #X obj 140 147 bfilt2 5; #X obj 145 87 metro 100; #X msg 145 68 1; #X text 42 29 bfilt2: real bangfilter: bangs on first inlet \, internal counter \, only outputs every arg2th bang ...; #X msg 169 67 0; #N canvas 176 129 494 344 META 0; #X text 12 155 HELP_PATCH_AUTHORS Jonathan Wilkes revised the patch to conform to the PDDP template for Pd version 0.42.; #X text 12 45 DESCRIPTION bang on first inlet \, internal counter \, only outputs ever arg2th bang; #X text 12 5 KEYWORDS control filter bang_op; #X text 12 75 INLET_0 bang float; #X text 12 95 INLET_1 float; #X text 12 25 LICENSE GPL v2; #X text 12 115 OUTLET_0 bang; #X text 12 135 AUTHOR jdl@xdv.org; #X restore 355 203 pd META; #X connect 0 0 3 1; #X connect 2 0 3 0; #X connect 3 0 1 0; #X connect 5 0 8 1; #X connect 7 0 8 0; #X connect 8 0 6 0; #X connect 9 0 8 0; #X connect 10 0 9 0; #X connect 12 0 9 0; cxc-0.5.2/ENV.c0000644000076500007650000000345412076107577011567 0ustar hanshans/* cxc@web.fm, 2002 02 */ #include "m_pd.h" #include #ifdef _WIN32 #define setenv(a,b,c) _putenv(a) #endif /* _WIN32 */ #ifndef RAND_MAX #define RAND_MAX 2147483647 #endif t_class *ENV_class; typedef struct ENV { t_object x_obj; t_float x_RM; t_atom x_at[1]; } t_ENV; void ENV_float(t_ENV *x, t_floatarg f) { post("cxc/ENV.c: a float %f", f); } void ENV_RAND_MAX(t_ENV *x) { SETFLOAT(x->x_at, x->x_RM); #ifdef DEBUG post("cxc/ENV.c: %f",atom_getfloat(x->x_at)); #endif outlet_list(x->x_obj.ob_outlet, &s_list, 1,x->x_at); } void ENV_getenv(t_ENV *x, t_symbol *s) { char *env; env = getenv(s->s_name); #ifdef DEBUG post("cxc/ENV.c: %s",env); #endif if(env!=NULL) SETSYMBOL(x->x_at,gensym(env)); else SETFLOAT(x->x_at,-1); outlet_list(x->x_obj.ob_outlet, &s_list, 1,x->x_at); } void ENV_setenv(t_ENV *x, t_symbol *s, t_symbol *t) { //t_symbol *t = atom_getsymbol(a); // post("cxc/ENV.c: %s=%s",s->s_name,t->s_name); if(setenv(s->s_name,t->s_name,1)!=-1) post("cxc/ENV.c: set %s=%s",s->s_name,t->s_name); else post("cxc/ENV.c: set failed"); } void *ENV_new(void) { t_ENV *x = (t_ENV *)pd_new(ENV_class); x->x_RM = RAND_MAX; //x->x_at = (t_atom; outlet_new(&x->x_obj, &s_float); //post("ENV_new"); return (void *)x; } void ENV_help(void) { post("cxc/ENV.c: get + set ENVironment variables"); } void ENV_setup(void) { // post("ENV_setup"); ENV_class = class_new(gensym("ENV"), (t_newmethod)ENV_new, 0, sizeof(t_ENV), 0, 0); class_addmethod(ENV_class, (t_method)ENV_RAND_MAX, gensym("RAND_MAX"), 0); class_addmethod(ENV_class, (t_method)ENV_getenv, gensym("getenv"), A_SYMBOL); class_addmethod(ENV_class, (t_method)ENV_setenv, gensym("setenv"), A_SYMBOL, A_SYMBOL); class_addfloat(ENV_class, ENV_float); } cxc-0.5.2/cxc_prepend.c0000644000076500007650000000521412076107577013425 0ustar hanshans#include #ifdef _MSC_VER #pragma warning( disable : 4244 ) #pragma warning( disable : 4305 ) #endif /* this is taken from ggee, where the file was hanging around but the object was not funtional. i keep it here for reference since i dont wnat to fix it over and over ;) but its not included in the makefile to avoid namespace clash with ggee.prepend anyhow, i ll just rename it cxc_prepend */ /* ------------------------ prepend ----------------------------- */ static t_class *prepend_class; typedef struct _prepend { t_object x_obj; t_symbol* x_s; } t_prepend; void prepend_anything(t_prepend *x,t_symbol* s,t_int argc,t_atom* argv) { int i = argc; t_symbol* cur; t_atom a_out[256]; int c_out = 0; t_atom* a = a_out; #if 1 // post("sym: %s",s->s_name); SETSYMBOL(a,s); a++; c_out++; #endif while (i--) { switch( argv->a_type) { case A_FLOAT: // post("flo: %f",atom_getfloat(argv)); SETFLOAT(a,atom_getfloat(argv)); a++; c_out++; break; case A_SYMBOL: // post("sym: %s",atom_getsymbol(argv)->s_name); SETSYMBOL(a,atom_getsymbol(argv)); a++; c_out++; break; default: post("prepend.c: unknown type"); } argv++; } outlet_anything(x->x_obj.ob_outlet,x->x_s,c_out,(t_atom*)&a_out); //post("done"); } void prepend_list(t_prepend *x,t_symbol* s,t_int argc,t_atom* argv) { int i = argc; t_symbol* cur; t_atom a_out[256]; int c_out = 0; t_atom* a = a_out; while (i--) { switch( argv->a_type) { case A_FLOAT: // post("flo: %f",atom_getfloat(argv)); SETFLOAT(a,atom_getfloat(argv)); a++; c_out++; break; case A_SYMBOL: // post("sym: %s",atom_getsymbol(argv)->s_name); SETSYMBOL(a,atom_getsymbol(argv)); a++; c_out++; break; default: post("prepend.c: unknown type"); } argv++; } outlet_anything(x->x_obj.ob_outlet,x->x_s,c_out,(t_atom*)&a_out); //post("done"); } static void *prepend_new(t_symbol* s) { t_prepend *x = (t_prepend *)pd_new(prepend_class); outlet_new(&x->x_obj, &s_float); if (s != &s_) x->x_s = s; else x->x_s = gensym("cxc_prepend"); return (x); } static void prepend_set(t_prepend *x, t_symbol *s) { x->x_s = s; } void cxc_prepend_setup(void) { prepend_class = class_new(gensym("cxc_prepend"), (t_newmethod)prepend_new, 0, sizeof(t_prepend), 0,A_DEFSYM,NULL); class_addlist(prepend_class, prepend_list); class_addanything(prepend_class,prepend_anything); class_addmethod(prepend_class, (t_method)prepend_set, gensym("set"), A_SYMBOL, 0); } cxc-0.5.2/random_icg.c0000644000076500007650000001214612076107577013237 0ustar hanshans/* (c) 2002:cxc@web.fm randomix: various PRNG's code taken from: http://remus.rutgers.edu/%7Erhoads/Code/code.html let's check it out */ #include #include #include #define SMALLEST_RANGE .0001 #ifndef RAND_MAX #define RAND_MAX 2147483647 #endif static unsigned random_icg_INVERSE_seed (); static int makeseed(void); static int rand_random_icg(int, int); static unsigned int rand_random_icg_INVERSE_seed(int, int); static int makeseed(void) { static unsigned int random1_nextseed = 1489853723; random1_nextseed = random1_nextseed * 435898247 + 938284287; return (random1_nextseed & 0x7fffffff); } static int rand_random_icg(seed, p) { static int a, b, q, r; int state; unsigned int inv; a = 22211, b = 11926380,q = 96685, r = 12518; /* static int p = 2147483053, a = 858993221, b = 1,q = 2, r = 429496611;*/ /* static int p = 2147483053, a = 579, b = 24456079, q = 3708951, r = 424;*/ /* static int p = 2147483053, a = 11972, b = 62187060,q = 179375, r = 5553;*/ /* static int p = 2147483053, a = 21714, b = 94901263,q = 98898, r = 11881;*/ /* static int p = 2147483053, a = 4594, b = 44183289,q = 467453, r = 3971;*/ /* static int p = 2147483647, a = 1288490188, b = 1, q = 1, r = 858993459;*/ /* static int p = 2147483647, a = 9102, b = 36884165, q = 235935, r =3277;*/ /* static int p = 2147483647, a = 14288, b = 758634, q = 150299, r = 11535;*/ /* static int p = 2147483647, a = 21916, b = 71499791, q = 97987, r = 555;*/ /* static int p = 2147483647, a = 28933, b = 59217914, q = 74222, r = 18521;*/ /* static int p = 2147483647, a = 31152, b = 48897674, q = 68935, r = 20527;*/ // state = seed; inv = rand_random_icg_INVERSE_seed(seed, p); state = a*(inv % q) - r*(inv / q) + b; if (state < 0) state += p; else if (state >= state) state -= p; return state; } /* Modular Inversion using the extended Euclidean alg. for GCD */ /***************************************************************/ static unsigned rand_random_icg_INVERSE_seed (int state, int p) { unsigned int q,d; signed int u,v,inv,t; if (state <= 1) return(state); d = p; inv = 0; v = 1; u = state; do { q = d / u; t = d % u; d = u; u = t; t = inv - q*v; inv = v; v = t; } while (u != 0); if (inv < 0 ) inv += p; /* if (1 != d) */ /* post ("inverse_iter: Can't invert !"); */ return(inv); } /* -------------------------- random_icg ------------------------------ */ /* Inverse Congruential generator. This generator is quite a bit slower than the other ones on this page. and it */ /* fails some statistical tests. The main factor in its favor is that its properties tend to be the opposite of linear congruential */ /* generators. I.e. this generator is very likely to be good for those applications where linear congruential generators are */ /* bad. You can choose among several parameters. */ /* inversive congruential generator. */ static t_class *random_icg_class; typedef struct _random_icg { t_object x_obj; t_float x_f; // lower limit t_float x_g; // upper limit t_float x_p; // 1st shared parameter of iter function .. unsigned int x_state; // current seed } t_random_icg; static void *random_icg_new(t_floatarg f, t_floatarg g) { t_random_icg *x = (t_random_icg *)pd_new(random_icg_class); x->x_f = (f) ? f : 0; x->x_g = (g) ? g : RAND_MAX; x->x_p = 2147483053; //post("cxc/randomix.c: lolim: %f - %f, uplim: %f - %f", x->x_f, f, x->x_g, g); x->x_state = makeseed(); inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_float, gensym("fl1")); inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_float, gensym("fl2")); outlet_new(&x->x_obj, &s_float); return (x); } static void random_icg_bang(t_random_icg *x) { double nval; x->x_state = rand_random_icg(x->x_state, x->x_p); nval = (((x->x_state / x->x_p) - 1) * (double)(x->x_g - x->x_f) + (double)x->x_f); // hakc, why is it out of range? if(nval < (double)x->x_f) { random_icg_bang(x); } else { outlet_float(x->x_obj.ob_outlet, nval); } } void random_icg_low(t_random_icg *x, t_floatarg f) { if(f >= x->x_g) { post("cxc/randomix.c: lower larger than upper, setting to upper - %f = %f", SMALLEST_RANGE, x->x_g - SMALLEST_RANGE); x->x_f = x->x_g - SMALLEST_RANGE; } else x->x_f = f; } void random_icg_upp(t_random_icg *x, t_floatarg f) { if(f <= x->x_f) { post("cxc/randomix.c: upper smaller than lower, setting to lower + %f = %f", SMALLEST_RANGE, x->x_f + SMALLEST_RANGE); x->x_g = x->x_f + SMALLEST_RANGE; } else x->x_g = f; } static void random_icg_seed(t_random_icg *x, float f, float glob) { x->x_state = f; } void random_icg_setup(void) { random_icg_class = class_new(gensym("random_icg"), (t_newmethod)random_icg_new, 0, sizeof(t_random_icg), 0, A_DEFFLOAT, A_DEFFLOAT, 0); class_addbang(random_icg_class, random_icg_bang); class_addmethod(random_icg_class, (t_method)random_icg_low, gensym("fl1"), A_FLOAT, 0); class_addmethod(random_icg_class, (t_method)random_icg_upp, gensym("fl2"), A_FLOAT, 0); class_addmethod(random_icg_class, (t_method)random_icg_seed, gensym("seed"), A_FLOAT, 0); } cxc-0.5.2/random_fl-help.pd0000644000076500007650000001527212076107577014210 0ustar hanshans#N canvas 0 31 966 505 10; #X msg 197 150 bang; #X floatatom 244 150 5 0 0 0 - - -; #X floatatom 197 218 10 0 0 0 - - -; #X floatatom 53 162 5 0 0 0 - - -; #X msg 54 111 bang; #X floatatom 289 152 5 0 0 0 - - -; #X obj 53 135 random 100; #X msg 427 151 bang; #X floatatom 474 151 5 0 0 0 - - -; #X floatatom 427 219 10 0 0 0 - - -; #X floatatom 519 153 5 0 0 0 - - -; #X obj 196 183 random1 0 1; #X obj 426 184 random_fl 0 1; #X msg 672 152 bang; #X floatatom 719 152 5 0 0 0 - - -; #X floatatom 672 220 10 0 0 0 - - -; #X floatatom 764 154 5 0 0 0 - - -; #X obj 671 185 random_icg 0 1; #X msg 197 276 bang; #X floatatom 244 276 5 0 0 0 - - -; #X floatatom 197 344 10 0 0 0 - - -; #X floatatom 289 278 5 0 0 0 - - -; #X text 193 251 random_icg lowerlimit \, upperlimit; #X msg 368 288 help; #X text 253 10 the random number generatorse; #X obj 539 406 dist_normal; #X msg 540 356 bang; #X obj 579 357 metro 100; #X obj 579 337 tgl 15 0 empty empty empty 20 8 0 8 -262144 -1 -1 0 1; #X obj 196 309 random_tw 0 1; #X floatatom 637 334 5 0 0 0 - - -; #N canvas 0 0 600 400 streamview 0; #N canvas 0 0 450 300 (subpatch) 0; #X array randstream 100 float 0; #X coords 0 2 99 -2 200 140 1; #X restore 92 222 graph; #X obj 146 144 tabwrite randstream; #X obj 200 63 count; #X obj 200 88 % 100; #X obj 156 28 t f b; #X obj 49 15 inlet; #X connect 2 0 3 0; #X connect 3 0 1 1; #X connect 4 0 1 0; #X connect 4 1 2 0; #X connect 5 0 4 0; #X restore 570 433 pd streamview; #N canvas 306 24 679 400 distview 0; #N canvas 0 0 450 300 (subpatch) 0; #X array randview1 100 float 0; #X coords 0 200 99 0 400 200 1; #X restore 248 31 graph; #X obj 28 26 inlet; #X obj 45 355 tabwrite randview1; #X obj 136 201 * 100; #X obj 136 225 int; #X obj 136 153 + 2; #X obj 45 280 tabread randview1; #X obj 136 176 / 4; #X obj 136 250 t f f; #X obj 45 304 t f b; #X obj 45 329 + 1; #X obj 136 129 t f; #X connect 1 0 11 0; #X connect 3 0 4 0; #X connect 4 0 8 0; #X connect 5 0 7 0; #X connect 6 0 9 0; #X connect 7 0 3 0; #X connect 8 0 6 0; #X connect 8 1 2 1; #X connect 9 0 10 0; #X connect 10 0 2 0; #X connect 11 0 5 0; #X restore 550 458 pd distview; #X obj 540 381 t b; #X floatatom 477 430 5 0 0 0 - - -; #N canvas 0 0 600 400 seedit 0; #X msg 284 154 seed \$1; #X obj 284 107 utime; #X msg 304 74 bang; #X obj 254 28 loadbang; #X obj 284 130 * 1e+06; #X obj 360 167 until; #X msg 455 156 bang; #X obj 359 194 random 2.14748e+08; #X msg 359 267 seed \$1; #X msg 385 294 seed \$1; #X msg 412 318 seed \$1; #X msg 439 267 seed \$1; #X msg 466 293 seed \$1; #X obj 254 50 t b b; #X obj 195 155 print seed1; #X obj 143 360 outlet; #X obj 204 361 outlet; #X obj 264 361 outlet; #X obj 317 361 outlet; #X obj 367 361 outlet; #X text 35 9 seed one random obj \, which generates the seeds for all the others.; #X obj 359 218 serialize 6; #X msg 360 140 6; #X obj 359 242 unpack f f f f f f; #X msg 485 317 seed \$1; #X obj 420 359 outlet; #X connect 0 0 7 0; #X connect 1 1 4 0; #X connect 2 0 1 0; #X connect 3 0 13 0; #X connect 4 0 0 0; #X connect 4 0 14 0; #X connect 5 0 7 0; #X connect 6 0 7 0; #X connect 7 0 21 0; #X connect 8 0 15 0; #X connect 9 0 16 0; #X connect 10 0 17 0; #X connect 11 0 18 0; #X connect 12 0 19 0; #X connect 13 0 22 0; #X connect 13 1 1 0; #X connect 21 0 23 0; #X connect 22 0 5 0; #X connect 23 0 8 0; #X connect 23 1 9 0; #X connect 23 2 10 0; #X connect 23 3 11 0; #X connect 23 4 12 0; #X connect 23 5 24 0; #X connect 24 0 25 0; #X restore 258 33 pd seedit; #X text 37 79 std pd random; #X text 197 124 linear congruential generator; #X text 197 77 creation arguments for the extra randoms are:; #X text 205 92 \, defaults to 0 respectively RAND_MAX; #X text 545 17 see also:; #X obj 545 40 utime; #X text 428 129 another lcg method ..; #X text 668 127 inverse linear congruential generator; #X text 536 249 normal distribution mean 0 and dist 1; #X text 536 264 right now it uses random1 for the actual rand values ; #X text 537 278 but later on it should take one of the randoms as creation argument \, so yu can specify which generator is being used.; #X text 198 106 they all output floats); #X text 540 311 also \, there is some burst at the upper and lower limits; #N canvas 622 668 592 356 signalversions 0; #X obj 68 131 random1~; #N canvas 0 0 450 300 (subpatch) 0; #X array \$0-randomix_test 64 float 1; #A 0 -0.599965 0.178987 -0.501604 -1.10592 0.426163 -0.481499 -0.553236 0.0961931 0.554738 -0.695487 0.541875 -0.415309 -0.419922 -0.871908 0.0688377 -1.03721 -0.136159 -0.207339 -1.18947 -0.25981 -0.628915 -0.826873 0.334755 -0.738558 -0.0926691 -0.262739 0.309148 0.50131 -1.40461 -0.859907 0.621724 -0.888718 0.692579 -1.11799 0.162897 0.116501 -0.390333 0.327364 -0.902445 -0.201419 0.300071 -1.10817 -1.09973 0.34181 -0.0511739 -0.613584 -0.306316 0.433381 -0.154481 -1.17821 -0.428187 -0.449014 -1.04248 -0.906665 0.0687456 -1.08289 0.59097 0.0438875 -1.20429 0.0862183 -0.995607 0.585034 0.205198 -0.337256; #X coords 0 1 63 -1 200 140 1; #X restore 351 23 graph; #X obj 382 183 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0 1; #X floatatom 440 184 5 0 0 0 - - -; #X obj 382 201 metro 100; #X msg 342 201 bang; #X obj 73 295 dac~; #X floatatom 140 220 5 0 0 0 - - -; #X msg 68 58 seed 30000; #X obj 142 131 random_fl~; #X text 120 98 etc ..; #X obj 229 131 random_icg~; #X obj 81 241 fader 75; #X obj 368 239 tabwrite~ \$0-randomix_test; #X connect 0 0 12 0; #X connect 2 0 4 0; #X connect 3 0 4 1; #X connect 4 0 13 0; #X connect 5 0 13 0; #X connect 7 0 12 2; #X connect 8 0 0 0; #X connect 9 0 12 1; #X connect 11 0 12 0; #X connect 11 0 13 0; #X connect 12 0 6 0; #X connect 12 1 6 1; #X restore 98 421 pd signalversions; #N canvas 549 327 494 344 META 0; #X text 12 165 HELP_PATCH_AUTHORS Jonathan Wilkes revised the patch to conform to the PDDP template for Pd version 0.42.; #X text 12 25 LICENSE GPL v2; #X text 12 145 AUTHOR jdl@xdv.org; #X text 12 45 DESCRIPTION another lcg method ..; #X text 12 85 INLET_1 float; #X text 12 105 INLET_2 float; #X text 12 125 OUTLET_0 float; #X text 12 5 KEYWORDS control random; #X text 12 65 INLET_0 bang seed; #X restore 907 478 pd META; #X connect 0 0 11 0; #X connect 1 0 11 1; #X connect 4 0 6 0; #X connect 5 0 11 2; #X connect 6 0 3 0; #X connect 7 0 12 0; #X connect 8 0 12 1; #X connect 10 0 12 2; #X connect 11 0 2 0; #X connect 12 0 9 0; #X connect 13 0 17 0; #X connect 14 0 17 1; #X connect 16 0 17 2; #X connect 17 0 15 0; #X connect 18 0 29 0; #X connect 19 0 29 1; #X connect 21 0 29 2; #X connect 23 0 29 0; #X connect 25 0 31 0; #X connect 25 0 32 0; #X connect 25 0 34 0; #X connect 26 0 33 0; #X connect 27 0 33 0; #X connect 28 0 27 0; #X connect 29 0 20 0; #X connect 30 0 27 1; #X connect 33 0 25 0; #X connect 35 0 6 0; #X connect 35 1 11 0; #X connect 35 2 12 0; #X connect 35 3 17 0; #X connect 35 4 29 0; cxc-0.5.2/cxc_prepend-help.pd0000644000076500007650000000147712076107577014543 0ustar hanshans#N canvas 0 31 450 300 10; #X obj 186 244 print; #X msg 200 102 itsch ni san chi; #X obj 186 187 cxc_prepend /bla; #X obj 186 210 cxc_prepend send; #X floatatom 155 79 5 0 0 0 - - -; #X msg 214 138 qui qua 2 3.4555 "bla ha"; #X text 25 11 prepend arbitrary length lists/anythings with stuff; #N canvas 397 200 494 344 META 0; #X text 12 135 HELP_PATCH_AUTHORS Jonathan Wilkes revised the patch to conform to the PDDP template for Pd version 0.42.; #X text 12 45 DESCIPTION prepend arbitrary length lists/anythings with stuff; #X text 12 5 KEYWORDS control anything_op; #X text 12 75 INLET_0 anything set; #X text 12 95 OUTLET_0 anything; #X text 12 25 LICENSE GPL v2; #X text 12 115 AUTHOR jdl@xdv.org; #X restore 395 277 pd META; #X connect 1 0 2 0; #X connect 2 0 3 0; #X connect 3 0 0 0; #X connect 4 0 2 0; #X connect 5 0 2 0; cxc-0.5.2/cxstddev.c0000644000076500007650000000002312076107577012750 0ustar hanshans#include "mean~.c" cxc-0.5.2/hex2dec.c0000644000076500007650000000211112076107577012446 0ustar hanshans#include "m_pd.h" #include #include #include /* ----------------------- hex2dec --------------------- */ static t_class *hex2dec_class; typedef struct _hex2dec { t_object x_obj; t_symbol *x_format; } t_hex2dec; static void *hex2dec_new(t_symbol *s) { t_hex2dec *x = (t_hex2dec *)pd_new(hex2dec_class); if (!s->s_name) s = gensym("file.%d"); outlet_new(&x->x_obj, &s_symbol); x->x_format = s; return (x); } static void hex2dec_float(t_hex2dec *x, t_floatarg f) { char buf[MAXPDSTRING]; sprintf(buf, x->x_format->s_name, (int)f); outlet_symbol(x->x_obj.ob_outlet, gensym(buf)); } static void hex2dec_symbol(t_hex2dec *x, t_symbol *s) { char buf[MAXPDSTRING]; sprintf(buf, x->x_format->s_name, s->s_name); outlet_symbol(x->x_obj.ob_outlet, gensym(buf)); } void hex2dec_setup(void) { hex2dec_class = class_new(gensym("hex2dec"), (t_newmethod)hex2dec_new, 0, sizeof(t_hex2dec), 0, A_DEFSYM, 0); class_addfloat(hex2dec_class, hex2dec_float); class_addsymbol(hex2dec_class, hex2dec_symbol); } cxc-0.5.2/random_icg~-help.pd0000644000076500007650000001530312076107577014542 0ustar hanshans#N canvas 0 31 966 505 10; #X msg 197 150 bang; #X floatatom 244 150 5 0 0 0 - - -; #X floatatom 197 218 10 0 0 0 - - -; #X floatatom 53 162 5 0 0 0 - - -; #X msg 54 111 bang; #X floatatom 289 152 5 0 0 0 - - -; #X obj 53 135 random 100; #X msg 427 151 bang; #X floatatom 474 151 5 0 0 0 - - -; #X floatatom 427 219 10 0 0 0 - - -; #X floatatom 519 153 5 0 0 0 - - -; #X obj 196 183 random1 0 1; #X obj 426 184 random_fl 0 1; #X msg 672 152 bang; #X floatatom 719 152 5 0 0 0 - - -; #X floatatom 672 220 10 0 0 0 - - -; #X floatatom 764 154 5 0 0 0 - - -; #X obj 671 185 random_icg 0 1; #X msg 197 276 bang; #X floatatom 244 276 5 0 0 0 - - -; #X floatatom 197 344 10 0 0 0 - - -; #X floatatom 289 278 5 0 0 0 - - -; #X text 193 251 random_icg lowerlimit \, upperlimit; #X msg 368 288 help; #X text 253 10 the random number generatorse; #X obj 539 406 dist_normal; #X msg 540 356 bang; #X obj 579 357 metro 100; #X obj 579 337 tgl 15 0 empty empty empty 20 8 0 8 -262144 -1 -1 0 1; #X obj 196 309 random_tw 0 1; #X floatatom 637 334 5 0 0 0 - - -; #N canvas 0 0 600 400 streamview 0; #N canvas 0 0 450 300 (subpatch) 0; #X array randstream 100 float 0; #X coords 0 2 99 -2 200 140 1; #X restore 92 222 graph; #X obj 146 144 tabwrite randstream; #X obj 200 63 count; #X obj 200 88 % 100; #X obj 156 28 t f b; #X obj 49 15 inlet; #X connect 2 0 3 0; #X connect 3 0 1 1; #X connect 4 0 1 0; #X connect 4 1 2 0; #X connect 5 0 4 0; #X restore 570 433 pd streamview; #N canvas 306 24 679 400 distview 0; #N canvas 0 0 450 300 (subpatch) 0; #X array randview1 100 float 0; #X coords 0 200 99 0 400 200 1; #X restore 248 31 graph; #X obj 28 26 inlet; #X obj 45 355 tabwrite randview1; #X obj 136 201 * 100; #X obj 136 225 int; #X obj 136 153 + 2; #X obj 45 280 tabread randview1; #X obj 136 176 / 4; #X obj 136 250 t f f; #X obj 45 304 t f b; #X obj 45 329 + 1; #X obj 136 129 t f; #X connect 1 0 11 0; #X connect 3 0 4 0; #X connect 4 0 8 0; #X connect 5 0 7 0; #X connect 6 0 9 0; #X connect 7 0 3 0; #X connect 8 0 6 0; #X connect 8 1 2 1; #X connect 9 0 10 0; #X connect 10 0 2 0; #X connect 11 0 5 0; #X restore 550 458 pd distview; #X obj 540 381 t b; #X floatatom 477 430 5 0 0 0 - - -; #N canvas 0 0 600 400 seedit 0; #X msg 284 154 seed \$1; #X obj 284 107 utime; #X msg 304 74 bang; #X obj 254 28 loadbang; #X obj 284 130 * 1e+06; #X obj 360 167 until; #X msg 455 156 bang; #X obj 359 194 random 2.14748e+08; #X msg 359 267 seed \$1; #X msg 385 294 seed \$1; #X msg 412 318 seed \$1; #X msg 439 267 seed \$1; #X msg 466 293 seed \$1; #X obj 254 50 t b b; #X obj 195 155 print seed1; #X obj 143 360 outlet; #X obj 204 361 outlet; #X obj 264 361 outlet; #X obj 317 361 outlet; #X obj 367 361 outlet; #X text 35 9 seed one random obj \, which generates the seeds for all the others.; #X obj 359 218 serialize 6; #X msg 360 140 6; #X obj 359 242 unpack f f f f f f; #X msg 485 317 seed \$1; #X obj 420 359 outlet; #X connect 0 0 7 0; #X connect 1 1 4 0; #X connect 2 0 1 0; #X connect 3 0 13 0; #X connect 4 0 0 0; #X connect 4 0 14 0; #X connect 5 0 7 0; #X connect 6 0 7 0; #X connect 7 0 21 0; #X connect 8 0 15 0; #X connect 9 0 16 0; #X connect 10 0 17 0; #X connect 11 0 18 0; #X connect 12 0 19 0; #X connect 13 0 22 0; #X connect 13 1 1 0; #X connect 21 0 23 0; #X connect 22 0 5 0; #X connect 23 0 8 0; #X connect 23 1 9 0; #X connect 23 2 10 0; #X connect 23 3 11 0; #X connect 23 4 12 0; #X connect 23 5 24 0; #X connect 24 0 25 0; #X restore 258 33 pd seedit; #X text 37 79 std pd random; #X text 197 124 linear congruential generator; #X text 197 77 creation arguments for the extra randoms are:; #X text 205 92 \, defaults to 0 respectively RAND_MAX; #X text 545 17 see also:; #X obj 545 40 utime; #X text 428 129 another lcg method ..; #X text 668 127 inverse linear congruential generator; #X text 536 249 normal distribution mean 0 and dist 1; #X text 536 264 right now it uses random1 for the actual rand values ; #X text 537 278 but later on it should take one of the randoms as creation argument \, so yu can specify which generator is being used.; #X text 198 106 they all output floats); #X text 540 311 also \, there is some burst at the upper and lower limits; #N canvas 622 668 592 356 signalversions 0; #X obj 68 131 random1~; #N canvas 0 0 450 300 (subpatch) 0; #X array \$0-randomix_test 64 float 1; #A 0 -0.599965 0.178987 -0.501604 -1.10592 0.426163 -0.481499 -0.553236 0.0961931 0.554738 -0.695487 0.541875 -0.415309 -0.419922 -0.871908 0.0688377 -1.03721 -0.136159 -0.207339 -1.18947 -0.25981 -0.628915 -0.826873 0.334755 -0.738558 -0.0926691 -0.262739 0.309148 0.50131 -1.40461 -0.859907 0.621724 -0.888718 0.692579 -1.11799 0.162897 0.116501 -0.390333 0.327364 -0.902445 -0.201419 0.300071 -1.10817 -1.09973 0.34181 -0.0511739 -0.613584 -0.306316 0.433381 -0.154481 -1.17821 -0.428187 -0.449014 -1.04248 -0.906665 0.0687456 -1.08289 0.59097 0.0438875 -1.20429 0.0862183 -0.995607 0.585034 0.205198 -0.337256; #X coords 0 1 63 -1 200 140 1; #X restore 351 23 graph; #X obj 382 183 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0 1; #X floatatom 440 184 5 0 0 0 - - -; #X obj 382 201 metro 100; #X msg 342 201 bang; #X obj 73 295 dac~; #X floatatom 140 220 5 0 0 0 - - -; #X msg 68 58 seed 30000; #X obj 142 131 random_fl~; #X text 120 98 etc ..; #X obj 229 131 random_icg~; #X obj 81 241 fader 75; #X obj 368 239 tabwrite~ \$0-randomix_test; #X connect 0 0 12 0; #X connect 2 0 4 0; #X connect 3 0 4 1; #X connect 4 0 13 0; #X connect 5 0 13 0; #X connect 7 0 12 2; #X connect 8 0 0 0; #X connect 9 0 12 1; #X connect 11 0 12 0; #X connect 11 0 13 0; #X connect 12 0 6 0; #X connect 12 1 6 1; #X restore 98 421 pd signalversions; #N canvas 176 129 494 344 META 0; #X text 12 165 HELP_PATCH_AUTHORS Jonathan Wilkes revised the patch to conform to the PDDP template for Pd version 0.42.; #X text 12 5 KEYWORDS control time; #X text 12 65 INLET_0 bang; #X text 12 25 LICENSE GPL v2; #X text 12 145 AUTHOR jdl@xdv.org; #X text 12 45 DESCRIPTION inverse linear congruential generator; #X text 12 85 INLET_1 float; #X text 12 105 INLET_2 float; #X text 12 125 OUTLET_0 float; #X restore 907 458 pd META; #X connect 0 0 11 0; #X connect 1 0 11 1; #X connect 4 0 6 0; #X connect 5 0 11 2; #X connect 6 0 3 0; #X connect 7 0 12 0; #X connect 8 0 12 1; #X connect 10 0 12 2; #X connect 11 0 2 0; #X connect 12 0 9 0; #X connect 13 0 17 0; #X connect 14 0 17 1; #X connect 16 0 17 2; #X connect 17 0 15 0; #X connect 18 0 29 0; #X connect 19 0 29 1; #X connect 21 0 29 2; #X connect 23 0 29 0; #X connect 25 0 31 0; #X connect 25 0 32 0; #X connect 25 0 34 0; #X connect 26 0 33 0; #X connect 27 0 33 0; #X connect 28 0 27 0; #X connect 29 0 20 0; #X connect 30 0 27 1; #X connect 33 0 25 0; #X connect 35 0 6 0; #X connect 35 1 11 0; #X connect 35 2 12 0; #X connect 35 3 17 0; #X connect 35 4 29 0; cxc-0.5.2/proc.c0000644000076500007650000001421412076107577012076 0ustar hanshans/* cxc@web.fm, 200203 interface to the linux proc filesystem TODO: stat, number of users, network stats (tx,rx,etc) */ #include "m_pd.h" #include #include #include //#include // later for number of users // #include /* support older Pd versions without sys_fopen(), sys_fclose(), and, sys_close() */ #if PD_MAJOR_VERSION == 0 && PD_MINOR_VERSION < 44 #define sys_fopen fopen #define sys_fclose fclose #define sys_close close #endif #ifndef SSIZE_MAX #define SSIZE_MAX 255 #endif #ifndef RAND_MAX #define RAND_MAX 2147483647 #endif #ifndef MAXOUTAT #define MAXOUTAT 50 #endif t_class *proc_class; typedef struct proc { t_object x_obj; // t_float x_RM; t_atom x_at[MAXOUTAT]; int x_atc; } t_proc; void proc_float(t_proc *x, t_floatarg f) { post("cxc/proc.c: %f", f); } void proc_cpuinfo(t_proc *x) { char name[255]; // filename char rest[255]; // string value t_float restf; // float value char bla[1]; FILE* fp; // info file descriptor // t_float val; int ac; // atom count t_atom* at = x->x_at; // out atom int atc = x->x_atc; // out atom count //name = "/proc/cpuinfo"; sprintf(name,"%s","/proc/cpuinfo"); //val = 0; restf = 0; ac = 0; fp = sys_fopen(name,"r"); if (!fp) { post("cxc/proc.c: unable to open %s",name); return; } //*name = 0; while(!feof(fp)) { /* fread(bla,1,1,fp); */ /* post("cxc/proc.c: '%s'",bla); */ //ac = fscanf(fp,"%s\t: %s",name,rest); ac = fscanf(fp,"%s\t: %f",name,&restf); // fscanf(fp,"%s\t%s %d",name,rest,&val); if((!strcmp("MHz",name) || !strcmp("processor",name) || !strcmp("bogomips",name)) && ac != -1) { if(!strcmp("MHz",name)) { //val = (t_float)sprintf("%f",rest); SETFLOAT(at+atc,restf); atc++; } else if (!strcmp("processor",name)) { SETFLOAT(at+atc,restf); atc++; } else if (!strcmp("bogomips",name)) { SETFLOAT(at+atc,restf); atc++; } #ifdef DEBUG post("cxc/proc.c: count %d, '%s' -> '%f'",ac,name,restf); #endif } } outlet_anything(x->x_obj.ob_outlet, gensym("cpuinfo"),atc,at); } ///////////////////////////////////////////////////////////////// // more generic proc function: file to open is the message itself void proc_proc(t_proc *x, t_symbol *s) { char name[255]; // filename char rest[255]; // string value t_float restf; // float value t_float restg; // another float, needing more etc t_float resth; // another float, needing more etc // unsmart, convert the whole line // into an atom vector or something ... int a,b,c; // few helper ints for scanf char bla[1]; FILE* fp; // info file descriptor // t_float val; int ac; // atom count t_atom* at = x->x_at; // out atom int atc = x->x_atc; // out atom count //post("cxc/proc.c: %s",s->s_name); //sprintf(name,"%s","/proc/cpuinfo"); sprintf(name,"/proc/%s",s->s_name); //val = 0; restf = 0; ac = 0; fp = sys_fopen(name,"r"); if (!fp) { post("cxc/proc.c: unable to open %s",name); return; } //*name = 0; while(!feof(fp)) { /* fread(bla,1,1,fp); */ /* post("cxc/proc.c: '%s'",bla); */ //ac = fscanf(fp,"%s\t: %s",name,rest); // ac = fscanf(fp,"%s\t: %f",name,&restf); // fscanf(fp,"%s\t%s %d",name,rest,&val); ////////////////////////////////////////////////// // cpuinfo (rel. compl. parse) if(!strcmp("cpuinfo",s->s_name)) { ac = fscanf(fp,"%s\t: %f",name,&restf); #ifdef DEBUG if((!strcmp("MHz",name) || !strcmp("processor",name) || !strcmp("bogomips",name)) && ac != -1) { post("cxc/proc.c: count %d, '%s' -> '%f'",ac,name,restf); } #endif if(!strcmp("MHz",name)) { //val = (t_float)sprintf("%f",rest); SETFLOAT(at+atc,restf); atc++; } else if (!strcmp("processor",name)) { SETFLOAT(at+atc,restf); atc++; } else if (!strcmp("bogomips",name)) { SETFLOAT(at+atc,restf); atc++; } ////////////////////////////////////////////////// // uptime (easy, just two floats ... } else if (!strcmp("uptime",s->s_name)) { ac = fscanf(fp,"%f %f",&restf,&restg); SETFLOAT(at+atc,restf); atc++; SETFLOAT(at+atc,restg); atc++; // why break here? break; ////////////////////////////////////////////////// // loadavg } else if (!strcmp("loadavg",s->s_name)) { ac = fscanf(fp,"%f %f %f %d/%d %d",&restf,&restg,&resth,&a,&b,&c); SETFLOAT(at+atc,restf); atc++; SETFLOAT(at+atc,restg); atc++; SETFLOAT(at+atc,resth); atc++; SETFLOAT(at+atc,(t_float)a); atc++; SETFLOAT(at+atc,(t_float)b); atc++; SETFLOAT(at+atc,(t_float)c); atc++; // why break here? break; ////////////////////////////////////////////////// // version (linux version) } else if (!strcmp("version",s->s_name)) { ac = fscanf(fp,"%s %s %d.%d.%d *",name,rest,&a,&b,&c); SETFLOAT(at+atc,a); atc++; SETFLOAT(at+atc,b); atc++; SETFLOAT(at+atc,c); atc++; // why break here? break; /* } else if (!strcmp("stat",s->s_name)) { */ /* break; */ } else { post("cxc/proc.c: %s not yet implemented",s->s_name); break; } } fclose(fp); outlet_anything(x->x_obj.ob_outlet, gensym(s->s_name),atc,at); } void *proc_new(void) { t_proc *x = (t_proc *)pd_new(proc_class); x->x_atc = 0; outlet_new(&x->x_obj, &s_anything); return (void *)x; } void proc_setup(void) { // post("proc_setup"); proc_class = class_new(gensym("proc"), (t_newmethod)proc_new, 0, sizeof(t_proc), 0, 0); class_addmethod(proc_class, (t_method)proc_cpuinfo, gensym("cpuinfo"), 0); class_addmethod(proc_class, (t_method)proc_proc, gensym("proc"), A_SYMBOL); //class_addmethod(proc_class, (t_method)proc_RAND_MAX, gensym("RAND_MAX"), 0); //class_addmethod(proc_class, (t_method)proc_getenv, gensym("getenv"), A_SYMBOL); //class_addmethod(proc_class, (t_method)proc_setenv, gensym("setenv"), A_SYMBOL, A_SYMBOL); class_addfloat(proc_class, proc_float); } cxc-0.5.2/cxmean-help.pd0000644000076500007650000000635612076107577013525 0ustar hanshans#N canvas 0 31 645 382 10; #X obj 64 102 noise~; #X obj 463 105 mean~ blir; #X obj 21 262 table blir; #N canvas 162 270 331 246 fillary 0; #X obj 34 53 until; #X obj 34 79 count; #X msg 85 27 bang; #X obj 34 105 - 1; #X obj 34 130 t b f; #X obj 34 166 random_fl -1 1; #X obj 162 16 loadbang; #X obj 192 64 utime; #X obj 200 100 +; #X msg 200 124 seed \$1; #X obj 162 39 t b b b; #X obj 232 13 inlet; #X obj 120 65 t b b; #X msg 34 27 1000; #X msg 132 108 set \$1; #X obj 280 13 inlet; #X obj 178 165 random_icg -1 1; #X obj 34 192 tabwrite blor; #X connect 0 0 1 0; #X connect 1 0 3 0; #X connect 2 0 1 1; #X connect 3 0 4 0; #X connect 4 0 5 0; #X connect 4 1 17 1; #X connect 5 0 17 0; #X connect 6 0 10 0; #X connect 7 0 8 0; #X connect 7 1 8 1; #X connect 8 0 9 0; #X connect 9 0 5 0; #X connect 9 0 16 0; #X connect 10 0 12 0; #X connect 10 1 7 0; #X connect 11 0 12 0; #X connect 12 0 13 0; #X connect 12 1 2 0; #X connect 13 0 0 0; #X connect 14 0 13 0; #X connect 15 0 14 0; #X connect 16 0 17 0; #X restore 152 241 pd fillary; #X obj 21 175 tabwrite~ blir; #X msg 21 147 bang; #X obj 356 102 samplerate~; #X floatatom 356 126 5 0 0 0 - - -; #X obj 356 80 loadbang; #X floatatom 463 129 8 0 0 0 - - -; #X obj 64 150 +~ 0.1; #X floatatom 101 127 5 0 0 0 - - -; #X msg 152 218 bang; #X text 44 30 mean~ ; #X floatatom 160 160 5 0 0 0 - - -; #X obj 160 183 t f f; #X text 206 163 set arraysize; #X text 529 130 mean; #X text 43 10 this is supposed to calculate the signal mean of an array. ; #X msg 463 82 mean; #X msg 503 82 ad; #X msg 534 82 sd; #X obj 462 35 mean 1 2 3; #X floatatom 462 59 5 0 0 0 - - -; #X msg 462 13 1 2 3.6677; #X floatatom 271 305 8 0 0 0 - - -; #X msg 316 228 mean; #X msg 350 228 ad; #X obj 21 291 table blor; #X floatatom 341 325 10 0 0 0 - - -; #X floatatom 461 326 10 0 0 0 - - -; #X obj 392 150 loadbang; #X obj 316 272 t f f f; #X text 542 36 pd's mean; #X text 544 115 dont need this; #X msg 392 218 set \$1; #X obj 392 194 symbol; #X msg 392 173 blir; #X msg 429 173 blor; #X msg 20 214 \; blir resize \$1 \;; #X msg 113 270 \; blor resize \$1 \;; #X obj 460 304 cxstddev blir; #X obj 342 304 cxavgdev blir; #X obj 316 251 cxmean blir; #N canvas 567 269 494 344 META 0; #X text 12 135 HELP_PATCH_AUTHORS Jonathan Wilkes revised the patch to conform to the PDDP template for Pd version 0.42.; #X text 12 25 LICENSE GPL v2; #X text 12 115 AUTHOR jdl@xdv.org; #X text 12 5 KEYWORDS control array; #X text 12 45 DESCRIPTION this is supposed to calculate the signal mean of an array.; #X text 12 95 OUTLET_0 float; #X text 12 75 INLET_0 float set; #X restore 583 337 pd META; #X connect 0 0 10 0; #X connect 1 0 9 0; #X connect 5 0 4 0; #X connect 6 0 7 0; #X connect 8 0 6 0; #X connect 10 0 4 0; #X connect 11 0 10 1; #X connect 12 0 3 0; #X connect 14 0 15 0; #X connect 15 0 39 0; #X connect 15 0 40 0; #X connect 15 1 3 1; #X connect 19 0 1 0; #X connect 20 0 1 0; #X connect 21 0 1 0; #X connect 22 0 23 0; #X connect 24 0 22 0; #X connect 26 0 43 0; #X connect 27 0 43 0; #X connect 31 0 38 0; #X connect 32 0 25 0; #X connect 32 1 42 0; #X connect 32 2 41 0; #X connect 35 0 41 0; #X connect 35 0 42 0; #X connect 35 0 43 0; #X connect 36 0 35 0; #X connect 37 0 36 0; #X connect 38 0 36 0; #X connect 41 0 30 0; #X connect 42 0 29 0; #X connect 43 0 32 0; cxc-0.5.2/random1~.c0000644000076500007650000000625612076107577012701 0ustar hanshans/* (c) 2002:cxc@web.fm randomix: various PRNG's code taken from: http://remus.rutgers.edu/%7Erhoads/Code/code.html let's check it out */ #include #include #include #define SMALLEST_RANGE .0001 #ifndef RAND_MAX #define RAND_MAX 2147483647 #endif static int makeseed(void); static int rand_random1(int); static int makeseed(void) { static unsigned int random1_nextseed = 1489853723; random1_nextseed = random1_nextseed * 435898247 + 938284287; return (random1_nextseed & 0x7fffffff); } /* -------------------------- random1 ------------------------------ */ /* linear congruential generator. Generator x[n+1] = a * x[n] mod m */ static int rand_random1(seed) { int state; //unsigned int a = 1588635695, m = 4294967291U, q = 2, r = 1117695901; // unsigned int a = 1588635695, m = (RAND_MAX * 2), q = 2, r = 1117695901; /* static unsigned int a = 1223106847, m = 4294967291U, q = 3, r = 625646750;*/ /* static unsigned int a = 279470273, m = 4294967291U, q = 15, r = 102913196;*/ //static unsigned int a = 1583458089, m = 2147483647, q = 1, r = 564025558; static unsigned int a = 784588716, m = 2147483647, q = 2, r = 578306215; /* static unsigned int a = 16807, m = 2147483647, q = 127773, r = 2836; */ /* static unsigned int a = 950706376, m = 2147483647, q = 2, r = 246070895; */ //state = (seed) ? seed : makeseed(); state = seed; state = a*(state % q) - r*(state / q); return (state); } /* -------------------------- random1 ------------------------------ */ /* linear congruential generator. Generator x[n+1] = a * x[n] mod m */ static t_class *random1_class; typedef struct _random1 { t_object x_obj; t_float x_f; // lower limit t_float x_g; // upper limit unsigned int x_state; // current seed } t_random1; /* -------------------------- random1 ------------------------------ */ /* linear congruential generator. Generator x[n+1] = a * x[n] mod m */ /* signal version */ static t_class *random1_tilde_class; typedef struct _random1_tilde { t_object x_obj; unsigned int x_state; // current seed } t_random1_tilde; static void *random1_tilde_new() { t_random1_tilde *x = (t_random1_tilde *)pd_new(random1_tilde_class); x->x_state = makeseed(); outlet_new(&x->x_obj, gensym("signal")); return (x); } static void random1_tilde_seed(t_random1_tilde *x, float f, float glob) { x->x_state = f; } static t_int *random1_tilde_perform(t_int *w) { t_random1_tilde *x = (t_random1_tilde *)(w[1]); t_float *out = (t_float *)(w[2]); int n = (int)(w[3]); while (n--) { // generate new noise sample x->x_state = rand_random1(x->x_state); *out++ = (t_float)x->x_state / RAND_MAX - 1; } return (w+4); } static void random1_tilde_dsp(t_random1_tilde *x, t_signal **sp) { dsp_add(random1_tilde_perform, 3, x, sp[0]->s_vec, sp[0]->s_n); } void random1_tilde_setup(void) { random1_tilde_class = class_new(gensym("random1~"), (t_newmethod)random1_tilde_new, 0, sizeof(t_random1_tilde), 0, 0); class_addmethod(random1_tilde_class, (t_method)random1_tilde_seed,gensym("seed"), A_FLOAT, 0); class_addmethod(random1_tilde_class, (t_method)random1_tilde_dsp, gensym("dsp"), 0); } cxc-0.5.2/cxstddev-help.pd0000644000076500007650000000635612076107577014076 0ustar hanshans#N canvas 0 31 640 382 10; #X obj 64 102 noise~; #X obj 463 105 mean~ blir; #X obj 21 262 table blir; #N canvas 162 270 331 246 fillary 0; #X obj 34 53 until; #X obj 34 79 count; #X msg 85 27 bang; #X obj 34 105 - 1; #X obj 34 130 t b f; #X obj 34 166 random_fl -1 1; #X obj 162 16 loadbang; #X obj 192 64 utime; #X obj 200 100 +; #X msg 200 124 seed \$1; #X obj 162 39 t b b b; #X obj 232 13 inlet; #X obj 120 65 t b b; #X msg 34 27 1000; #X msg 132 108 set \$1; #X obj 280 13 inlet; #X obj 178 165 random_icg -1 1; #X obj 34 192 tabwrite blor; #X connect 0 0 1 0; #X connect 1 0 3 0; #X connect 2 0 1 1; #X connect 3 0 4 0; #X connect 4 0 5 0; #X connect 4 1 17 1; #X connect 5 0 17 0; #X connect 6 0 10 0; #X connect 7 0 8 0; #X connect 7 1 8 1; #X connect 8 0 9 0; #X connect 9 0 5 0; #X connect 9 0 16 0; #X connect 10 0 12 0; #X connect 10 1 7 0; #X connect 11 0 12 0; #X connect 12 0 13 0; #X connect 12 1 2 0; #X connect 13 0 0 0; #X connect 14 0 13 0; #X connect 15 0 14 0; #X connect 16 0 17 0; #X restore 152 241 pd fillary; #X obj 21 175 tabwrite~ blir; #X msg 21 147 bang; #X obj 356 102 samplerate~; #X floatatom 356 126 5 0 0 0 - - -; #X obj 356 80 loadbang; #X floatatom 463 129 8 0 0 0 - - -; #X obj 64 150 +~ 0.1; #X floatatom 101 127 5 0 0 0 - - -; #X msg 152 218 bang; #X text 44 30 mean~ ; #X floatatom 160 160 5 0 0 0 - - -; #X obj 160 183 t f f; #X text 206 163 set arraysize; #X text 529 130 mean; #X text 43 10 this is supposed to calculate the signal mean of an array. ; #X msg 463 82 mean; #X msg 503 82 ad; #X msg 534 82 sd; #X obj 462 35 mean 1 2 3; #X floatatom 462 59 5 0 0 0 - - -; #X msg 462 13 1 2 3.6677; #X floatatom 271 305 8 0 0 0 - - -; #X msg 316 228 mean; #X msg 350 228 ad; #X obj 21 291 table blor; #X floatatom 341 325 10 0 0 0 - - -; #X floatatom 461 326 10 0 0 0 - - -; #X obj 392 150 loadbang; #X obj 316 272 t f f f; #X text 542 36 pd's mean; #X text 544 115 dont need this; #X msg 392 218 set \$1; #X obj 392 194 symbol; #X msg 392 173 blir; #X msg 429 173 blor; #X msg 20 214 \; blir resize \$1 \;; #X msg 113 270 \; blor resize \$1 \;; #X obj 460 304 cxstddev blir; #X obj 342 304 cxavgdev blir; #X obj 316 251 cxmean blir; #N canvas 567 269 494 344 META 0; #X text 12 135 HELP_PATCH_AUTHORS Jonathan Wilkes revised the patch to conform to the PDDP template for Pd version 0.42.; #X text 12 25 LICENSE GPL v2; #X text 12 115 AUTHOR jdl@xdv.org; #X text 12 5 KEYWORDS control array; #X text 12 45 DESCRIPTION this is supposed to calculate the signal mean of an array.; #X text 12 95 OUTLET_0 float; #X text 12 75 INLET_0 float set; #X restore 573 327 pd META; #X connect 0 0 10 0; #X connect 1 0 9 0; #X connect 5 0 4 0; #X connect 6 0 7 0; #X connect 8 0 6 0; #X connect 10 0 4 0; #X connect 11 0 10 1; #X connect 12 0 3 0; #X connect 14 0 15 0; #X connect 15 0 39 0; #X connect 15 0 40 0; #X connect 15 1 3 1; #X connect 19 0 1 0; #X connect 20 0 1 0; #X connect 21 0 1 0; #X connect 22 0 23 0; #X connect 24 0 22 0; #X connect 26 0 43 0; #X connect 27 0 43 0; #X connect 31 0 38 0; #X connect 32 0 25 0; #X connect 32 1 42 0; #X connect 32 2 41 0; #X connect 35 0 41 0; #X connect 35 0 42 0; #X connect 35 0 43 0; #X connect 36 0 35 0; #X connect 37 0 36 0; #X connect 38 0 36 0; #X connect 41 0 30 0; #X connect 42 0 29 0; #X connect 43 0 32 0; cxc-0.5.2/utime-help.pd0000644000076500007650000000131412076107577013362 0ustar hanshans#N canvas 0 31 347 149 10; #X obj 42 74 utime; #X msg 42 35 bang; #X floatatom 69 102 8 0 0 0 - - -; #X floatatom 42 129 20 0 0 0 - - -; #X text 25 8 output seconds since epoch and microsecond fraction; #N canvas 176 129 494 344 META 0; #X text 12 155 HELP_PATCH_AUTHORS Jonathan Wilkes revised the patch to conform to the PDDP template for Pd version 0.42.; #X text 12 5 KEYWORDS control time; #X text 12 45 DESCRIPTION output seconds since epoch and microsecond fraction; #X text 12 75 INLET_0 bang; #X text 12 95 OUTLET_0 float; #X text 12 115 OUTLET_1 float; #X text 12 25 LICENSE GPL v2; #X text 12 135 AUTHOR jdl@xdv.org; #X restore 297 128 pd META; #X connect 0 0 3 0; #X connect 0 1 2 0; #X connect 1 0 0 0; cxc-0.5.2/README.txt0000644000076500007650000000366412076107577012474 0ustar hanshans-------------------------- cxc pd eternals library powered by zt0ln d4ta -------------------------- USE AT YOUR OWN RISK! NO WARRANTY WHATSOEVER! THIS IS GPL SOFTWARE. see gpl.txt in this directory or http://www.gnu.org/licenses/gpl.txt etc blah blah ... install: ./configure --prefix=/path/to then type $ make $ make install (install cxc.pd_linux in $PREFIX/lib/pd/externs and documentation in $PREFIX/lib/pd/doc/5.refernce included objects: ixprint: print data on console without prefix (needed for ascwave) binshift: binary shift objects (<<,>>) ascseq: ascii-sequencer: input anything, which is output again sequentially character by character with a given delay ascwave: print funny ascii constructions on console bfilt alias bangfilter: re-output every argumen-th event useful for modulo-sequencers internal: modulo x -> sel 0 bfilt2: features internal counter, output just bangs counter: cloned out of markex so i dont need to load gem to have these reson: same as above cxc_prepend: prepend stuff with another symbol cxc_split: split incoming string at specified delimiter utime: output seconds since epoch and microsecond fraction random1, random_fl, random_icg, random_tw, dist_normal: various PRNG algorithms from http://remus.rutgers.edu/~rhoads/Code random1~, random_fl~, random_icg~: signal version of above algorithms ENV: get and set environment variables and certain defines like RAND_MAX proc: get stuff out of the linux proc directory (so far: cpuinfo, loadavg, version, uptime) delta~: emit distance to last sample as signal. cx.mean, cx.avgdev, cx.stddev: calculate mean, standard and average deviation of a signal in an array ---------------------------------------------------------------------- x_connective*.diffs: patch for pd-src to make receives have inlets and set method. see reference folder for objects in action jdl@xdv.org, 20030301 ------------------------------ references see REFERENCES file bla cxc-0.5.2/dist_normal-help.pd0000644000076500007650000001521612076107577014560 0ustar hanshans#N canvas 0 31 966 505 10; #X msg 197 150 bang; #X floatatom 244 150 5 0 0 0 - - -; #X floatatom 197 218 10 0 0 0 - - -; #X floatatom 53 162 5 0 0 0 - - -; #X msg 54 111 bang; #X floatatom 289 152 5 0 0 0 - - -; #X obj 53 135 random 100; #X msg 427 151 bang; #X floatatom 474 151 5 0 0 0 - - -; #X floatatom 427 219 10 0 0 0 - - -; #X floatatom 519 153 5 0 0 0 - - -; #X obj 196 183 random1 0 1; #X obj 426 184 random_fl 0 1; #X msg 672 152 bang; #X floatatom 719 152 5 0 0 0 - - -; #X floatatom 672 220 10 0 0 0 - - -; #X floatatom 764 154 5 0 0 0 - - -; #X obj 671 185 random_icg 0 1; #X msg 197 276 bang; #X floatatom 244 276 5 0 0 0 - - -; #X floatatom 197 344 10 0 0 0 - - -; #X floatatom 289 278 5 0 0 0 - - -; #X text 193 251 random_icg lowerlimit \, upperlimit; #X msg 368 288 help; #X obj 539 406 dist_normal; #X msg 540 356 bang; #X obj 579 357 metro 100; #X obj 579 337 tgl 15 0 empty empty empty 20 8 0 8 -262144 -1 -1 0 1; #X obj 196 309 random_tw 0 1; #X floatatom 637 334 5 0 0 0 - - -; #N canvas 0 0 600 400 streamview 0; #N canvas 0 0 450 300 (subpatch) 0; #X array randstream 100 float 0; #X coords 0 2 99 -2 200 140 1; #X restore 92 222 graph; #X obj 146 144 tabwrite randstream; #X obj 200 63 count; #X obj 200 88 % 100; #X obj 156 28 t f b; #X obj 49 15 inlet; #X connect 2 0 3 0; #X connect 3 0 1 1; #X connect 4 0 1 0; #X connect 4 1 2 0; #X connect 5 0 4 0; #X restore 570 433 pd streamview; #N canvas 306 24 679 400 distview 0; #N canvas 0 0 450 300 (subpatch) 0; #X array randview1 100 float 0; #X coords 0 200 99 0 400 200 1; #X restore 248 31 graph; #X obj 28 26 inlet; #X obj 45 355 tabwrite randview1; #X obj 136 201 * 100; #X obj 136 225 int; #X obj 136 153 + 2; #X obj 45 280 tabread randview1; #X obj 136 176 / 4; #X obj 136 250 t f f; #X obj 45 304 t f b; #X obj 45 329 + 1; #X obj 136 129 t f; #X connect 1 0 11 0; #X connect 3 0 4 0; #X connect 4 0 8 0; #X connect 5 0 7 0; #X connect 6 0 9 0; #X connect 7 0 3 0; #X connect 8 0 6 0; #X connect 8 1 2 1; #X connect 9 0 10 0; #X connect 10 0 2 0; #X connect 11 0 5 0; #X restore 550 458 pd distview; #X obj 540 381 t b; #X floatatom 477 430 5 0 0 0 - - -; #N canvas 0 0 600 400 seedit 0; #X msg 284 154 seed \$1; #X obj 284 107 utime; #X msg 304 74 bang; #X obj 254 28 loadbang; #X obj 284 130 * 1e+06; #X obj 360 167 until; #X msg 455 156 bang; #X obj 359 194 random 2.14748e+08; #X msg 359 267 seed \$1; #X msg 385 294 seed \$1; #X msg 412 318 seed \$1; #X msg 439 267 seed \$1; #X msg 466 293 seed \$1; #X obj 254 50 t b b; #X obj 195 155 print seed1; #X obj 143 360 outlet; #X obj 204 361 outlet; #X obj 264 361 outlet; #X obj 317 361 outlet; #X obj 367 361 outlet; #X text 35 9 seed one random obj \, which generates the seeds for all the others.; #X obj 359 218 serialize 6; #X msg 360 140 6; #X obj 359 242 unpack f f f f f f; #X msg 485 317 seed \$1; #X obj 420 359 outlet; #X connect 0 0 7 0; #X connect 1 1 4 0; #X connect 2 0 1 0; #X connect 3 0 13 0; #X connect 4 0 0 0; #X connect 4 0 14 0; #X connect 5 0 7 0; #X connect 6 0 7 0; #X connect 7 0 21 0; #X connect 8 0 15 0; #X connect 9 0 16 0; #X connect 10 0 17 0; #X connect 11 0 18 0; #X connect 12 0 19 0; #X connect 13 0 22 0; #X connect 13 1 1 0; #X connect 21 0 23 0; #X connect 22 0 5 0; #X connect 23 0 8 0; #X connect 23 1 9 0; #X connect 23 2 10 0; #X connect 23 3 11 0; #X connect 23 4 12 0; #X connect 23 5 24 0; #X connect 24 0 25 0; #X restore 258 33 pd seedit; #X text 37 79 std pd random; #X text 197 124 linear congruential generator; #X text 197 77 creation arguments for the extra randoms are:; #X text 205 92 \, defaults to 0 respectively RAND_MAX; #X text 545 17 see also:; #X obj 545 40 utime; #X text 428 129 another lcg method ..; #X text 668 127 inverse linear congruential generator; #X text 536 249 normal distribution mean 0 and dist 1; #X text 536 264 right now it uses random1 for the actual rand values ; #X text 537 278 but later on it should take one of the randoms as creation argument \, so yu can specify which generator is being used.; #X text 198 106 they all output floats); #X text 540 311 also \, there is some burst at the upper and lower limits; #N canvas 198 89 592 356 signalversions 0; #X obj 68 131 random1~; #X obj 368 239 tabwrite~ randomix_test; #N canvas 0 0 450 300 (subpatch) 0; #X array randomix_test 64 float 1; #A 0 -0.599965 0.178987 -0.501604 -1.10592 0.426163 -0.481499 -0.553236 0.0961931 0.554738 -0.695487 0.541875 -0.415309 -0.419922 -0.871908 0.0688377 -1.03721 -0.136159 -0.207339 -1.18947 -0.25981 -0.628915 -0.826873 0.334755 -0.738558 -0.0926691 -0.262739 0.309148 0.50131 -1.40461 -0.859907 0.621724 -0.888718 0.692579 -1.11799 0.162897 0.116501 -0.390333 0.327364 -0.902445 -0.201419 0.300071 -1.10817 -1.09973 0.34181 -0.0511739 -0.613584 -0.306316 0.433381 -0.154481 -1.17821 -0.428187 -0.449014 -1.04248 -0.906665 0.0687456 -1.08289 0.59097 0.0438875 -1.20429 0.0862183 -0.995607 0.585034 0.205198 -0.337256; #X coords 0 1 63 -1 200 140 1; #X restore 351 23 graph; #X obj 382 183 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0 1; #X floatatom 440 184 5 0 0 0 - - -; #X obj 382 201 metro 100; #X msg 342 201 bang; #X obj 73 295 dac~; #X floatatom 140 220 5 0 0 0 - - -; #X msg 68 58 seed 30000; #X obj 142 131 random_fl~; #X text 120 98 etc ..; #X obj 229 131 random_icg~; #X obj 81 241 fader 75; #X connect 0 0 13 0; #X connect 3 0 5 0; #X connect 4 0 5 1; #X connect 5 0 1 0; #X connect 6 0 1 0; #X connect 8 0 13 2; #X connect 9 0 0 0; #X connect 10 0 13 1; #X connect 12 0 1 0; #X connect 12 0 13 0; #X connect 13 0 7 0; #X connect 13 1 7 1; #X restore 98 421 pd signalversions; #N canvas 739 383 494 344 META 0; #X text 12 145 HELP_PATCH_AUTHORS Jonathan Wilkes revised the patch to conform to the PDDP template for Pd version 0.42.; #X text 12 25 LICENSE GPL v2; #X text 12 125 AUTHOR jdl@xdv.org; #X text 12 105 OUTLET_0 float; #X text 12 65 INLET_0 bang; #X text 12 85 INLET_1 float; #X text 12 5 KEYWORDS control random; #X text 12 45 DESCRIPTION normal distribution mean; #X restore 903 467 pd META; #X text 253 10 the random number generators; #X connect 0 0 11 0; #X connect 1 0 11 1; #X connect 4 0 6 0; #X connect 5 0 11 2; #X connect 6 0 3 0; #X connect 7 0 12 0; #X connect 8 0 12 1; #X connect 10 0 12 2; #X connect 11 0 2 0; #X connect 12 0 9 0; #X connect 13 0 17 0; #X connect 14 0 17 1; #X connect 16 0 17 2; #X connect 17 0 15 0; #X connect 18 0 28 0; #X connect 19 0 28 1; #X connect 21 0 28 2; #X connect 23 0 28 0; #X connect 24 0 30 0; #X connect 24 0 31 0; #X connect 24 0 33 0; #X connect 25 0 32 0; #X connect 26 0 32 0; #X connect 27 0 26 0; #X connect 28 0 20 0; #X connect 29 0 26 1; #X connect 32 0 24 0; #X connect 34 0 6 0; #X connect 34 1 11 0; #X connect 34 2 12 0; #X connect 34 3 17 0; #X connect 34 4 28 0; cxc-0.5.2/REFERENCES0000644000076500007650000000013712076107577012332 0ustar hanshans-www,dspguide.com -lena.ucsd.edu/~msp/ -gige.xdv.org/pd -ftp://iem.kug.ac.at/pd/Externals/ZEXY cxc-0.5.2/bfilt.c0000644000076500007650000000207012076107577012230 0ustar hanshans/* bangfilter: = % x plus sel 0 * spaeter: % x plus sel y mit 2 arguments */ #include "m_pd.h" #include static t_class *bfilt_class; typedef struct _bfilt { t_object x_obj; t_float x_f1; t_float x_f2; } t_bfilt; static void *bfilt_new(t_floatarg f) { t_bfilt *x = (t_bfilt *)pd_new(bfilt_class); outlet_new(&x->x_obj, &s_bang); floatinlet_new(&x->x_obj, &x->x_f2); x->x_f1 = 0; x->x_f2 = f; return (x); } static void bfilt_bang(t_bfilt *x) { int n2 = x->x_f2, result; if (n2 < 0) n2 = -n2; else if (!n2) n2 = 1; result = ((int)(x->x_f1)) % n2; if (result == 0) //result += n2; { outlet_bang(x->x_obj.ob_outlet); } //outlet_float(x->x_obj.ob_outlet, (t_float)result); } static void bfilt_float(t_bfilt *x, t_float f) { x->x_f1 = f; bfilt_bang(x); } void bfilt_setup() { bfilt_class = class_new(gensym("bfilt"), (t_newmethod)bfilt_new, 0, sizeof(t_bfilt), 0, A_DEFFLOAT, 0); class_addbang(bfilt_class, bfilt_bang); class_addfloat(bfilt_class, (t_method)bfilt_float); } cxc-0.5.2/cxavgdev-help.pd0000644000076500007650000000635612076107577014061 0ustar hanshans#N canvas 0 31 636 364 10; #X obj 64 102 noise~; #X obj 463 105 mean~ blir; #X obj 21 262 table blir; #N canvas 162 270 331 246 fillary 0; #X obj 34 53 until; #X obj 34 79 count; #X msg 85 27 bang; #X obj 34 105 - 1; #X obj 34 130 t b f; #X obj 34 166 random_fl -1 1; #X obj 162 16 loadbang; #X obj 192 64 utime; #X obj 200 100 +; #X msg 200 124 seed \$1; #X obj 162 39 t b b b; #X obj 232 13 inlet; #X obj 120 65 t b b; #X msg 34 27 1000; #X msg 132 108 set \$1; #X obj 280 13 inlet; #X obj 178 165 random_icg -1 1; #X obj 34 192 tabwrite blor; #X connect 0 0 1 0; #X connect 1 0 3 0; #X connect 2 0 1 1; #X connect 3 0 4 0; #X connect 4 0 5 0; #X connect 4 1 17 1; #X connect 5 0 17 0; #X connect 6 0 10 0; #X connect 7 0 8 0; #X connect 7 1 8 1; #X connect 8 0 9 0; #X connect 9 0 5 0; #X connect 9 0 16 0; #X connect 10 0 12 0; #X connect 10 1 7 0; #X connect 11 0 12 0; #X connect 12 0 13 0; #X connect 12 1 2 0; #X connect 13 0 0 0; #X connect 14 0 13 0; #X connect 15 0 14 0; #X connect 16 0 17 0; #X restore 152 241 pd fillary; #X obj 21 175 tabwrite~ blir; #X msg 21 147 bang; #X obj 356 102 samplerate~; #X floatatom 356 126 5 0 0 0 - - -; #X obj 356 80 loadbang; #X floatatom 463 129 8 0 0 0 - - -; #X obj 64 150 +~ 0.1; #X floatatom 101 127 5 0 0 0 - - -; #X msg 152 218 bang; #X text 44 30 mean~ ; #X floatatom 160 160 5 0 0 0 - - -; #X obj 160 183 t f f; #X text 206 163 set arraysize; #X text 529 130 mean; #X text 43 10 this is supposed to calculate the signal mean of an array. ; #X msg 463 82 mean; #X msg 503 82 ad; #X msg 534 82 sd; #X obj 462 35 mean 1 2 3; #X floatatom 462 59 5 0 0 0 - - -; #X msg 462 13 1 2 3.6677; #X floatatom 271 305 8 0 0 0 - - -; #X msg 316 228 mean; #X msg 350 228 ad; #X obj 21 291 table blor; #X floatatom 341 325 10 0 0 0 - - -; #X floatatom 461 326 10 0 0 0 - - -; #X obj 392 150 loadbang; #X obj 316 272 t f f f; #X text 542 36 pd's mean; #X text 544 115 dont need this; #X msg 392 218 set \$1; #X obj 392 194 symbol; #X msg 392 173 blir; #X msg 429 173 blor; #X msg 20 214 \; blir resize \$1 \;; #X msg 113 270 \; blor resize \$1 \;; #X obj 460 304 cxstddev blir; #X obj 342 304 cxavgdev blir; #X obj 316 251 cxmean blir; #N canvas 567 269 494 344 META 0; #X text 12 135 HELP_PATCH_AUTHORS Jonathan Wilkes revised the patch to conform to the PDDP template for Pd version 0.42.; #X text 12 25 LICENSE GPL v2; #X text 12 115 AUTHOR jdl@xdv.org; #X text 12 5 KEYWORDS control array; #X text 12 45 DESCRIPTION this is supposed to calculate the signal mean of an array.; #X text 12 95 OUTLET_0 float; #X text 12 75 INLET_0 float set; #X restore 583 337 pd META; #X connect 0 0 10 0; #X connect 1 0 9 0; #X connect 5 0 4 0; #X connect 6 0 7 0; #X connect 8 0 6 0; #X connect 10 0 4 0; #X connect 11 0 10 1; #X connect 12 0 3 0; #X connect 14 0 15 0; #X connect 15 0 39 0; #X connect 15 0 40 0; #X connect 15 1 3 1; #X connect 19 0 1 0; #X connect 20 0 1 0; #X connect 21 0 1 0; #X connect 22 0 23 0; #X connect 24 0 22 0; #X connect 26 0 43 0; #X connect 27 0 43 0; #X connect 31 0 38 0; #X connect 32 0 25 0; #X connect 32 1 42 0; #X connect 32 2 41 0; #X connect 35 0 41 0; #X connect 35 0 42 0; #X connect 35 0 43 0; #X connect 36 0 35 0; #X connect 37 0 36 0; #X connect 38 0 36 0; #X connect 41 0 30 0; #X connect 42 0 29 0; #X connect 43 0 32 0; cxc-0.5.2/random1.c0000644000076500007650000001067612076107577012504 0ustar hanshans/* (c) 2002:cxc@web.fm randomix: various PRNG's code taken from: http://remus.rutgers.edu/%7Erhoads/Code/code.html let's check it out */ #include #include #include #define SMALLEST_RANGE .0001 #ifndef RAND_MAX #define RAND_MAX 2147483647 #endif static int makeseed(void); static int rand_random1(int); static int makeseed(void) { static unsigned int random1_nextseed = 1489853723; random1_nextseed = random1_nextseed * 435898247 + 938284287; return (random1_nextseed & 0x7fffffff); } /* -------------------------- random1 ------------------------------ */ /* linear congruential generator. Generator x[n+1] = a * x[n] mod m */ static int rand_random1(seed) { int state; //unsigned int a = 1588635695, m = 4294967291U, q = 2, r = 1117695901; // unsigned int a = 1588635695, m = (RAND_MAX * 2), q = 2, r = 1117695901; /* static unsigned int a = 1223106847, m = 4294967291U, q = 3, r = 625646750;*/ /* static unsigned int a = 279470273, m = 4294967291U, q = 15, r = 102913196;*/ //static unsigned int a = 1583458089, m = 2147483647, q = 1, r = 564025558; static unsigned int a = 784588716, m = 2147483647, q = 2, r = 578306215; /* static unsigned int a = 16807, m = 2147483647, q = 127773, r = 2836; */ /* static unsigned int a = 950706376, m = 2147483647, q = 2, r = 246070895; */ //state = (seed) ? seed : makeseed(); state = seed; state = a*(state % q) - r*(state / q); return (state); } /* -------------------------- random1 ------------------------------ */ /* linear congruential generator. Generator x[n+1] = a * x[n] mod m */ static t_class *random1_class; typedef struct _random1 { t_object x_obj; t_float x_f; // lower limit t_float x_g; // upper limit unsigned int x_state; // current seed } t_random1; static void *random1_new(t_floatarg f, t_floatarg g) { t_random1 *x = (t_random1 *)pd_new(random1_class); x->x_f = (f) ? f : 0; x->x_g = (g) ? g : RAND_MAX; //post("cxc/randomix.c: lolim: %f - %f, uplim: %f - %f", x->x_f, f, x->x_g, g); x->x_state = makeseed(); inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_float, gensym("fl1")); inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_float, gensym("fl2")); outlet_new(&x->x_obj, &s_float); return (x); } /* -------------------------- random_fl ------------------------------ */ /* An improved (faster) implementation of the Linear Congruential Generator. Has parameters for 6 separate */ /* linear congruence formulas. These formulas are different than those above because the previous formulas won't work */ /* correctly in this implementation. Also, this method only works if your floating point mantissa has at least 53 bits. */ /* linear congruential generator. Generator x[n+1] = a * x[n] mod m */ /* works if your floating pt. mantissa has at least 53 bits. faster than other versions */ static void random1_bang(t_random1 *x) { int n = x->x_f; double nval; unsigned int m; // this seems weird? m = (RAND_MAX * 2); // unsigned int a = 1588635695, m = 4294967291U, q = 2, r = 1117695901; // post("cxc/randomix.c: x_state: %d",x->x_state); x->x_state = rand_random1(x->x_state); nval = ((double)x->x_state / (double)m) * (double)(x->x_g - x->x_f) + (double)x->x_f; // post("cxc/randomix.c: lolim: %f, uplim: %f", x->x_f, x->x_g); // post("cxc/randomix.c: nval: %f",nval); outlet_float(x->x_obj.ob_outlet, nval); } void random1_low(t_random1 *x, t_floatarg f) { if(f >= x->x_g) { post("cxc/randomix.c: lower larger than upper, setting to upper - %f = %f", SMALLEST_RANGE, x->x_g - SMALLEST_RANGE); x->x_f = x->x_g - SMALLEST_RANGE; } else x->x_f = f; } void random1_upp(t_random1 *x, t_floatarg f) { if(f <= x->x_f) { post("cxc/randomix.c: upper smaller than lower, setting to lower + %f = %f", SMALLEST_RANGE, x->x_f + SMALLEST_RANGE); x->x_g = x->x_f + SMALLEST_RANGE; } else x->x_g = f; } static void random1_seed(t_random1 *x, float f, float glob) { x->x_state = f; } void random1_setup(void) { random1_class = class_new(gensym("random1"), (t_newmethod)random1_new, 0, sizeof(t_random1), 0, A_DEFFLOAT, A_DEFFLOAT, 0); class_addbang(random1_class, random1_bang); class_addmethod(random1_class, (t_method)random1_low, gensym("fl1"), A_FLOAT, 0); class_addmethod(random1_class, (t_method)random1_upp, gensym("fl2"), A_FLOAT, 0); class_addmethod(random1_class, (t_method)random1_seed, gensym("seed"), A_FLOAT, 0); } cxc-0.5.2/TODO0000644000076500007650000000132012076107577011451 0ustar hanshans -real autoconf enable -scaler -event_quantize -autosequ -htget/curl -/dev/random -/proc + other system data // done 20020321 * handle SMP systems (cpuinfo) -eth (network device statistics) -distribution: randomix.c: add double gaussrand() to that file with callback or something .. ? add this one: http://www.counterpane.com/yarrow.html -libpcap wrapper -statistics *mean *average + standard deviation (sliced (param) for non-stationary signals?) *histogram *ascii2sig *delta~ (difference between last 2 samples) *sigrandomix -serialize seems to have bug on resize .. ----- -delta~ -histo (pmf,pdf,mean,ad,sd) -random~ -rand swap~: byteshuffle~ or byteshift~ ... cxc-0.5.2/cxmean.c0000644000076500007650000000002312076107577012377 0ustar hanshans#include "mean~.c" cxc-0.5.2/proc-help.pd0000644000076500007650000000524412076107577013210 0ustar hanshans#N canvas 0 31 658 496 10; #X obj 151 118 proc; #X text 96 15 interface to the linux proc filesystem; #X msg 88 80 cpuinfo; #X obj 27 281 unpack f f f; #X floatatom 25 304 5 0 0 0 - - -; #X floatatom 67 305 5 0 0 0 - - -; #X floatatom 109 304 5 0 0 0 - - -; #X text 37 254 cpu-id \, cpu-mhz \, bogomips; #X obj 151 147 print proc_raw; #X msg 151 94 proc \$1; #X obj 151 71 symbol; #X msg 123 38 cpuinfo; #X msg 183 38 uptime; #X msg 351 38 stat; #X msg 389 38 blubb; #X obj 242 276 unpack f f; #X text 241 255 uptime in s \, idle-time in s; #X floatatom 241 301 5 0 0 0 - - -; #X floatatom 302 305 5 0 0 0 - - -; #X msg 237 38 loadavg; #X msg 297 39 version; #X obj 174 349 unpack f f f f f f; #X floatatom 172 373 5 0 0 0 - - -; #X floatatom 187 397 5 0 0 0 - - -; #X floatatom 220 373 5 0 0 0 - - -; #X floatatom 238 397 5 0 0 0 - - -; #X floatatom 271 372 5 0 0 0 - - -; #X floatatom 289 396 5 0 0 0 - - -; #X text 315 345 apparently the loadavg format is something liek this ; #X text 318 359 my manpage seems outdated ...; #X text 330 379 1: number of jobs in the run queue (1'); #X text 340 394 2: numofjobs in R qu (5'); #X text 348 411 3: numofjobs in R qu (15'); #X text 339 425 4: num of procs waiting for disk io?; #X text 339 452 6: num of processes ever total; #X text 339 438 5: num of processes now total; #X obj 27 234 route cpuinfo uptime loadavg version stat; #X obj 458 241 unpack f f f; #X floatatom 458 267 5 0 0 0 - - -; #X floatatom 484 293 5 0 0 0 - - -; #X floatatom 516 266 5 0 0 0 - - -; #X text 462 215 uname -r; #X text 307 82 really useless stuff but maybe good for estimating number of voices in self-generating patches; #N canvas 176 129 494 344 META 0; #X text 12 145 HELP_PATCH_AUTHORS Jonathan Wilkes revised the patch to conform to the PDDP template for Pd version 0.42.; #X text 12 5 GENRE help; #X text 12 25 KEYWORDS control filesystem; #X text 12 65 DESCRIPTION interface to the linux proc filesystem; #X text 12 85 INLET_0 anything; #X text 12 105 OUTLET_0 anything; #X text 12 45 LICENSE GPL v2; #X text 12 125 AUTHOR jdl@xdv.org; #X restore 605 473 pd META; #X connect 0 0 8 0; #X connect 0 0 36 0; #X connect 2 0 0 0; #X connect 3 0 4 0; #X connect 3 1 5 0; #X connect 3 2 6 0; #X connect 9 0 0 0; #X connect 10 0 9 0; #X connect 11 0 10 0; #X connect 12 0 10 0; #X connect 13 0 10 0; #X connect 14 0 10 0; #X connect 15 0 17 0; #X connect 15 1 18 0; #X connect 19 0 10 0; #X connect 20 0 10 0; #X connect 21 0 22 0; #X connect 21 1 23 0; #X connect 21 2 24 0; #X connect 21 3 25 0; #X connect 21 4 26 0; #X connect 21 5 27 0; #X connect 36 0 3 0; #X connect 36 1 15 0; #X connect 36 2 21 0; #X connect 36 3 37 0; #X connect 37 0 38 0; #X connect 37 1 39 0; #X connect 37 2 40 0; cxc-0.5.2/cxc-meta.pd0000644000076500007650000000052512076107577013015 0ustar hanshans#N canvas 10 10 200 200 10; #N canvas 20 20 420 300 META 0; #X text 10 10 META this is a prototype of a libdir meta file; #X text 10 30 NAME cxc; #X text 10 50 AUTHOR jdl@xdv.org; #X text 10 70 DESCRIPTION library of randoms \, averages \, and system tools; #X text 10 90 LICENSE GPL; #X text 10 110 VERSION 0.5.2; #X restore 10 10 pd META; cxc-0.5.2/LICENSE.txt0000644000076500007650000004325412076107577012620 0ustar hanshans GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Lesser General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. cxc-0.5.2/random1-help.pd0000644000076500007650000001530212076107577013602 0ustar hanshans#N canvas 0 31 966 505 10; #X msg 197 150 bang; #X floatatom 244 150 5 0 0 0 - - -; #X floatatom 197 218 10 0 0 0 - - -; #X floatatom 53 162 5 0 0 0 - - -; #X msg 54 111 bang; #X floatatom 289 152 5 0 0 0 - - -; #X obj 53 135 random 100; #X msg 427 151 bang; #X floatatom 474 151 5 0 0 0 - - -; #X floatatom 427 219 10 0 0 0 - - -; #X floatatom 519 153 5 0 0 0 - - -; #X obj 196 183 random1 0 1; #X obj 426 184 random_fl 0 1; #X msg 672 152 bang; #X floatatom 719 152 5 0 0 0 - - -; #X floatatom 672 220 10 0 0 0 - - -; #X floatatom 764 154 5 0 0 0 - - -; #X obj 671 185 random_icg 0 1; #X msg 197 276 bang; #X floatatom 244 276 5 0 0 0 - - -; #X floatatom 197 344 10 0 0 0 - - -; #X floatatom 289 278 5 0 0 0 - - -; #X text 193 251 random_icg lowerlimit \, upperlimit; #X msg 368 288 help; #X text 253 10 the random number generatorse; #X obj 539 406 dist_normal; #X msg 540 356 bang; #X obj 579 357 metro 100; #X obj 579 337 tgl 15 0 empty empty empty 20 8 0 8 -262144 -1 -1 0 1; #X obj 196 309 random_tw 0 1; #X floatatom 637 334 5 0 0 0 - - -; #N canvas 0 0 600 400 streamview 0; #N canvas 0 0 450 300 (subpatch) 0; #X array randstream 100 float 0; #X coords 0 2 99 -2 200 140 1; #X restore 92 222 graph; #X obj 146 144 tabwrite randstream; #X obj 200 63 count; #X obj 200 88 % 100; #X obj 156 28 t f b; #X obj 49 15 inlet; #X connect 2 0 3 0; #X connect 3 0 1 1; #X connect 4 0 1 0; #X connect 4 1 2 0; #X connect 5 0 4 0; #X restore 570 433 pd streamview; #N canvas 306 24 679 400 distview 0; #N canvas 0 0 450 300 (subpatch) 0; #X array randview1 100 float 0; #X coords 0 200 99 0 400 200 1; #X restore 248 31 graph; #X obj 28 26 inlet; #X obj 45 355 tabwrite randview1; #X obj 136 201 * 100; #X obj 136 225 int; #X obj 136 153 + 2; #X obj 45 280 tabread randview1; #X obj 136 176 / 4; #X obj 136 250 t f f; #X obj 45 304 t f b; #X obj 45 329 + 1; #X obj 136 129 t f; #X connect 1 0 11 0; #X connect 3 0 4 0; #X connect 4 0 8 0; #X connect 5 0 7 0; #X connect 6 0 9 0; #X connect 7 0 3 0; #X connect 8 0 6 0; #X connect 8 1 2 1; #X connect 9 0 10 0; #X connect 10 0 2 0; #X connect 11 0 5 0; #X restore 550 458 pd distview; #X obj 540 381 t b; #X floatatom 477 430 5 0 0 0 - - -; #N canvas 0 0 600 400 seedit 0; #X msg 284 154 seed \$1; #X obj 284 107 utime; #X msg 304 74 bang; #X obj 254 28 loadbang; #X obj 284 130 * 1e+06; #X obj 360 167 until; #X msg 455 156 bang; #X obj 359 194 random 2.14748e+08; #X msg 359 267 seed \$1; #X msg 385 294 seed \$1; #X msg 412 318 seed \$1; #X msg 439 267 seed \$1; #X msg 466 293 seed \$1; #X obj 254 50 t b b; #X obj 195 155 print seed1; #X obj 143 360 outlet; #X obj 204 361 outlet; #X obj 264 361 outlet; #X obj 317 361 outlet; #X obj 367 361 outlet; #X text 35 9 seed one random obj \, which generates the seeds for all the others.; #X obj 359 218 serialize 6; #X msg 360 140 6; #X obj 359 242 unpack f f f f f f; #X msg 485 317 seed \$1; #X obj 420 359 outlet; #X connect 0 0 7 0; #X connect 1 1 4 0; #X connect 2 0 1 0; #X connect 3 0 13 0; #X connect 4 0 0 0; #X connect 4 0 14 0; #X connect 5 0 7 0; #X connect 6 0 7 0; #X connect 7 0 21 0; #X connect 8 0 15 0; #X connect 9 0 16 0; #X connect 10 0 17 0; #X connect 11 0 18 0; #X connect 12 0 19 0; #X connect 13 0 22 0; #X connect 13 1 1 0; #X connect 21 0 23 0; #X connect 22 0 5 0; #X connect 23 0 8 0; #X connect 23 1 9 0; #X connect 23 2 10 0; #X connect 23 3 11 0; #X connect 23 4 12 0; #X connect 23 5 24 0; #X connect 24 0 25 0; #X restore 258 33 pd seedit; #X text 37 79 std pd random; #X text 197 124 linear congruential generator; #X text 197 77 creation arguments for the extra randoms are:; #X text 205 92 \, defaults to 0 respectively RAND_MAX; #X text 545 17 see also:; #X obj 545 40 utime; #X text 428 129 another lcg method ..; #X text 668 127 inverse linear congruential generator; #X text 536 249 normal distribution mean 0 and dist 1; #X text 536 264 right now it uses random1 for the actual rand values ; #X text 537 278 but later on it should take one of the randoms as creation argument \, so yu can specify which generator is being used.; #X text 198 106 they all output floats); #X text 540 311 also \, there is some burst at the upper and lower limits; #N canvas 289 428 592 356 signalversions 0; #X obj 68 131 random1~; #N canvas 0 0 450 300 (subpatch) 0; #X array \$0-randomix_test 64 float 1; #A 0 -0.599965 0.178987 -0.501604 -1.10592 0.426163 -0.481499 -0.553236 0.0961931 0.554738 -0.695487 0.541875 -0.415309 -0.419922 -0.871908 0.0688377 -1.03721 -0.136159 -0.207339 -1.18947 -0.25981 -0.628915 -0.826873 0.334755 -0.738558 -0.0926691 -0.262739 0.309148 0.50131 -1.40461 -0.859907 0.621724 -0.888718 0.692579 -1.11799 0.162897 0.116501 -0.390333 0.327364 -0.902445 -0.201419 0.300071 -1.10817 -1.09973 0.34181 -0.0511739 -0.613584 -0.306316 0.433381 -0.154481 -1.17821 -0.428187 -0.449014 -1.04248 -0.906665 0.0687456 -1.08289 0.59097 0.0438875 -1.20429 0.0862183 -0.995607 0.585034 0.205198 -0.337256; #X coords 0 1 63 -1 200 140 1; #X restore 351 23 graph; #X obj 382 183 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0 1; #X floatatom 440 184 5 0 0 0 - - -; #X obj 382 201 metro 100; #X msg 342 201 bang; #X obj 73 295 dac~; #X floatatom 140 220 5 0 0 0 - - -; #X msg 68 58 seed 30000; #X obj 142 131 random_fl~; #X text 120 98 etc ..; #X obj 229 131 random_icg~; #X obj 81 241 fader 75; #X obj 368 239 tabwrite~ \$0-randomix_test; #X connect 0 0 12 0; #X connect 2 0 4 0; #X connect 3 0 4 1; #X connect 4 0 13 0; #X connect 5 0 13 0; #X connect 7 0 12 2; #X connect 8 0 0 0; #X connect 9 0 12 1; #X connect 11 0 12 0; #X connect 11 0 13 0; #X connect 12 0 6 0; #X connect 12 1 6 1; #X restore 98 421 pd signalversions; #N canvas 645 314 494 359 META 0; #X text 12 165 HELP_PATCH_AUTHORS Jonathan Wilkes revised the patch to conform to the PDDP template for Pd version 0.42.; #X text 12 25 LICENSE GPL v2; #X text 12 145 AUTHOR jdl@xdv.org; #X text 12 125 OUTLET_0 float; #X text 12 65 INLET_0 bang seed; #X text 12 85 INLET_1 float; #X text 12 105 INLET_2 float; #X text 12 5 KEYWORDS control random; #X text 12 45 DESCRIPTION linear congruential generator; #X restore 905 472 pd META; #X connect 0 0 11 0; #X connect 1 0 11 1; #X connect 4 0 6 0; #X connect 5 0 11 2; #X connect 6 0 3 0; #X connect 7 0 12 0; #X connect 8 0 12 1; #X connect 10 0 12 2; #X connect 11 0 2 0; #X connect 12 0 9 0; #X connect 13 0 17 0; #X connect 14 0 17 1; #X connect 16 0 17 2; #X connect 17 0 15 0; #X connect 18 0 29 0; #X connect 19 0 29 1; #X connect 21 0 29 2; #X connect 23 0 29 0; #X connect 25 0 31 0; #X connect 25 0 32 0; #X connect 25 0 34 0; #X connect 26 0 33 0; #X connect 27 0 33 0; #X connect 28 0 27 0; #X connect 29 0 20 0; #X connect 30 0 27 1; #X connect 33 0 25 0; #X connect 35 0 6 0; #X connect 35 1 11 0; #X connect 35 2 12 0; #X connect 35 3 17 0; #X connect 35 4 29 0; cxc-0.5.2/random1~-help.pd0000644000076500007650000001520012076107577013775 0ustar hanshans#N canvas 0 31 966 505 10; #X msg 197 150 bang; #X floatatom 244 150 5 0 0 0 - - -; #X floatatom 197 218 10 0 0 0 - - -; #X floatatom 53 162 5 0 0 0 - - -; #X msg 54 111 bang; #X floatatom 289 152 5 0 0 0 - - -; #X obj 53 135 random 100; #X msg 427 151 bang; #X floatatom 474 151 5 0 0 0 - - -; #X floatatom 427 219 10 0 0 0 - - -; #X floatatom 519 153 5 0 0 0 - - -; #X obj 196 183 random1 0 1; #X obj 426 184 random_fl 0 1; #X msg 672 152 bang; #X floatatom 719 152 5 0 0 0 - - -; #X floatatom 672 220 10 0 0 0 - - -; #X floatatom 764 154 5 0 0 0 - - -; #X obj 671 185 random_icg 0 1; #X msg 197 276 bang; #X floatatom 244 276 5 0 0 0 - - -; #X floatatom 197 344 10 0 0 0 - - -; #X floatatom 289 278 5 0 0 0 - - -; #X text 193 251 random_icg lowerlimit \, upperlimit; #X msg 368 288 help; #X text 253 10 the random number generatorse; #X obj 539 406 dist_normal; #X msg 540 356 bang; #X obj 579 357 metro 100; #X obj 579 337 tgl 15 0 empty empty empty 20 8 0 8 -262144 -1 -1 0 1; #X obj 196 309 random_tw 0 1; #X floatatom 637 334 5 0 0 0 - - -; #N canvas 0 0 600 400 streamview 0; #N canvas 0 0 450 300 (subpatch) 0; #X array randstream 100 float 0; #X coords 0 2 99 -2 200 140 1; #X restore 92 222 graph; #X obj 146 144 tabwrite randstream; #X obj 200 63 count; #X obj 200 88 % 100; #X obj 156 28 t f b; #X obj 49 15 inlet; #X connect 2 0 3 0; #X connect 3 0 1 1; #X connect 4 0 1 0; #X connect 4 1 2 0; #X connect 5 0 4 0; #X restore 570 433 pd streamview; #N canvas 306 24 679 400 distview 0; #N canvas 0 0 450 300 (subpatch) 0; #X array randview1 100 float 0; #X coords 0 200 99 0 400 200 1; #X restore 248 31 graph; #X obj 28 26 inlet; #X obj 45 355 tabwrite randview1; #X obj 136 201 * 100; #X obj 136 225 int; #X obj 136 153 + 2; #X obj 45 280 tabread randview1; #X obj 136 176 / 4; #X obj 136 250 t f f; #X obj 45 304 t f b; #X obj 45 329 + 1; #X obj 136 129 t f; #X connect 1 0 11 0; #X connect 3 0 4 0; #X connect 4 0 8 0; #X connect 5 0 7 0; #X connect 6 0 9 0; #X connect 7 0 3 0; #X connect 8 0 6 0; #X connect 8 1 2 1; #X connect 9 0 10 0; #X connect 10 0 2 0; #X connect 11 0 5 0; #X restore 550 458 pd distview; #X obj 540 381 t b; #X floatatom 477 430 5 0 0 0 - - -; #N canvas 0 0 600 400 seedit 0; #X msg 284 154 seed \$1; #X obj 284 107 utime; #X msg 304 74 bang; #X obj 254 28 loadbang; #X obj 284 130 * 1e+06; #X obj 360 167 until; #X msg 455 156 bang; #X obj 359 194 random 2.14748e+08; #X msg 359 267 seed \$1; #X msg 385 294 seed \$1; #X msg 412 318 seed \$1; #X msg 439 267 seed \$1; #X msg 466 293 seed \$1; #X obj 254 50 t b b; #X obj 195 155 print seed1; #X obj 143 360 outlet; #X obj 204 361 outlet; #X obj 264 361 outlet; #X obj 317 361 outlet; #X obj 367 361 outlet; #X text 35 9 seed one random obj \, which generates the seeds for all the others.; #X obj 359 218 serialize 6; #X msg 360 140 6; #X obj 359 242 unpack f f f f f f; #X msg 485 317 seed \$1; #X obj 420 359 outlet; #X connect 0 0 7 0; #X connect 1 1 4 0; #X connect 2 0 1 0; #X connect 3 0 13 0; #X connect 4 0 0 0; #X connect 4 0 14 0; #X connect 5 0 7 0; #X connect 6 0 7 0; #X connect 7 0 21 0; #X connect 8 0 15 0; #X connect 9 0 16 0; #X connect 10 0 17 0; #X connect 11 0 18 0; #X connect 12 0 19 0; #X connect 13 0 22 0; #X connect 13 1 1 0; #X connect 21 0 23 0; #X connect 22 0 5 0; #X connect 23 0 8 0; #X connect 23 1 9 0; #X connect 23 2 10 0; #X connect 23 3 11 0; #X connect 23 4 12 0; #X connect 23 5 24 0; #X connect 24 0 25 0; #X restore 258 33 pd seedit; #X text 37 79 std pd random; #X text 197 124 linear congruential generator; #X text 197 77 creation arguments for the extra randoms are:; #X text 205 92 \, defaults to 0 respectively RAND_MAX; #X text 545 17 see also:; #X obj 545 40 utime; #X text 428 129 another lcg method ..; #X text 668 127 inverse linear congruential generator; #X text 536 249 normal distribution mean 0 and dist 1; #X text 536 264 right now it uses random1 for the actual rand values ; #X text 537 278 but later on it should take one of the randoms as creation argument \, so yu can specify which generator is being used.; #X text 198 106 they all output floats); #X text 540 311 also \, there is some burst at the upper and lower limits; #N canvas 217 91 592 356 signalversions 0; #X obj 68 131 random1~; #N canvas 0 0 450 300 (subpatch) 0; #X array \$0-randomix_test 64 float 1; #A 0 -0.599965 0.178987 -0.501604 -1.10592 0.426163 -0.481499 -0.553236 0.0961931 0.554738 -0.695487 0.541875 -0.415309 -0.419922 -0.871908 0.0688377 -1.03721 -0.136159 -0.207339 -1.18947 -0.25981 -0.628915 -0.826873 0.334755 -0.738558 -0.0926691 -0.262739 0.309148 0.50131 -1.40461 -0.859907 0.621724 -0.888718 0.692579 -1.11799 0.162897 0.116501 -0.390333 0.327364 -0.902445 -0.201419 0.300071 -1.10817 -1.09973 0.34181 -0.0511739 -0.613584 -0.306316 0.433381 -0.154481 -1.17821 -0.428187 -0.449014 -1.04248 -0.906665 0.0687456 -1.08289 0.59097 0.0438875 -1.20429 0.0862183 -0.995607 0.585034 0.205198 -0.337256; #X coords 0 1 63 -1 200 140 1; #X restore 351 23 graph; #X obj 382 183 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0 1; #X floatatom 440 184 5 0 0 0 - - -; #X obj 382 201 metro 100; #X msg 342 201 bang; #X obj 73 295 dac~; #X floatatom 140 220 5 0 0 0 - - -; #X msg 68 58 seed 30000; #X obj 142 131 random_fl~; #X text 120 98 etc ..; #X obj 229 131 random_icg~; #X obj 81 241 fader 75; #X obj 368 239 tabwrite~ \$0-randomix_test; #X connect 0 0 12 0; #X connect 2 0 4 0; #X connect 3 0 4 1; #X connect 4 0 13 0; #X connect 5 0 13 0; #X connect 7 0 12 2; #X connect 8 0 0 0; #X connect 9 0 12 1; #X connect 11 0 12 0; #X connect 11 0 13 0; #X connect 12 0 6 0; #X connect 12 1 6 1; #X restore 98 421 pd signalversions; #N canvas 739 383 494 344 META 0; #X text 12 125 HELP_PATCH_AUTHORS Jonathan Wilkes revised the patch to conform to the PDDP template for Pd version 0.42.; #X text 12 25 LICENSE GPL v2; #X text 12 105 AUTHOR jdl@xdv.org; #X text 12 5 KEYWORDS signal random; #X text 12 45 DESCRIPTION linear congruential generator; #X text 12 65 INLET_0 seed; #X text 12 85 OUTLET_0 signal; #X restore 904 469 pd META; #X connect 0 0 11 0; #X connect 1 0 11 1; #X connect 4 0 6 0; #X connect 5 0 11 2; #X connect 6 0 3 0; #X connect 7 0 12 0; #X connect 8 0 12 1; #X connect 10 0 12 2; #X connect 11 0 2 0; #X connect 12 0 9 0; #X connect 13 0 17 0; #X connect 14 0 17 1; #X connect 16 0 17 2; #X connect 17 0 15 0; #X connect 18 0 29 0; #X connect 19 0 29 1; #X connect 21 0 29 2; #X connect 23 0 29 0; #X connect 25 0 31 0; #X connect 25 0 32 0; #X connect 25 0 34 0; #X connect 26 0 33 0; #X connect 27 0 33 0; #X connect 28 0 27 0; #X connect 29 0 20 0; #X connect 30 0 27 1; #X connect 33 0 25 0; #X connect 35 0 6 0; #X connect 35 1 11 0; #X connect 35 2 12 0; #X connect 35 3 17 0; #X connect 35 4 29 0; cxc-0.5.2/random_tw-help.pd0000644000076500007650000001531412076107577014236 0ustar hanshans#N canvas 0 31 966 505 10; #X msg 197 150 bang; #X floatatom 244 150 5 0 0 0 - - -; #X floatatom 197 218 10 0 0 0 - - -; #X floatatom 53 162 5 0 0 0 - - -; #X msg 54 111 bang; #X floatatom 289 152 5 0 0 0 - - -; #X obj 53 135 random 100; #X msg 427 151 bang; #X floatatom 474 151 5 0 0 0 - - -; #X floatatom 427 219 10 0 0 0 - - -; #X floatatom 519 153 5 0 0 0 - - -; #X obj 196 183 random1 0 1; #X obj 426 184 random_fl 0 1; #X msg 672 152 bang; #X floatatom 719 152 5 0 0 0 - - -; #X floatatom 672 220 10 0 0 0 - - -; #X floatatom 764 154 5 0 0 0 - - -; #X obj 671 185 random_icg 0 1; #X msg 197 276 bang; #X floatatom 244 276 5 0 0 0 - - -; #X floatatom 197 344 10 0 0 0 - - -; #X floatatom 289 278 5 0 0 0 - - -; #X text 193 251 random_icg lowerlimit \, upperlimit; #X msg 368 288 help; #X text 253 10 the random number generatorse; #X obj 539 406 dist_normal; #X msg 540 356 bang; #X obj 579 357 metro 100; #X obj 579 337 tgl 15 0 empty empty empty 20 8 0 8 -262144 -1 -1 0 1; #X obj 196 309 random_tw 0 1; #X floatatom 637 334 5 0 0 0 - - -; #N canvas 0 0 600 400 streamview 0; #N canvas 0 0 450 300 (subpatch) 0; #X array randstream 100 float 0; #X coords 0 2 99 -2 200 140 1; #X restore 92 222 graph; #X obj 146 144 tabwrite randstream; #X obj 200 63 count; #X obj 200 88 % 100; #X obj 156 28 t f b; #X obj 49 15 inlet; #X connect 2 0 3 0; #X connect 3 0 1 1; #X connect 4 0 1 0; #X connect 4 1 2 0; #X connect 5 0 4 0; #X restore 570 433 pd streamview; #N canvas 306 24 679 400 distview 0; #N canvas 0 0 450 300 (subpatch) 0; #X array randview1 100 float 0; #X coords 0 200 99 0 400 200 1; #X restore 248 31 graph; #X obj 28 26 inlet; #X obj 45 355 tabwrite randview1; #X obj 136 201 * 100; #X obj 136 225 int; #X obj 136 153 + 2; #X obj 45 280 tabread randview1; #X obj 136 176 / 4; #X obj 136 250 t f f; #X obj 45 304 t f b; #X obj 45 329 + 1; #X obj 136 129 t f; #X connect 1 0 11 0; #X connect 3 0 4 0; #X connect 4 0 8 0; #X connect 5 0 7 0; #X connect 6 0 9 0; #X connect 7 0 3 0; #X connect 8 0 6 0; #X connect 8 1 2 1; #X connect 9 0 10 0; #X connect 10 0 2 0; #X connect 11 0 5 0; #X restore 550 458 pd distview; #X obj 540 381 t b; #X floatatom 477 430 5 0 0 0 - - -; #N canvas 0 0 600 400 seedit 0; #X msg 284 154 seed \$1; #X obj 284 107 utime; #X msg 304 74 bang; #X obj 254 28 loadbang; #X obj 284 130 * 1e+06; #X obj 360 167 until; #X msg 455 156 bang; #X obj 359 194 random 2.14748e+08; #X msg 359 267 seed \$1; #X msg 385 294 seed \$1; #X msg 412 318 seed \$1; #X msg 439 267 seed \$1; #X msg 466 293 seed \$1; #X obj 254 50 t b b; #X obj 195 155 print seed1; #X obj 143 360 outlet; #X obj 204 361 outlet; #X obj 264 361 outlet; #X obj 317 361 outlet; #X obj 367 361 outlet; #X text 35 9 seed one random obj \, which generates the seeds for all the others.; #X obj 359 218 serialize 6; #X msg 360 140 6; #X obj 359 242 unpack f f f f f f; #X msg 485 317 seed \$1; #X obj 420 359 outlet; #X connect 0 0 7 0; #X connect 1 1 4 0; #X connect 2 0 1 0; #X connect 3 0 13 0; #X connect 4 0 0 0; #X connect 4 0 14 0; #X connect 5 0 7 0; #X connect 6 0 7 0; #X connect 7 0 21 0; #X connect 8 0 15 0; #X connect 9 0 16 0; #X connect 10 0 17 0; #X connect 11 0 18 0; #X connect 12 0 19 0; #X connect 13 0 22 0; #X connect 13 1 1 0; #X connect 21 0 23 0; #X connect 22 0 5 0; #X connect 23 0 8 0; #X connect 23 1 9 0; #X connect 23 2 10 0; #X connect 23 3 11 0; #X connect 23 4 12 0; #X connect 23 5 24 0; #X connect 24 0 25 0; #X restore 258 33 pd seedit; #X text 37 79 std pd random; #X text 197 124 linear congruential generator; #X text 197 77 creation arguments for the extra randoms are:; #X text 205 92 \, defaults to 0 respectively RAND_MAX; #X text 545 17 see also:; #X obj 545 40 utime; #X text 428 129 another lcg method ..; #X text 668 127 inverse linear congruential generator; #X text 536 249 normal distribution mean 0 and dist 1; #X text 536 264 right now it uses random1 for the actual rand values ; #X text 537 278 but later on it should take one of the randoms as creation argument \, so yu can specify which generator is being used.; #X text 198 106 they all output floats); #X text 540 311 also \, there is some burst at the upper and lower limits; #N canvas 622 668 592 356 signalversions 0; #X obj 68 131 random1~; #N canvas 0 0 450 300 (subpatch) 0; #X array \$0-randomix_test 64 float 1; #A 0 -0.599965 0.178987 -0.501604 -1.10592 0.426163 -0.481499 -0.553236 0.0961931 0.554738 -0.695487 0.541875 -0.415309 -0.419922 -0.871908 0.0688377 -1.03721 -0.136159 -0.207339 -1.18947 -0.25981 -0.628915 -0.826873 0.334755 -0.738558 -0.0926691 -0.262739 0.309148 0.50131 -1.40461 -0.859907 0.621724 -0.888718 0.692579 -1.11799 0.162897 0.116501 -0.390333 0.327364 -0.902445 -0.201419 0.300071 -1.10817 -1.09973 0.34181 -0.0511739 -0.613584 -0.306316 0.433381 -0.154481 -1.17821 -0.428187 -0.449014 -1.04248 -0.906665 0.0687456 -1.08289 0.59097 0.0438875 -1.20429 0.0862183 -0.995607 0.585034 0.205198 -0.337256; #X coords 0 1 63 -1 200 140 1; #X restore 351 23 graph; #X obj 382 183 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0 1; #X floatatom 440 184 5 0 0 0 - - -; #X obj 382 201 metro 100; #X msg 342 201 bang; #X obj 73 295 dac~; #X floatatom 140 220 5 0 0 0 - - -; #X msg 68 58 seed 30000; #X obj 142 131 random_fl~; #X text 120 98 etc ..; #X obj 229 131 random_icg~; #X obj 81 241 fader 75; #X obj 368 239 tabwrite~ \$0-randomix_test; #X connect 0 0 12 0; #X connect 2 0 4 0; #X connect 3 0 4 1; #X connect 4 0 13 0; #X connect 5 0 13 0; #X connect 7 0 12 2; #X connect 8 0 0 0; #X connect 9 0 12 1; #X connect 11 0 12 0; #X connect 11 0 13 0; #X connect 12 0 6 0; #X connect 12 1 6 1; #X restore 98 421 pd signalversions; #N canvas 697 364 494 344 META 0; #X text 12 165 HELP_PATCH_AUTHORS Jonathan Wilkes revised the patch to conform to the PDDP template for Pd version 0.42.; #X text 12 25 LICENSE GPL v2; #X text 12 145 AUTHOR jdl@xdv.org; #X text 12 65 INLET_0 bang seed help; #X text 12 85 INLET_1 float; #X text 12 105 INLET_2 float; #X text 12 125 OUTLET_0 float; #X text 12 45 DESCIPTION random_icg lowerlimit \, upperlimit; #X text 12 5 KEYWORDS control random; #X restore 903 475 pd META; #X connect 0 0 11 0; #X connect 1 0 11 1; #X connect 4 0 6 0; #X connect 5 0 11 2; #X connect 6 0 3 0; #X connect 7 0 12 0; #X connect 8 0 12 1; #X connect 10 0 12 2; #X connect 11 0 2 0; #X connect 12 0 9 0; #X connect 13 0 17 0; #X connect 14 0 17 1; #X connect 16 0 17 2; #X connect 17 0 15 0; #X connect 18 0 29 0; #X connect 19 0 29 1; #X connect 21 0 29 2; #X connect 23 0 29 0; #X connect 25 0 31 0; #X connect 25 0 32 0; #X connect 25 0 34 0; #X connect 26 0 33 0; #X connect 27 0 33 0; #X connect 28 0 27 0; #X connect 29 0 20 0; #X connect 30 0 27 1; #X connect 33 0 25 0; #X connect 35 0 6 0; #X connect 35 1 11 0; #X connect 35 2 12 0; #X connect 35 3 17 0; #X connect 35 4 29 0; cxc-0.5.2/cxc_counter.c0000644000076500007650000001313112076107577013444 0ustar hanshans/* * Copyright (c) 1997-1999 Mark Danks. * For information on usage and redistribution, and for a DISCLAIMER OF ALL * WARRANTIES, see the file, "GEM.LICENSE.TERMS" in this distribution. */ #include "m_pd.h" /* -------------------------- counter ------------------------------ */ /* instance structure */ static t_class *counter_class; typedef struct _counter { t_object x_obj; /* obligatory object header */ int c_current; /* current number */ int c_high; /* highest number */ int c_low; /* lowest number */ int c_updown; /* 0 = going up, 1 = going down */ int c_dir; /* counter dir. 1=up, 2=down, 3=up/down */ t_outlet *t_out1; /* the outlet */ t_outlet *t_out2; /* the outlet */ } t_counter; void counter_bang(t_counter *x) { int sendBang = 0; switch(x->c_dir) { // count up case 1: x->c_current++; if (x->c_current > x->c_high) x->c_current = x->c_low; else if (x->c_current < x->c_low) x->c_current = x->c_low; else if (x->c_current == x->c_high) sendBang = 1; break; // count down case 2: x->c_current--; if (x->c_current < x->c_low) x->c_current = x->c_high; else if (x->c_current > x->c_high) x->c_current = x->c_high; else if (x->c_current == x->c_low) sendBang = 1; break; // count up and down case 3: // going up if (x->c_updown == 0) { x->c_current++; if (x->c_current > x->c_high) { x->c_current = x->c_high - 1; x->c_updown = 1; } else if (x->c_current < x->c_low) x->c_current = x->c_low; else if (x->c_current == x->c_high) sendBang = 1; } // going down else if (x->c_updown == 1) { x->c_current--; if (x->c_current < x->c_low) { x->c_current = x->c_low + 1; x->c_updown = 0; } else if (x->c_current > x->c_high) x->c_current = x->c_high; else if (x->c_current == x->c_low) sendBang = 1; } else { error("up/down wrong"); return; } break; default: error("dir wrong"); return; } outlet_float(x->t_out1, (float)x->c_current); if (sendBang) outlet_bang(x->t_out2); } void counter_dir(t_counter *x, t_floatarg n) { if (n == 1 || n == 2 || n == 3) x->c_dir = (int)n; else error("bad dir"); } void counter_high(t_counter *x, t_floatarg n) { x->c_high = (int)n; } void counter_low(t_counter *x, t_floatarg n) { x->c_low = (int)n; } void counter_reset(t_counter *x, t_symbol *s, int argc, t_atom *argv) { if (!argc) { switch(x->c_dir) { case 1: x->c_current = x->c_low; break; case 2: x->c_current = x->c_high; break; case 3: if (x->c_updown == 0) x->c_current = x->c_low; else if (x->c_updown == 1) x->c_current = x->c_high; break; default: return; } } else { switch(argv[0].a_type) { case A_FLOAT : x->c_current = (int)argv[0].a_w.w_float; break; default : error ("counter: reset not float"); break; } } outlet_float(x->t_out1, (float)x->c_current); } void counter_clear(t_counter *x, t_symbol *s, int argc, t_atom *argv) { if (!argc) { switch(x->c_dir) { case 1: x->c_current = x->c_low - 1; break; case 2: x->c_current = x->c_high + 1; break; case 3: if (x->c_updown == 0) x->c_current = x->c_low - 1; else if (x->c_updown == 1) x->c_current = x->c_high + 1; break; default: break; } } else { switch(argv[0].a_type) { case A_FLOAT : x->c_current = (int)argv[0].a_w.w_float - 1; break; default : error ("counter: reset not float"); break; } } } void *counter_new(t_floatarg f, t_floatarg g, t_floatarg h) /* init vals in struc */ { t_counter *x = (t_counter *)pd_new(counter_class); x->t_out1 = outlet_new(&x->x_obj, 0); x->t_out2 = outlet_new(&x->x_obj, 0); inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_float, gensym("fl1")); inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_float, gensym("fl2")); inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_float, gensym("fl3")); x->c_current = 0; x->c_updown = 0; if (h) { counter_low(x, f); counter_high(x, g); counter_dir(x, h); } else if (g) { x->c_dir = 1; counter_low(x, f); counter_high(x, g); } else if (f) { x->c_dir = x->c_low = 1; counter_high(x, f); } else { x->c_dir = x->c_low = 1; x->c_high = 10; } return (x); } void cxc_counter_setup(void) { counter_class = class_new(gensym("cxc_counter"), (t_newmethod)counter_new, 0, sizeof(t_counter), 0, A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT, 0); class_addbang(counter_class, (t_method)counter_bang); class_addmethod(counter_class, (t_method)counter_dir, gensym("fl1"), A_FLOAT, 0); class_addmethod(counter_class, (t_method)counter_low, gensym("fl2"), A_FLOAT, 0); class_addmethod(counter_class, (t_method)counter_high, gensym("fl3"), A_FLOAT, 0); class_addmethod(counter_class, (t_method)counter_reset, gensym("reset"), A_GIMME, 0); class_addmethod(counter_class, (t_method)counter_clear, gensym("clear"), A_GIMME, 0); } cxc-0.5.2/ixprint.c0000644000076500007650000000372012076107577012630 0ustar hanshans#include "m_pd.h" /* -------------------------- ixprint ------------------------------ * print without "print: " ... */ static t_class *ixprint_class; typedef struct _ixprint { t_object x_obj; t_symbol *x_sym; } t_ixprint; static void *ixprint_new(t_symbol *s) { t_ixprint *x = (t_ixprint *)pd_new(ixprint_class); if (*s->s_name) x->x_sym = s; // change, plain print .. else x->x_sym = gensym(""); return (x); } static void ixprint_bang(t_ixprint *x) { post("bang", x->x_sym->s_name); } static void ixprint_pointer(t_ixprint *x, t_gpointer *gp) { post("(gpointer)", x->x_sym->s_name); } static void ixprint_float(t_ixprint *x, t_float f) { post("%g",f); } static void ixprint_list(t_ixprint *x, t_symbol *s, int argc, t_atom *argv) { int i; char buf[80]; if (argc && argv->a_type != A_SYMBOL) startpost("%s:", x->x_sym->s_name); else startpost("%s", (argc > 1 ? s_list.s_name : s_symbol.s_name)); postatom(argc, argv); endpost(); } static void ixprint_anything(t_ixprint *x, t_symbol *s, int argc, t_atom *argv) { int i; char buf[80]; startpost("%s", s->s_name); postatom(argc, argv); endpost(); } /* -------------------------- logger ------------------------------ * log text input into file , output linecount .. */ /* static t_class *logger_class; typedef struct _logger { t_object x_obj; t_symbol x_fname; t_float x_lc; } t_logger; static void *logger_new(t_symbol *s) { t_logger *x = (t_logger *)pd_new(logger_class); x->x_fname = gensym("pd.log"); return (x); } */ void ixprint_setup(void) { ixprint_class = class_new(gensym("ixprint"), (t_newmethod)ixprint_new, 0, sizeof(t_ixprint), 0, A_DEFSYM, 0); class_addbang(ixprint_class, ixprint_bang); class_addfloat(ixprint_class, ixprint_float); class_addpointer(ixprint_class, ixprint_pointer); class_addlist(ixprint_class, ixprint_list); class_addanything(ixprint_class, ixprint_anything); } cxc-0.5.2/utime.c0000644000076500007650000000367512076107577012267 0ustar hanshans/* (c) 2002:cxc@web.fm microtime: seconds since epoch plus microsecs */ #include #ifdef _WIN32 #include #else #include #endif #include /* ----------------------- utime --------------------- */ static t_class *utime_class; typedef struct _utime { t_object x_obj; t_outlet *x_outlet1; t_outlet *x_outlet2; } t_utime; static void *utime_new(t_symbol *s, int argc, t_atom *argv) { t_utime *x = (t_utime *)pd_new(utime_class); x->x_outlet1 = outlet_new(&x->x_obj, &s_float); x->x_outlet2 = outlet_new(&x->x_obj, &s_float); return (x); } #ifndef _WIN32 static void utime_bang(t_utime *x) { struct timeval myutime; struct timezone mytz; gettimeofday(&myutime, &mytz); outlet_float(x->x_outlet2, (t_float)myutime.tv_usec); outlet_float(x->x_outlet1, (t_float)myutime.tv_sec); } #else static void utime_bang(t_utime *x) { FILETIME myfiletime; ULARGE_INTEGER ulfiletime, ulSec, uluSec; GetSystemTimeAsFileTime(&myfiletime); ulfiletime.LowPart = myfiletime.dwLowDateTime; ulfiletime.HighPart = myfiletime.dwHighDateTime; ulfiletime.QuadPart -= 116444736000000000; // number of 100ns ticks from 1601-01-01 to 1970-01-01 ulSec.QuadPart = ulfiletime.QuadPart / (10 * 1000 * 1000); // FILETIME uses 100ns ticks uluSec.QuadPart = (ulfiletime.QuadPart - ulSec.QuadPart * 10 * 1000 * 1000) / 10; // FILETIME uses 100ns ticks outlet_float(x->x_outlet2, (t_float)(__int64)ulSec.QuadPart ); outlet_float(x->x_outlet1, (t_float)(__int64)uluSec.QuadPart); } #endif static void help_utime(t_utime *x) { post("\n%c utime\t\t:: get the current system time", 70); post("\noutputs are\t: seconds since epoch / remaining microseconds"); } void utime_setup(void) { utime_class = class_new(gensym("utime"), (t_newmethod)utime_new, 0, sizeof(t_utime), 0, A_GIMME, 0); class_addbang(utime_class, utime_bang); class_addmethod(utime_class, (t_method)help_utime, gensym("help"), 0); } cxc-0.5.2/ascwave.c0000644000076500007650000000741312076107577012567 0ustar hanshans/* code for foo1 pd class */ #include "m_pd.h" #include #include #ifdef _WIN32 #include #endif /* support older Pd versions without sys_fopen(), sys_fclose(), and, sys_close() */ #if PD_MAJOR_VERSION == 0 && PD_MINOR_VERSION < 44 #define sys_fopen fopen #define sys_fclose fclose #define sys_close close #endif #ifndef RAND_MAX #define RAND_MAX 21 #endif t_class *ascwave_class; typedef struct ascwave { t_object t_ob; t_symbol* filename; FILE* x_file; // width vertical, sort of useless t_float x_jodel; // width horizontal t_float x_julp; // fill or not flag t_float x_fill; // chr to use for draw t_float x_chr; // chr to use 4 fill } t_ascwave; void ascwave_bang(t_ascwave *x, t_floatarg f) { // post("cxc/ascwave.c: bang %f", x->x_jodel); outlet_float(x->t_ob.ob_outlet, x->x_jodel + x->x_jodel); } /* fill or line toggle */ static void ascwave_fill(t_ascwave *x, t_floatarg f) { x->x_fill = f; // post("ascwave: fill %f", x->x_fill); } /* open a file to put ascii output into */ static void ascwave_open(t_ascwave *x, t_symbol *filename) { post("ascwave: open"); x->filename = filename; post("ascwave: filename = %s",x->filename->s_name); if ((x->x_file = sys_fopen(x->filename->s_name,"w")) < 0) { error("can't create %s",filename->s_name); return; } } void ascwave_ft1(t_ascwave *x, t_floatarg g) { int sz = x->x_julp; int lchr = x->x_chr; int schr = 32; int i = 0; char* xip; char* xap; xip = (char*)malloc((sz+1)*sizeof(char)); xap = (char*)malloc((sz+1)*sizeof(char)); for (i = 0;i <= sz; ++i) { if (i == sz-1) { xip[i] = lchr; } else { if (!x->x_fill) { xip[i] = schr; } else { xip[i] = lchr; /* if (rand() > 20) xip[i] = '\n'; */ } } if (i == 0 || i == sz-1) xap[i] = lchr; else xap[i] = i % 80 + 33; } // xip[sz] = schr;//'\n'; xip[sz+1] = '\0'; //xap[sz] = schr;//'\n'; xap[sz+1] = '\0'; // poststring(xip); // post("ft1: %f, %d", x->x_jodel, sz); // outlet_float(x->t_ob.ob_outlet, x->x_jodel + x->x_jodel); outlet_symbol(x->t_ob.ob_outlet, gensym(xip)); for (i = 0; i < g-2;++i) outlet_symbol(x->t_ob.ob_outlet, gensym(xap)); if (g > 1) outlet_symbol(x->t_ob.ob_outlet, gensym(xip)); x->x_jodel = g; free(xip); free(xap); } static void ascwave_width(t_ascwave *x, t_floatarg g) { if (g < 0) x->x_julp = 0; else x->x_julp = g; //post("ascwave: setting width: %f", x->x_julp); } static void ascwave_chr(t_ascwave *x, t_floatarg g) { x->x_chr = g; // post("ascwave: setting character: %f", x->x_chr); } void ascwave_free() { } void *ascwave_new() { t_ascwave *x = (t_ascwave *)pd_new(ascwave_class); x->x_chr = 46; // outlet_new(&x->t_ob, &s_float); outlet_new(&x->t_ob, &s_symbol); inlet_new(&x->t_ob, &x->t_ob.ob_pd, gensym("float"), gensym("ft1")); inlet_new(&x->t_ob, &x->t_ob.ob_pd, gensym("float"), gensym("ft2")); inlet_new(&x->t_ob, &x->t_ob.ob_pd, gensym("float"), gensym("ft3")); // post("ascwave_new"); return (void *)x; } void ascwave_setup() { // post("ascwave_setup"); ascwave_class = class_new(gensym("ascwave"), (t_newmethod)ascwave_new, 0, sizeof(t_ascwave), 0, 0); class_addmethod(ascwave_class, (t_method)ascwave_bang, gensym("bang"), 0); class_addmethod(ascwave_class, (t_method)ascwave_fill, gensym("fill"), A_FLOAT, A_NULL); class_addmethod(ascwave_class, (t_method) ascwave_open, gensym("open"), A_SYMBOL,A_NULL); class_addmethod(ascwave_class, (t_method)ascwave_ft1, gensym("ft1"), A_FLOAT, 0); class_addmethod(ascwave_class, (t_method)ascwave_width, gensym("ft2"), A_FLOAT, 0); // set chr class_addmethod(ascwave_class, (t_method)ascwave_chr, gensym("ft3"), A_FLOAT, 0); } cxc-0.5.2/reson~-help.pd0000644000076500007650000000115412076107577013565 0ustar hanshans#N canvas 0 4 454 304 10; #X obj 183 119 reson~; #X text 104 237 An interpolating reson filter; #N canvas 358 105 494 359 META 0; #X text 12 185 HELP_PATCH_AUTHORS Jonathan Wilkes revised the patch to conform to the PDDP template for Pd version 0.42.; #X text 12 5 KEYWORDS signal filter needs_work (example patch); #X text 12 45 DESCRIPTION an interpolating reson filter; #X text 12 65 INLET_0 signal; #X text 12 85 INLET_1 signal; #X text 12 105 INLET_2 signal; #X text 12 125 INLET_3 signal; #X text 12 145 OUTLET_0 signal; #X text 12 25 LICENSE GPL v2; #X text 12 165 AUTHOR jdl@xdv.org; #X restore 405 282 pd META; cxc-0.5.2/ascwave-help.pd0000644000076500007650000000364012076107577013674 0ustar hanshans#N canvas 1 2 407 316 10; #X msg 80 153 bang; #X floatatom 169 176 0 0 0 0 - - -; #X floatatom 214 58 0 0 0 0 - - -; #X obj 151 13 loadbang; #X obj 157 97 metro 100; #X msg 157 196 1; #X msg 157 58 1; #X msg 186 58 0; #X obj 145 221 ascwave; #X msg 75 192 fill 1; #X msg 74 211 fill 0; #X obj 145 269 ixprint; #X msg 145 241 \$1; #N canvas 273 122 588 372 modulate 0; #X obj 84 200 outlet; #X obj 84 139 random 80; #X msg 30 110 bang; #X obj 84 75 * 50; #X obj 84 93 metro 5000; #X obj 29 52 loadbang; #X msg 29 70 1; #X obj 84 161 pack 1 5000; #X obj 84 180 line; #X obj 86 31 inlet start/stop; #X obj 130 53 inlet time; #X connect 1 0 7 0; #X connect 2 0 1 0; #X connect 3 0 4 0; #X connect 3 0 7 1; #X connect 4 0 1 0; #X connect 5 0 6 0; #X connect 6 0 4 0; #X connect 7 0 8 0; #X connect 8 0 0 0; #X connect 9 0 4 0; #X connect 10 0 3 0; #X restore 169 154 page modulate; #X floatatom 262 132 0 0 0 0 - - -; #X obj 262 179 min 127; #X obj 262 154 max 33; #X obj 157 77 f; #X obj 210 78 f; #X text 200 178 <== here; #X text 297 131 <== and here; #N canvas 409 221 494 369 META 0; #X text 12 185 HELP_PATCH_AUTHORS Jonathan Wilkes revised the patch to conform to the PDDP template for Pd version 0.42.; #X text 12 45 DESCRIPTION; #X text 12 5 KEYWORDS control symbol_op; #X text 12 85 INLET_1 float; #X text 12 105 INLET_2 float; #X text 12 125 INLET_3 float; #X text 12 65 INLET_0 float bang fill; #X text 12 145 OUTLET_0 symbol float; #X text 12 25 LICENSE GPL v2; #X text 12 165 AUTHOR jdl@xdv.org; #X restore 356 294 pd META; #X connect 0 0 8 0; #X connect 1 0 8 2; #X connect 2 0 18 0; #X connect 3 0 6 0; #X connect 4 0 5 0; #X connect 5 0 8 1; #X connect 6 0 17 0; #X connect 7 0 17 0; #X connect 8 0 12 0; #X connect 9 0 8 0; #X connect 10 0 8 0; #X connect 12 0 11 0; #X connect 13 0 8 2; #X connect 14 0 16 0; #X connect 15 0 8 3; #X connect 16 0 15 0; #X connect 17 0 4 0; #X connect 17 0 13 0; #X connect 18 0 4 1; #X connect 18 0 13 1; cxc-0.5.2/Makefile0000644000076500007650000003613412076107577012434 0ustar hanshans## Pd library template version 1.0.11 # For instructions on how to use this template, see: # http://puredata.info/docs/developer/MakefileTemplate LIBRARY_NAME = cxc # add your .c source files, one object per file, to the SOURCES # variable, help files will be included automatically SOURCES = ENV.c ascseq.c ascwave.c bfilt.c bfilt2.c cxc_counter.c cxavgdev.c cxc_prepend.c cxc_split.c cxmean.c cxstddev.c delta~.c dist_normal.c hex2dec.c ixprint.c mean~.c random1.c random1~.c random_fl.c random_fl~.c random_icg.c random_icg~.c random_tw.c reson~.c utime.c # For objects that only build on certain platforms, add those to the SOURCES # line for the right platforms. SOURCES_linux = proc.c # list all pd objects (i.e. myobject.pd) files here, and their helpfiles will # be included automatically PDOBJECTS = fader.pd # example patches and related files, in the 'examples' subfolder EXAMPLES = # manuals and related files, in the 'manual' subfolder MANUAL = # if you want to include any other files in the source and binary tarballs, # list them here. This can be anything from header files, test patches, # documentation, etc. README.txt and LICENSE.txt are required and therefore # automatically included EXTRA_DIST = TODO REFERENCES x_connective_pd034.diff x_connective_pd035.diff cxc.h cxc.c #------------------------------------------------------------------------------# # # things you might need to edit if you are using other C libraries # #------------------------------------------------------------------------------# ALL_CFLAGS = -I"$(PD_INCLUDE)" ALL_LDFLAGS = SHARED_LDFLAGS = ALL_LIBS = #------------------------------------------------------------------------------# # # you shouldn't need to edit anything below here, if we did it right :) # #------------------------------------------------------------------------------# # these can be set from outside without (usually) breaking the build CFLAGS = -Wall -W -g LDFLAGS = LIBS = # get library version from meta file LIBRARY_VERSION = $(shell sed -n 's|^\#X text [0-9][0-9]* [0-9][0-9]* VERSION \(.*\);|\1|p' $(LIBRARY_NAME)-meta.pd) ALL_CFLAGS += -DPD -DVERSION='"$(LIBRARY_VERSION)"' PD_INCLUDE = $(PD_PATH)/include/pd # where to install the library, overridden below depending on platform prefix = /usr/local libdir = $(prefix)/lib pkglibdir = $(libdir)/pd-externals objectsdir = $(pkglibdir) INSTALL = install INSTALL_PROGRAM = $(INSTALL) -p -m 644 INSTALL_DATA = $(INSTALL) -p -m 644 INSTALL_DIR = $(INSTALL) -p -m 755 -d ALLSOURCES := $(SOURCES) $(SOURCES_android) $(SOURCES_cygwin) $(SOURCES_macosx) \ $(SOURCES_iphoneos) $(SOURCES_linux) $(SOURCES_windows) DISTDIR=$(LIBRARY_NAME)-$(LIBRARY_VERSION) ORIGDIR=pd-$(LIBRARY_NAME:~=)_$(LIBRARY_VERSION) UNAME := $(shell uname -s) ifeq ($(UNAME),Darwin) CPU := $(shell uname -p) ifeq ($(CPU),arm) # iPhone/iPod Touch SOURCES += $(SOURCES_iphoneos) EXTENSION = pd_darwin SHARED_EXTENSION = dylib OS = iphoneos PD_PATH = /Applications/Pd-extended.app/Contents/Resources IPHONE_BASE=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin CC=$(IPHONE_BASE)/gcc CPP=$(IPHONE_BASE)/cpp CXX=$(IPHONE_BASE)/g++ ISYSROOT = -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.0.sdk IPHONE_CFLAGS = -miphoneos-version-min=3.0 $(ISYSROOT) -arch armv6 OPT_CFLAGS = -fast -funroll-loops -fomit-frame-pointer ALL_CFLAGS := $(IPHONE_CFLAGS) $(ALL_CFLAGS) ALL_LDFLAGS += -arch armv6 -bundle -undefined dynamic_lookup $(ISYSROOT) SHARED_LDFLAGS += -arch armv6 -dynamiclib -undefined dynamic_lookup $(ISYSROOT) ALL_LIBS += -lc $(LIBS_iphoneos) STRIP = strip -x DISTBINDIR=$(DISTDIR)-$(OS) else # Mac OS X SOURCES += $(SOURCES_macosx) EXTENSION = pd_darwin SHARED_EXTENSION = dylib OS = macosx PD_PATH = /Applications/Pd-extended.app/Contents/Resources OPT_CFLAGS = -ftree-vectorize -ftree-vectorizer-verbose=2 -fast # build universal 32-bit on 10.4 and 32/64 on newer ifeq ($(shell uname -r | sed 's|\([0-9][0-9]*\)\.[0-9][0-9]*\.[0-9][0-9]*|\1|'), 8) FAT_FLAGS = -arch ppc -arch i386 -mmacosx-version-min=10.4 else FAT_FLAGS = -arch ppc -arch i386 -arch x86_64 -mmacosx-version-min=10.4 SOURCES += $(SOURCES_iphoneos) endif ALL_CFLAGS += $(FAT_FLAGS) -fPIC -I/sw/include # if the 'pd' binary exists, check the linking against it to aid with stripping BUNDLE_LOADER = $(shell test ! -e $(PD_PATH)/bin/pd || echo -bundle_loader $(PD_PATH)/bin/pd) ALL_LDFLAGS += $(FAT_FLAGS) -bundle $(BUNDLE_LOADER) -undefined dynamic_lookup -L/sw/lib SHARED_LDFLAGS += $(FAT_FLAGS) -dynamiclib -undefined dynamic_lookup \ -install_name @loader_path/$(SHARED_LIB) -compatibility_version 1 -current_version 1.0 ALL_LIBS += -lc $(LIBS_macosx) STRIP = strip -x DISTBINDIR=$(DISTDIR)-$(OS) # install into ~/Library/Pd on Mac OS X since /usr/local isn't used much pkglibdir=$(HOME)/Library/Pd endif endif # Tho Android uses Linux, we use this fake uname to provide an easy way to # setup all this things needed to cross-compile for Android using the NDK ifeq ($(UNAME),ANDROID) CPU := arm SOURCES += $(SOURCES_android) EXTENSION = pd_linux SHARED_EXTENSION = so OS = android PD_PATH = /usr NDK_BASE := /usr/local/android-ndk NDK_PLATFORM_VERSION := 5 NDK_SYSROOT=$(NDK_BASE)/platforms/android-$(NDK_PLATFORM_VERSION)/arch-arm NDK_UNAME := $(shell uname -s | tr '[A-Z]' '[a-z]') NDK_TOOLCHAIN_BASE=$(NDK_BASE)/toolchains/arm-linux-androideabi-4.4.3/prebuilt/$(NDK_UNAME)-x86 CC := $(NDK_TOOLCHAIN_BASE)/bin/arm-linux-androideabi-gcc --sysroot=$(NDK_SYSROOT) OPT_CFLAGS = -O6 -funroll-loops -fomit-frame-pointer CFLAGS += LDFLAGS += -rdynamic -shared SHARED_LDFLAGS += -Wl,-soname,$(SHARED_LIB) -shared LIBS += -lc $(LIBS_android) STRIP := $(NDK_TOOLCHAIN_BASE)/bin/arm-linux-androideabi-strip \ --strip-unneeded -R .note -R .comment DISTBINDIR=$(DISTDIR)-$(OS)-$(shell uname -m) endif ifeq ($(UNAME),Linux) CPU := $(shell uname -m) SOURCES += $(SOURCES_linux) EXTENSION = pd_linux SHARED_EXTENSION = so OS = linux PD_PATH = /usr OPT_CFLAGS = -O6 -funroll-loops -fomit-frame-pointer ALL_CFLAGS += -fPIC ALL_LDFLAGS += -rdynamic -shared -fPIC SHARED_LDFLAGS += -Wl,-soname,$(SHARED_LIB) -shared ALL_LIBS += -lc $(LIBS_linux) STRIP = strip --strip-unneeded -R .note -R .comment DISTBINDIR=$(DISTDIR)-$(OS)-$(shell uname -m) endif ifeq ($(UNAME),GNU) # GNU/Hurd, should work like GNU/Linux for basically all externals CPU := $(shell uname -m) SOURCES += $(SOURCES_linux) EXTENSION = pd_linux SHARED_EXTENSION = so OS = linux PD_PATH = /usr OPT_CFLAGS = -O6 -funroll-loops -fomit-frame-pointer ALL_CFLAGS += -fPIC ALL_LDFLAGS += -rdynamic -shared -fPIC SHARED_LDFLAGS += -shared -Wl,-soname,$(SHARED_LIB) ALL_LIBS += -lc $(LIBS_linux) STRIP = strip --strip-unneeded -R .note -R .comment DISTBINDIR=$(DISTDIR)-$(OS)-$(shell uname -m) endif ifeq ($(UNAME),GNU/kFreeBSD) # Debian GNU/kFreeBSD, should work like GNU/Linux for basically all externals CPU := $(shell uname -m) SOURCES += $(SOURCES_linux) EXTENSION = pd_linux SHARED_EXTENSION = so OS = linux PD_PATH = /usr OPT_CFLAGS = -O6 -funroll-loops -fomit-frame-pointer ALL_CFLAGS += -fPIC ALL_LDFLAGS += -rdynamic -shared -fPIC SHARED_LDFLAGS += -shared -Wl,-soname,$(SHARED_LIB) ALL_LIBS += -lc $(LIBS_linux) STRIP = strip --strip-unneeded -R .note -R .comment DISTBINDIR=$(DISTDIR)-$(OS)-$(shell uname -m) endif ifeq (CYGWIN,$(findstring CYGWIN,$(UNAME))) CPU := $(shell uname -m) SOURCES += $(SOURCES_cygwin) EXTENSION = dll SHARED_EXTENSION = dll OS = cygwin PD_PATH = $(shell cygpath $$PROGRAMFILES)/pd OPT_CFLAGS = -O6 -funroll-loops -fomit-frame-pointer ALL_CFLAGS += ALL_LDFLAGS += -rdynamic -shared -L"$(PD_PATH)/src" -L"$(PD_PATH)/bin" SHARED_LDFLAGS += -shared -Wl,-soname,$(SHARED_LIB) ALL_LIBS += -lc -lpd $(LIBS_cygwin) STRIP = strip --strip-unneeded -R .note -R .comment DISTBINDIR=$(DISTDIR)-$(OS) endif ifeq (MINGW,$(findstring MINGW,$(UNAME))) CPU := $(shell uname -m) SOURCES += $(SOURCES_windows) EXTENSION = dll SHARED_EXTENSION = dll OS = windows PD_PATH = $(shell cd "$$PROGRAMFILES/pd" && pwd) # MinGW doesn't seem to include cc so force gcc CC=gcc OPT_CFLAGS = -O3 -funroll-loops -fomit-frame-pointer ALL_CFLAGS += -mms-bitfields ALL_LDFLAGS += -s -shared -Wl,--enable-auto-import -L"$(PD_PATH)/src" -L"$(PD_PATH)/bin" -L"$(PD_PATH)/obj" SHARED_LDFLAGS += -shared ALL_LIBS += -lpd -lwsock32 -lkernel32 -luser32 -lgdi32 $(LIBS_windows) STRIP = strip --strip-unneeded -R .note -R .comment DISTBINDIR=$(DISTDIR)-$(OS) endif # in case somebody manually set the HELPPATCHES above HELPPATCHES ?= $(SOURCES:.c=-help.pd) $(PDOBJECTS:.pd=-help.pd) ALL_CFLAGS := $(ALL_CFLAGS) $(CFLAGS) $(OPT_CFLAGS) ALL_LDFLAGS := $(LDFLAGS) $(ALL_LDFLAGS) ALL_LIBS := $(LIBS) $(ALL_LIBS) SHARED_SOURCE ?= $(shell test ! -e lib$(LIBRARY_NAME).c || \ echo lib$(LIBRARY_NAME).c ) SHARED_HEADER ?= $(shell test ! -e $(LIBRARY_NAME).h || echo $(LIBRARY_NAME).h) SHARED_LIB = $(SHARED_SOURCE:.c=.$(SHARED_EXTENSION)) .PHONY = install libdir_install single_install install-doc install-examples install-manual clean distclean dist etags $(LIBRARY_NAME) all: $(SOURCES:.c=.$(EXTENSION)) $(SHARED_LIB) %.o: %.c $(CC) $(ALL_CFLAGS) -o "$*.o" -c "$*.c" %.$(EXTENSION): %.o $(SHARED_LIB) $(CC) $(ALL_LDFLAGS) -o "$*.$(EXTENSION)" "$*.o" $(ALL_LIBS) $(SHARED_LIB) chmod a-x "$*.$(EXTENSION)" # this links everything into a single binary file $(LIBRARY_NAME): $(SOURCES:.c=.o) $(LIBRARY_NAME).o $(CC) $(ALL_LDFLAGS) -o $(LIBRARY_NAME).$(EXTENSION) $(SOURCES:.c=.o) $(LIBRARY_NAME).o $(ALL_LIBS) chmod a-x $(LIBRARY_NAME).$(EXTENSION) $(SHARED_LIB): $(SHARED_SOURCE:.c=.o) $(CC) $(SHARED_LDFLAGS) -o $(SHARED_LIB) $(SHARED_SOURCE:.c=.o) $(LIBS) install: libdir_install # The meta and help files are explicitly installed to make sure they are # actually there. Those files are not optional, then need to be there. libdir_install: $(SOURCES:.c=.$(EXTENSION)) $(SHARED_LIB) install-doc install-examples install-manual $(INSTALL_DIR) $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME) $(INSTALL_DATA) $(LIBRARY_NAME)-meta.pd \ $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME) test -z "$(strip $(SOURCES))" || (\ $(INSTALL_PROGRAM) $(SOURCES:.c=.$(EXTENSION)) $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME) && \ $(STRIP) $(addprefix $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME)/,$(SOURCES:.c=.$(EXTENSION)))) test -z "$(strip $(SHARED_LIB))" || \ $(INSTALL_DATA) $(SHARED_LIB) \ $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME) test -z "$(strip $(wildcard $(SOURCES:.c=.tcl)))" || \ $(INSTALL_DATA) $(wildcard $(SOURCES:.c=.tcl)) \ $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME) test -z "$(strip $(PDOBJECTS))" || \ $(INSTALL_DATA) $(PDOBJECTS) \ $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME) # install library linked as single binary single_install: $(LIBRARY_NAME) install-doc install-examples install-manual $(INSTALL_DIR) $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME) $(INSTALL_PROGRAM) $(LIBRARY_NAME).$(EXTENSION) $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME) $(STRIP) $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME)/$(LIBRARY_NAME).$(EXTENSION) install-doc: $(INSTALL_DIR) $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME) test -z "$(strip $(SOURCES) $(PDOBJECTS))" || \ $(INSTALL_DATA) $(HELPPATCHES) \ $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME) $(INSTALL_DATA) README.txt $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME)/README.txt $(INSTALL_DATA) LICENSE.txt $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME)/LICENSE.txt install-examples: test -z "$(strip $(EXAMPLES))" || \ $(INSTALL_DIR) $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME)/examples && \ for file in $(EXAMPLES); do \ $(INSTALL_DATA) examples/$$file $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME)/examples; \ done install-manual: test -z "$(strip $(MANUAL))" || \ $(INSTALL_DIR) $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME)/manual && \ for file in $(MANUAL); do \ $(INSTALL_DATA) manual/$$file $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME)/manual; \ done clean: -rm -f -- $(SOURCES:.c=.o) $(SOURCES_LIB:.c=.o) $(SHARED_SOURCE:.c=.o) -rm -f -- $(SOURCES:.c=.$(EXTENSION)) -rm -f -- $(LIBRARY_NAME).o -rm -f -- $(LIBRARY_NAME).$(EXTENSION) -rm -f -- $(SHARED_LIB) distclean: clean -rm -f -- $(DISTBINDIR).tar.gz -rm -rf -- $(DISTBINDIR) -rm -f -- $(DISTDIR).tar.gz -rm -rf -- $(DISTDIR) -rm -f -- $(ORIGDIR).tar.gz -rm -rf -- $(ORIGDIR) $(DISTBINDIR): $(INSTALL_DIR) $(DISTBINDIR) libdir: all $(DISTBINDIR) $(INSTALL_DATA) $(LIBRARY_NAME)-meta.pd $(DISTBINDIR) $(INSTALL_DATA) $(SOURCES) $(SHARED_SOURCE) $(SHARED_HEADER) $(DISTBINDIR) $(INSTALL_DATA) $(HELPPATCHES) $(DISTBINDIR) test -z "$(strip $(EXTRA_DIST))" || \ $(INSTALL_DATA) $(EXTRA_DIST) $(DISTBINDIR) # tar --exclude-vcs -czpf $(DISTBINDIR).tar.gz $(DISTBINDIR) $(DISTDIR): $(INSTALL_DIR) $(DISTDIR) $(ORIGDIR): $(INSTALL_DIR) $(ORIGDIR) dist: $(DISTDIR) $(INSTALL_DATA) Makefile $(DISTDIR) $(INSTALL_DATA) README.txt $(DISTDIR) $(INSTALL_DATA) LICENSE.txt $(DISTDIR) $(INSTALL_DATA) $(LIBRARY_NAME)-meta.pd $(DISTDIR) test -z "$(strip $(ALLSOURCES))" || \ $(INSTALL_DATA) $(ALLSOURCES) $(DISTDIR) test -z "$(strip $(wildcard $(ALLSOURCES:.c=.tcl)))" || \ $(INSTALL_DATA) $(wildcard $(ALLSOURCES:.c=.tcl)) $(DISTDIR) test -z "$(strip $(SHARED_HEADER))" || \ $(INSTALL_DATA) $(SHARED_HEADER) $(DISTDIR) test -z "$(strip $(SHARED_SOURCE))" || \ $(INSTALL_DATA) $(SHARED_SOURCE) $(DISTDIR) test -z "$(strip $(PDOBJECTS))" || \ $(INSTALL_DATA) $(PDOBJECTS) $(DISTDIR) test -z "$(strip $(HELPPATCHES))" || \ $(INSTALL_DATA) $(HELPPATCHES) $(DISTDIR) test -z "$(strip $(EXTRA_DIST))" || \ $(INSTALL_DATA) $(EXTRA_DIST) $(DISTDIR) test -z "$(strip $(EXAMPLES))" || \ $(INSTALL_DIR) $(DISTDIR)/examples && \ for file in $(EXAMPLES); do \ $(INSTALL_DATA) examples/$$file $(DISTDIR)/examples; \ done test -z "$(strip $(MANUAL))" || \ $(INSTALL_DIR) $(DISTDIR)/manual && \ for file in $(MANUAL); do \ $(INSTALL_DATA) manual/$$file $(DISTDIR)/manual; \ done tar --exclude-vcs -czpf $(DISTDIR).tar.gz $(DISTDIR) # make a Debian source package dpkg-source: debclean make distclean dist mv $(DISTDIR) $(ORIGDIR) tar --exclude-vcs -czpf ../$(ORIGDIR).orig.tar.gz $(ORIGDIR) rm -f -- $(DISTDIR).tar.gz rm -rf -- $(DISTDIR) $(ORIGDIR) cd .. && dpkg-source -b $(LIBRARY_NAME) etags: etags *.h $(SOURCES) ../../pd/src/*.[ch] /usr/include/*.h /usr/include/*/*.h showsetup: @echo "CC: $(CC)" @echo "CFLAGS: $(CFLAGS)" @echo "LDFLAGS: $(LDFLAGS)" @echo "LIBS: $(LIBS)" @echo "ALL_CFLAGS: $(ALL_CFLAGS)" @echo "ALL_LDFLAGS: $(ALL_LDFLAGS)" @echo "ALL_LIBS: $(ALL_LIBS)" @echo "PD_INCLUDE: $(PD_INCLUDE)" @echo "PD_PATH: $(PD_PATH)" @echo "objectsdir: $(objectsdir)" @echo "LIBRARY_NAME: $(LIBRARY_NAME)" @echo "LIBRARY_VERSION: $(LIBRARY_VERSION)" @echo "SOURCES: $(SOURCES)" @echo "SHARED_HEADER: $(SHARED_HEADER)" @echo "SHARED_SOURCE: $(SHARED_SOURCE)" @echo "SHARED_LIB: $(SHARED_LIB)" @echo "PDOBJECTS: $(PDOBJECTS)" @echo "ALLSOURCES: $(ALLSOURCES)" @echo "ALLSOURCES TCL: $(wildcard $(ALLSOURCES:.c=.tcl))" @echo "UNAME: $(UNAME)" @echo "CPU: $(CPU)" @echo "pkglibdir: $(pkglibdir)" @echo "DISTDIR: $(DISTDIR)" @echo "ORIGDIR: $(ORIGDIR)" cxc-0.5.2/random_fl~.c0000644000076500007650000000470212076107577013273 0ustar hanshans/* (c) 2002:cxc@web.fm randomix: various PRNG's code taken from: http://remus.rutgers.edu/%7Erhoads/Code/code.html let's check it out */ #include #include #include #define SMALLEST_RANGE .0001 #ifndef RAND_MAX #define RAND_MAX 2147483647 #endif static int makeseed(void); static int rand_random_fl(int); static int makeseed(void) { static unsigned int random1_nextseed = 1489853723; random1_nextseed = random1_nextseed * 435898247 + 938284287; return (random1_nextseed & 0x7fffffff); } static int rand_random_fl(seed) { int q; double state; /* The following parameters are recommended settings based on research uncomment the one you want. */ double a = 1389796, m = RAND_MAX; /* static double a = 950975, m = 2147483647; */ /* static double a = 3467255, m = 21474836472; */ /* static double a = 657618, m = 4294967291; */ /* static double a = 93167, m = 4294967291; */ /* static double a = 1345659, m = 4294967291; */ state = seed; state *= a; q = state / m; state -= q*m; return state; } /* ------------------------------- random_fl signal version -------------------- */ static t_class *random_fl_tilde_class; typedef struct _random_fl_tilde { t_object x_obj; unsigned int x_state; // current seed } t_random_fl_tilde; static void *random_fl_tilde_new() { t_random_fl_tilde *x = (t_random_fl_tilde *)pd_new(random_fl_tilde_class); x->x_state = makeseed(); outlet_new(&x->x_obj, gensym("signal")); return (x); } static void random_fl_tilde_seed(t_random_fl_tilde *x, float f, float glob) { x->x_state = f; } static t_int *random_fl_tilde_perform(t_int *w) { t_random_fl_tilde *x = (t_random_fl_tilde *)(w[1]); t_float *out = (t_float *)(w[2]); int n = (int)(w[3]); while (n--) { // generate new noise sample x->x_state = rand_random_fl(x->x_state); *out++ = (t_float)x->x_state / RAND_MAX * 2 - 1; } return (w+4); } static void random_fl_tilde_dsp(t_random_fl_tilde *x, t_signal **sp) { dsp_add(random_fl_tilde_perform, 3, x, sp[0]->s_vec, sp[0]->s_n); } void random_fl_tilde_setup(void) { random_fl_tilde_class = class_new(gensym("random_fl~"), (t_newmethod)random_fl_tilde_new, 0, sizeof(t_random_fl_tilde), 0, 0); class_addmethod(random_fl_tilde_class, (t_method)random_fl_tilde_seed, gensym("seed"), A_FLOAT, 0); class_addmethod(random_fl_tilde_class, (t_method)random_fl_tilde_dsp, gensym("dsp"), 0); } cxc-0.5.2/random_fl.c0000644000076500007650000000723712076107577013103 0ustar hanshans/* (c) 2002:cxc@web.fm randomix: various PRNG's code taken from: http://remus.rutgers.edu/%7Erhoads/Code/code.html let's check it out */ #include #include #include #define SMALLEST_RANGE .0001 #ifndef RAND_MAX #define RAND_MAX 2147483647 #endif static int makeseed(void); static int rand_random_fl(int); static int makeseed(void) { static unsigned int random1_nextseed = 1489853723; random1_nextseed = random1_nextseed * 435898247 + 938284287; return (random1_nextseed & 0x7fffffff); } static int rand_random_fl(seed) { int q; double state; /* The following parameters are recommended settings based on research uncomment the one you want. */ double a = 1389796, m = RAND_MAX; /* static double a = 950975, m = 2147483647; */ /* static double a = 3467255, m = 21474836472; */ /* static double a = 657618, m = 4294967291; */ /* static double a = 93167, m = 4294967291; */ /* static double a = 1345659, m = 4294967291; */ state = seed; state *= a; q = state / m; state -= q*m; return state; } /* -------------------------- random_fl ------------------------------ */ /* An improved (faster) implementation of the Linear Congruential Generator. Has parameters for 6 separate */ /* linear congruence formulas. These formulas are different than those above because the previous formulas won't work */ /* correctly in this implementation. Also, this method only works if your floating point mantissa has at least 53 bits. */ /* linear congruential generator. Generator x[n+1] = a * x[n] mod m */ /* works if your floating pt. mantissa has at least 53 bits. faster than other versions */ static t_class *random_fl_class; typedef struct _random_fl { t_object x_obj; t_float x_f; // lower limit t_float x_g; // upper limit unsigned int x_state; // current seed } t_random_fl; static void *random_fl_new(t_floatarg f, t_floatarg g) { t_random_fl *x = (t_random_fl *)pd_new(random_fl_class); x->x_f = (f) ? f : 0; x->x_g = (g) ? g : RAND_MAX; //post("cxc/randomix.c: lolim: %f - %f, uplim: %f - %f", x->x_f, f, x->x_g, g); x->x_state = makeseed(); inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_float, gensym("fl1")); inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_float, gensym("fl2")); outlet_new(&x->x_obj, &s_float); return (x); } void random_fl_bang(t_random_fl *x) { int n = x->x_f; int q; double nval; double m; m = RAND_MAX; x->x_state = rand_random_fl(x->x_state); nval = ((x->x_state / m) * (double)(x->x_g - x->x_f) + (double)x->x_f); outlet_float(x->x_obj.ob_outlet, nval); } void random_fl_low(t_random_fl *x, t_floatarg f) { if(f >= x->x_g) { post("cxc/randomix.c: lower larger than upper, setting to upper - %f = %f", SMALLEST_RANGE, x->x_g - SMALLEST_RANGE); x->x_f = x->x_g - SMALLEST_RANGE; } else x->x_f = f; } void random_fl_upp(t_random_fl *x, t_floatarg f) { if(f <= x->x_f) { post("cxc/randomix.c: upper smaller than lower, setting to lower + %f = %f", SMALLEST_RANGE, x->x_f + SMALLEST_RANGE); x->x_g = x->x_f + SMALLEST_RANGE; } else x->x_g = f; } static void random_fl_seed(t_random_fl *x, float f, float glob) { x->x_state = f; } void random_fl_setup(void) { random_fl_class = class_new(gensym("random_fl"), (t_newmethod)random_fl_new, 0, sizeof(t_random_fl), 0, A_DEFFLOAT, A_DEFFLOAT, 0); class_addbang(random_fl_class, random_fl_bang); class_addmethod(random_fl_class, (t_method)random_fl_low, gensym("fl1"), A_FLOAT, 0); class_addmethod(random_fl_class, (t_method)random_fl_upp, gensym("fl2"), A_FLOAT, 0); class_addmethod(random_fl_class, (t_method)random_fl_seed, gensym("seed"), A_FLOAT, 0); } cxc-0.5.2/hex2dec-help.pd0000644000076500007650000000134412076107577013564 0ustar hanshans#N canvas 0 31 450 300 10; #X obj 138 153 hex2dec; #X floatatom 137 189 5 0 0 0 - - -; #X msg 139 105 symbol fff; #X msg 237 123 123; #X obj 257 194 print; #X text 136 51 doesn't seem to work; #N canvas 397 200 494 344 META 0; #X text 12 135 HELP_PATCH_AUTHORS Jonathan Wilkes revised the patch to conform to the PDDP template for Pd version 0.42.; #X text 12 55 DESCIPTION hexadecimal to decimal conversion; #X text 12 75 INLET_0 symbol float; #X text 12 95 OUTLET_0 float symbol; #X text 12 5 KEYWORDS control conversion symbol_op needs_work (object doesn't work); #X text 12 35 LICENSE GPL v2; #X text 12 115 AUTHOR jdl@xdv.org; #X restore 394 274 pd META; #X connect 0 0 1 0; #X connect 0 0 4 0; #X connect 2 0 0 0; #X connect 3 0 0 0; cxc-0.5.2/fader-help.pd0000644000076500007650000000144412076107577013324 0ustar hanshans#N canvas 288 386 450 300 10; #X obj 158 159 fader; #X obj 158 204 dac~; #X floatatom 191 131 5 0 0 0 - - -; #X obj 196 102 hsl 128 15 0.1 127 1 0 empty empty empty -2 -8 0 10 -262144 -1 -1 0 1; #X obj 162 74 noise~; #X text 84 25 control the output volume of two channels; #N canvas 42 244 494 344 META 0; #X text 12 25 LICENSE GPL v2; #X text 12 165 AUTHOR jdl@xdv.org; #X text 12 105 INLET_0 audio for left channel; #X text 12 125 INLET_1 audio for right channel; #X text 12 145 INLET_2 volume level (0-100); #X text 12 85 OUTLET_1 audio for right channel; #X text 12 65 OUTLET_0 audio for left channel; #X text 12 45 DESCRIPTION simple volume control; #X restore 386 267 pd META; #X connect 0 0 1 0; #X connect 0 1 1 1; #X connect 2 0 0 2; #X connect 3 0 2 0; #X connect 4 0 0 0; #X connect 4 0 0 1; cxc-0.5.2/cxc_split-help.pd0000644000076500007650000000360312076107577014232 0ustar hanshans#N canvas 0 31 576 417 10; #X msg 239 145 set x; #X msg 172 144 set .; #X obj 25 324 unpack f f f f; #X floatatom 25 354 5 0 0 0 - - -; #X floatatom 67 354 5 0 0 0 - - -; #X floatatom 108 354 5 0 0 0 - - -; #X floatatom 147 354 5 0 0 0 - - -; #X msg 284 91 bli.5.bla.8.90; #X msg 25 59 62.116.7.89; #X msg 113 143 set /; #X msg 158 60 /home/someone/pd/test/patches/bla.pd; #X msg 322 145 set azwejdgb; #X obj 336 236 print; #X text 320 125 only the 1st character is used; #X obj 336 205 cxc_split .; #X obj 25 196 cxc_split .; #X text 110 123 set the delimiter; #X obj 368 308 unpack s s s s; #X symbolatom 367 347 10 0 0 0 - - -; #X symbolatom 449 346 10 0 0 0 - - -; #X msg 56 149 set \$1; #X symbolatom 55 114 10 0 0 0 - - -; #X obj 63 230 print; #X obj 25 299 route list; #X msg 41 89 12.334/345.555/666.666/2389.23; #X text 26 5 split or tokenize the incoming string at the specified delimiter \, digit-only substrings (including the .) are converted to numbers.; #N canvas 397 200 494 344 META 0; #X text 12 135 HELP_PATCH_AUTHORS Jonathan Wilkes revised the patch to conform to the PDDP template for Pd version 0.42.; #X text 12 5 KEYWORDS control list_op symbol_op; #X text 12 45 DESCIPTION split or tokenize the incoming string at the specified delimiter; #X text 12 75 INLET_0 anything; #X text 12 95 OUTLET_0 list float symbol; #X text 12 25 LICENSE GPL v2; #X text 12 115 AUTHOR jdl@xdv.org; #X restore 516 392 pd META; #X connect 0 0 14 0; #X connect 1 0 14 0; #X connect 2 0 3 0; #X connect 2 1 4 0; #X connect 2 2 5 0; #X connect 2 3 6 0; #X connect 7 0 14 0; #X connect 8 0 15 0; #X connect 9 0 14 0; #X connect 10 0 14 0; #X connect 11 0 14 0; #X connect 14 0 12 0; #X connect 14 0 17 0; #X connect 15 0 23 0; #X connect 17 0 18 0; #X connect 17 1 19 0; #X connect 20 0 15 0; #X connect 21 0 20 0; #X connect 23 0 2 0; #X connect 23 0 22 0; #X connect 23 1 2 0; #X connect 23 1 22 0; #X connect 24 0 15 0; cxc-0.5.2/delta~.c0000644000076500007650000000237712076107577012431 0ustar hanshans#include "m_pd.h" #include #ifdef _MSC_VER #pragma warning( disable : 4244 ) #pragma warning( disable : 4305 ) #endif /* ------------------------ delta~ ----------------------------- */ /* tilde object to take difference value. */ static t_class *delta_class; typedef struct _delta { t_object x_obj; t_sample x_last; } t_delta; static t_int *delta_perform(t_int *w) { t_delta *x = (t_delta *)(w[1]); t_float *in = (t_float *)(w[2]); t_float *out = (t_float *)(w[3]); int n = (int)(w[4]); while (n--) { float f = *(in++); // *out++ = (f > 0 ? f : -f); *out++ = (f > x->x_last ? fabs(f - x->x_last) : -fabs(f - x->x_last)); x->x_last = f; } return (w+5); } static void delta_dsp(t_delta *x, t_signal **sp) { dsp_add(delta_perform, 4, x, sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n); } static void *delta_new(void) { t_delta *x = (t_delta *)pd_new(delta_class); x->x_last = 0.; outlet_new(&x->x_obj, gensym("signal")); return (x); } void delta_tilde_setup(void) { delta_class = class_new(gensym("delta~"), (t_newmethod)delta_new, 0, sizeof(t_delta), 0, A_DEFFLOAT, 0); class_addmethod(delta_class, nullfn, gensym("signal"), 0); class_addmethod(delta_class, (t_method)delta_dsp, gensym("dsp"), 0); } cxc-0.5.2/cxc_counter-help.pd0000644000076500007650000000410112076107577014550 0ustar hanshans#N canvas 0 31 497 450 10; #X floatatom 33 260 5 0 0 0 - - -; #X obj 33 37 metro 500; #X obj 33 12 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 0 1 ; #N canvas 144 91 494 389 META 0; #X text 12 215 HELP_PATCH_AUTHORS Jonathan Wilkes revised the patch to conform to the PDDP template for Pd version 0.42.; #X text 12 95 INLET_1 float; #X text 12 45 DESCRIPTION bang on first inlet \, internal counter \, only outputs every arg2th bang; #X text 12 75 INLET_0 bang; #X text 12 115 INLET_2 float; #X text 12 135 INLET_3 float; #X text 12 155 OUTLET_0 float; #X text 12 175 OUTLET_1 bang; #X text 12 5 KEYWORDS control filter bang_op storage; #X text 12 25 LICENSE GPL v2; #X text 12 195 AUTHOR jdl@xdv.org; #X restore 444 427 pd META; #X msg 245 31 fl1 1; #X msg 245 51 fl1 2; #X msg 245 71 fl1 3; #X text 288 31 count up; #X text 288 51 count down; #X text 288 71 count up and down; #X text 30 308 Args:; #X text 22 324 with no arguments: start at 1 \, count to 10 \, repeat ; #X text 22 349 with one argument a: start at 1 \, count up to a \, repeat; #X text 22 369 with two arguments a \, b: start at a \, count up to b \, repeat; #X text 22 389 with three args a \, b \, c: start at a \, count to b \, in direction c; #X msg 245 96 fl2 3; #X text 288 96 set low boundary; #X text 288 121 set high boundary; #X msg 245 121 fl3 6; #X msg 47 106 reset; #X msg 47 136 clear; #X floatatom 54 168 5 0 0 0 - - -; #X text 90 168 direction (1=up \, 2=down \, 3=up & down); #X floatatom 75 189 5 0 0 0 - - -; #X text 114 187 low value; #X floatatom 96 210 5 0 0 0 - - -; #X text 132 210 high value; #X text 124 8 For some reason you can also send the following messages to the leftmost inlet:; #X text 89 120 not sure how these; #X text 101 136 differ...; #X obj 96 260 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144 -1 -1; #X text 115 259 bang each time the counter reaches high/low limit; #X obj 33 233 cxc_counter; #X connect 1 0 32 0; #X connect 2 0 1 0; #X connect 19 0 32 0; #X connect 20 0 32 0; #X connect 21 0 32 1; #X connect 23 0 32 2; #X connect 25 0 32 3; #X connect 32 0 0 0; #X connect 32 1 30 0; cxc-0.5.2/mean~.c0000644000076500007650000002442712076107577012260 0ustar hanshans/* jdl@xdv.org, 200203 calculate mean of buffer standard deviation + histogram */ #include "m_pd.h" #include #include /* cx.mean: calculate the mean from a table */ /* as defined by: add all samples together and divide by number of samples */ t_class *cxmean_class; typedef struct _cxmean { t_object x_obj; t_symbol *x_arrayname; t_float x_mean; float *x_vec; t_float f; int x_nsampsintab; } t_cxmean; static void *cxmean_new(t_symbol *s) { t_cxmean *x = (t_cxmean *)pd_new(cxmean_class); x->x_arrayname = s; x->x_mean = 0; outlet_new(&x->x_obj, &s_float); return (x); } static void cxmean_set(t_cxmean *x, t_symbol *s) { t_garray *a; x->x_arrayname = s; if (!(a = (t_garray *)pd_findbyclass(x->x_arrayname, garray_class))) { if (*s->s_name) pd_error(x, "mean~: %s: no such array", x->x_arrayname->s_name); x->x_vec = 0; } else if (!garray_getfloatarray(a, &x->x_nsampsintab, &x->x_vec)) { error("%s: bad template for mean~", x->x_arrayname->s_name); x->x_vec = 0; } else garray_usedindsp(a); } static void cxmean_bang(t_cxmean *x) { outlet_float(x->x_obj.ob_outlet,x->x_mean); } static void cxmean_mean(t_cxmean *x) { // t_float *bl; t_garray *a; int cnt; t_float *fp; t_float xz = 0.; cnt = 0; if(!(a = (t_garray *)pd_findbyclass(x->x_arrayname,garray_class))) { pd_error(x, "%s: no such table", x->x_arrayname->s_name); } garray_getfloatarray(a,&x->x_nsampsintab,&x->x_vec); fp = x->x_vec; while(cnt < x->x_nsampsintab) { //post("cxc/mean.c: %f",*fp++); xz += *fp++; cnt++; } #ifdef DEBUG post("cxc/mean.c: sampsum: %f",xz); #endif x->x_mean = xz / x->x_nsampsintab; outlet_float(x->x_obj.ob_outlet, x->x_mean); } void cxmean_setup(void) { cxmean_class = class_new(gensym("cxmean"), (t_newmethod)cxmean_new, 0, sizeof(t_cxmean), CLASS_DEFAULT, A_DEFSYM, 0); class_addcreator((t_newmethod)cxmean_new,gensym("cx.mean"),A_DEFSYM, 0); class_addmethod(cxmean_class, (t_method)cxmean_set, gensym("set"), A_DEFSYM, 0); class_addmethod(cxmean_class, (t_method)cxmean_mean, gensym("mean"), A_DEFSYM, 0); class_addbang(cxmean_class, cxmean_bang); class_sethelpsymbol(cxmean_class, gensym("statistics.pd")); } /* cx.avgdev: calculate the average deviation of an array from mean as input and array. takes mean as input, sum of abs values of sample-val - mean divided by number of samples */ t_class *cxavgdev_class; typedef struct _cxavgdev { t_object x_obj; t_symbol *x_arrayname; t_float x_avgdev; float *x_vec; t_float f; int x_nsampsintab; } t_cxavgdev; static void *cxavgdev_new(t_symbol *s) { t_cxavgdev *x = (t_cxavgdev *)pd_new(cxavgdev_class); x->x_arrayname = s; x->x_avgdev = 0; outlet_new(&x->x_obj, &s_float); return (x); } static void cxavgdev_set(t_cxavgdev *x, t_symbol *s) { t_garray *a; x->x_arrayname = s; if (!(a = (t_garray *)pd_findbyclass(x->x_arrayname, garray_class))) { if (*s->s_name) pd_error(x, "mean~: %s: no such array", x->x_arrayname->s_name); x->x_vec = 0; } else if (!garray_getfloatarray(a, &x->x_nsampsintab, &x->x_vec)) { error("%s: bad template for mean~", x->x_arrayname->s_name); x->x_vec = 0; } else garray_usedindsp(a); } static void cxavgdev_bang(t_cxavgdev *x) { outlet_float(x->x_obj.ob_outlet,x->x_avgdev); } static void cxavgdev_float(t_cxavgdev *x, t_float f) { // t_float *bl; t_garray *a; int cnt; t_float *fp; t_float xz = 0.; t_float tz = 0.; cnt = 0; if(!(a = (t_garray *)pd_findbyclass(x->x_arrayname,garray_class))) { pd_error(x, "%s: no such table", x->x_arrayname->s_name); } garray_getfloatarray(a,&x->x_nsampsintab,&x->x_vec); fp = x->x_vec; while(cnt < x->x_nsampsintab) { tz = *fp++; tz = fabs(tz - f); xz += tz; #ifdef DEBUG //post("cxc/mean.c: sampdeviation: %f",tz); #endif cnt++; } #ifdef DEBUG post("cxc/mean.c: avgsum: %f",xz); #endif x->x_avgdev = xz / x->x_nsampsintab; outlet_float(x->x_obj.ob_outlet, x->x_avgdev); } void cxavgdev_setup(void) { cxavgdev_class = class_new(gensym("cxavgdev"), (t_newmethod)cxavgdev_new, 0, sizeof(t_cxavgdev), CLASS_DEFAULT, A_DEFSYM, 0); class_addcreator((t_newmethod)cxavgdev_new,gensym("cx.avgdev"),A_DEFSYM, 0); class_addmethod(cxavgdev_class, (t_method)cxavgdev_set, gensym("set"), A_DEFSYM, 0); /* class_addmethod(cxavgdev_class, (t_method)cxavgdev_mean, */ /* gensym("mean"), A_DEFSYM, 0); */ class_addfloat(cxavgdev_class, (t_method)cxavgdev_float); class_addbang(cxavgdev_class, cxavgdev_bang); class_sethelpsymbol(cxavgdev_class, gensym("statistics.pd")); } /* cx.stddev: calculate the standard deviation of an array from mean as input and array. square root of sum of power of sample - mean divided by num of samps - 1 */ t_class *cxstddev_class; typedef struct _cxstddev { t_object x_obj; t_symbol *x_arrayname; t_float x_stddev; float *x_vec; t_float f; int x_nsampsintab; } t_cxstddev; static void *cxstddev_new(t_symbol *s) { t_cxstddev *x = (t_cxstddev *)pd_new(cxstddev_class); x->x_arrayname = s; x->x_stddev = 0; outlet_new(&x->x_obj, &s_float); return (x); } static void cxstddev_set(t_cxstddev *x, t_symbol *s) { t_garray *a; x->x_arrayname = s; if (!(a = (t_garray *)pd_findbyclass(x->x_arrayname, garray_class))) { if (*s->s_name) pd_error(x, "mean~: %s: no such array", x->x_arrayname->s_name); x->x_vec = 0; } else if (!garray_getfloatarray(a, &x->x_nsampsintab, &x->x_vec)) { error("%s: bad template for mean~", x->x_arrayname->s_name); x->x_vec = 0; } else garray_usedindsp(a); } static void cxstddev_bang(t_cxstddev *x) { outlet_float(x->x_obj.ob_outlet,x->x_stddev); } static void cxstddev_float(t_cxstddev *x, t_float f) { // t_float *bl; t_garray *a; int cnt; t_float *fp; t_float xz = 0.; t_float tz = 0.; cnt = 0; if(!(a = (t_garray *)pd_findbyclass(x->x_arrayname,garray_class))) { pd_error(x, "%s: no such table", x->x_arrayname->s_name); } garray_getfloatarray(a,&x->x_nsampsintab,&x->x_vec); fp = x->x_vec; while(cnt < x->x_nsampsintab) { tz = *fp++; tz = pow(tz - f,2); // power of 2 xz += tz; #ifdef DEBUG //post("cxc/mean.c: sampdeviation: %f",tz); #endif cnt++; } #ifdef DEBUG post("cxc/mean.c: avgsum: %f",xz); #endif x->x_stddev = sqrt(xz / (x->x_nsampsintab - 1)); outlet_float(x->x_obj.ob_outlet, x->x_stddev); } void cxstddev_setup(void) { cxstddev_class = class_new(gensym("cxstddev"), (t_newmethod)cxstddev_new, 0, sizeof(t_cxstddev), CLASS_DEFAULT, A_DEFSYM, 0); class_addcreator((t_newmethod)cxstddev_new,gensym("cx.stddev"),A_DEFSYM, 0); class_addmethod(cxstddev_class, (t_method)cxstddev_set, gensym("set"), A_DEFSYM, 0); /* class_addmethod(cxstddev_class, (t_method)cxstddev_mean, */ /* gensym("mean"), A_DEFSYM, 0); */ class_addfloat(cxstddev_class, (t_method)cxstddev_float); class_addbang(cxstddev_class, cxstddev_bang); class_sethelpsymbol(cxstddev_class, gensym("statistics.pd")); } /* ---------- mean~ ---------- */ /* output the mean as a signal */ t_class *mean_tilde_class; typedef struct _mean_tilde { t_object x_obj; t_symbol *x_arrayname; t_float x_mean; float *x_vec; t_float f; int x_nsampsintab; } t_mean_tilde; static void *mean_tilde_new(t_symbol *s) { t_mean_tilde *x = (t_mean_tilde *)pd_new(mean_tilde_class); x->x_arrayname = s; x->x_mean = 0; outlet_new(&x->x_obj, &s_float); return (x); } static t_int *mean_tilde_perform(t_int *w) { t_mean_tilde *x = (t_mean_tilde *)(w[1]); //t_float *out = (t_float *)(w[3]), t_float *fp; //// t_float *in = (t_float *)(w[2]); //// *out = *in; int n = (int)(w[2]); t_float xz = 0.; fp = x->x_vec; while(n--) { xz += abs(*fp++); //post("cxc/mean.c: %d : %f : %f",n,xz,fp); } x->x_mean = (t_float)(xz / n); //post("cxc/mean.c: %f",xz); return (w+3); //return 0; } static void mean_tilde_set(t_mean_tilde *x, t_symbol *s) { t_garray *a; x->x_arrayname = s; if (!(a = (t_garray *)pd_findbyclass(x->x_arrayname, garray_class))) { if (*s->s_name) pd_error(x, "mean~: %s: no such array", x->x_arrayname->s_name); x->x_vec = 0; } else if (!garray_getfloatarray(a, &x->x_nsampsintab, &x->x_vec)) { error("%s: bad template for mean~", x->x_arrayname->s_name); x->x_vec = 0; } else garray_usedindsp(a); } static void mean_tilde_dsp(t_mean_tilde *x, t_signal **sp) { mean_tilde_set(x, x->x_arrayname); //dsp_add(mean_tilde_perform, 2, x, sp[0]->s_vec, sp[0]->s_n); //dsp_add(mean_tilde_perform, 3, x, sp[0]->s_vec, sp[0]->s_n); dsp_add(mean_tilde_perform, 2, x, sp[0]->s_n); } static void mean_tilde_bang(t_mean_tilde *x) { outlet_float(x->x_obj.ob_outlet,x->x_mean); } static void mean_tilde_mean(t_mean_tilde *x) { // t_float *bl; t_garray *a; int cnt; t_float *fp; t_float xz = 0.; cnt = 0; if(!(a = (t_garray *)pd_findbyclass(x->x_arrayname,garray_class))) { pd_error(x, "%s: no such table", x->x_arrayname->s_name); } garray_getfloatarray(a,&x->x_nsampsintab,&x->x_vec); fp = x->x_vec; while(cnt < x->x_nsampsintab) { //post("cxc/mean.c: %f",*fp++); xz += *fp++; cnt++; } #ifdef DEBUG post("cxc/mean.c: sampsum: %f",xz); #endif x->x_mean = xz / x->x_nsampsintab; outlet_float(x->x_obj.ob_outlet, x->x_mean); } void mean_tilde_setup(void) { //post("mean~ setup"); mean_tilde_class = class_new(gensym("mean~"), (t_newmethod)mean_tilde_new, 0, sizeof(t_mean_tilde), CLASS_DEFAULT, A_DEFSYM, 0); //CLASS_MAINSIGNALIN(mean_tilde_class, t_mean_tilde, f); class_addmethod(mean_tilde_class, nullfn, gensym("signal"), 0); class_addmethod(mean_tilde_class, (t_method)mean_tilde_dsp, gensym("dsp"), 0); class_addmethod(mean_tilde_class, (t_method)mean_tilde_set, gensym("set"), A_DEFSYM, 0); class_addmethod(mean_tilde_class, (t_method)mean_tilde_mean, gensym("mean"), A_DEFSYM, 0); class_addbang(mean_tilde_class, mean_tilde_bang); } cxc-0.5.2/cxc.h0000644000076500007650000000013512076107577011712 0ustar hanshans #include #ifndef L #define L fprintf(stderr,"%s:%d\n",__FILE__,__LINE__); #endif