Imported Upstream version 0.5.1

parents
#N canvas 370 240 625 314 10;
#X obj 147 203 ENV;
#X msg 147 163 RAND_MAX;
#X floatatom 226 253 10 0 0;
#X obj 147 277 print;
#X msg 214 164 getenv \$1;
#X symbolatom 215 130 10 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 386 168 cxc.prepend setenv;
#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;
#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 11 0 12 0;
#X connect 12 0 0 0;
#X connect 14 0 12 0;
#X connect 15 0 6 0;
#X connect 17 0 6 0;
/*
cxc@web.fm, 2002 02
*/
#include "m_pd.h"
#include <stdlib.h>
#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);
}
This diff is collapsed.
This diff is collapsed.
--------------------------
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
-www,dspguide.com
-lena.ucsd.edu/~msp/
-gige.xdv.org/pd
-ftp://iem.kug.ac.at/pd/Externals/ZEXY
-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~ ...
#N canvas 454 117 570 300 10;
#X obj 132 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;
#X msg 83 34 "abcde 123 dsfjnsdf ewrte 3k4n5 3n hjb5465hj 6";
#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;
/* ascii-sequencer
input lists, strings, anythings, output every characters ascii code
jdl@xdv.org 2002
*/
#include "m_pd.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#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;cnt<len;cnt++) { */
/* //printf("'%c'\n",bla[cnt]); */
/* chr = x->x_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;cnt<len;cnt++){ */
/* // printf("'%c'\n",bla[cnt]); */
/* chr = x->x_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);
}
#N canvas 448 258 407 316 10;
#X msg 80 153 bang;
#X floatatom 169 176;
#X floatatom 214 58;
#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 262 ixprint;
#X msg 145 241 \$1;
#N canvas 517 176 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;
#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;
#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;
/* code for foo1 pd class */
#include "m_pd.h"
#include <stdio.h>
#include <stdlib.h>
#ifdef _WIN32
#include <malloc.h>
#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 = 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);
}
#N canvas 203 207 404 226 10;
#X floatatom 85 119;
#X obj 57 175 print;
#X floatatom 45 120;
#X obj 58 146 bfilt 5;
#X text 43 16 bfilt (at the moment) is: modulo something + select 0;
#X floatatom 167 120;
#X obj 139 176 print;
#X floatatom 127 121;
#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;
#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;
/* bangfilter: = % x plus sel 0
* spaeter: % x plus sel y mit 2 arguments
*/
#include "m_pd.h"
#include <math.h>
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);
}
#N canvas 203 207 404 226 10;
#X floatatom 85 119;
#X obj 57 175 print;
#X floatatom 45 120;
#X obj 58 146 bfilt 5;
#X text 43 16 bfilt (at the moment) is: modulo something + select 0;
#X floatatom 167 120;
#X obj 139 176 print;
#X floatatom 127 121;
#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;
#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;