aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIOhannes m zmölnig <zmoelnig@users.sourceforge.net>2007-10-30 09:21:52 +0000
committerIOhannes m zmölnig <zmoelnig@users.sourceforge.net>2007-10-30 09:21:52 +0000
commit5e869f7a0cef88be3b03272303a6084b8bd1a7e3 (patch)
tree8d5e0dfc39eb696f5b457b3376dd6eb7de17b538
parent6d61e2a46722b75c1a3734e3419ee2886b11b2b3 (diff)
use t_float and t_sample when possible
svn path=/trunk/externals/zexy/; revision=8907
-rw-r--r--src/absgn~.c19
-rw-r--r--src/abs~.c13
-rw-r--r--src/avg~.c45
-rw-r--r--src/blockmirror~.c14
-rw-r--r--src/blockshuffle~.c22
-rw-r--r--src/blockswap~.c16
-rw-r--r--src/demultiplex~.c38
-rw-r--r--src/dfreq~.c46
-rw-r--r--src/dirac~.c124
-rw-r--r--src/envrms~.c152
-rw-r--r--src/limiter~.c118
-rw-r--r--src/multiline~.c98
-rw-r--r--src/multiplex~.c52
-rw-r--r--src/noish~.c31
-rw-r--r--src/noisi~.c35
-rw-r--r--src/pack~.c9
-rw-r--r--src/pdf~.c21
-rw-r--r--src/quantize~.c62
-rw-r--r--src/sgn~.c49
-rw-r--r--src/sigzero~.c89
-rw-r--r--src/step~.c122
-rw-r--r--src/swap~.c10
-rw-r--r--src/tavg~.c56
-rw-r--r--src/unpack~.c28
-rw-r--r--src/z~.c28
25 files changed, 657 insertions, 640 deletions
diff --git a/src/absgn~.c b/src/absgn~.c
index aa3e362..2279ade 100644
--- a/src/absgn~.c
+++ b/src/absgn~.c
@@ -16,7 +16,7 @@
typedef struct _absgn
{
t_object x_obj;
- float x_f;
+ t_float x_f;
} t_absgn;
@@ -26,20 +26,20 @@ static t_class *sigABSGN_class;
static t_int *sigABSGN_perform(t_int *w)
{
- t_float *in = (t_float *)(w[1]);
- t_float *out = (t_float *)(w[2]);
- t_float *out2 = (t_float *)(w[3]);
+ t_sample *in = (t_sample *)(w[1]);
+ t_sample *out = (t_sample *)(w[2]);
+ t_sample *out2 = (t_sample *)(w[3]);
int n = (int)(w[4]);
while (n--)
- {
- t_float val = *in++;
+ {
+ t_sample val = *in++;
*out++ = fabsf(val);
if (val>0.) *out2++=1.;
else if (val<0.) *out2++=-1.;
else *out2++=0.;
- }
+ }
return (w+5);
@@ -94,7 +94,8 @@ static void sigABSGN_dsp(t_absgn *x, t_signal **sp)
Z_SIMD_CHKBLOCKSIZE(sp[0]->s_n)&&
Z_SIMD_CHKALIGN(sp[0]->s_vec)&&
Z_SIMD_CHKALIGN(sp[1]->s_vec)&&
- Z_SIMD_CHKALIGN(sp[2]->s_vec)
+ Z_SIMD_CHKALIGN(sp[2]->s_vec)&&
+ ZEXY_TYPE_EQUAL(t_sample, float)
)
{
dsp_add(sigABSGN_performSSE, 4, sp[0]->s_vec, sp[1]->s_vec, sp[2]->s_vec, sp[0]->s_n);
@@ -125,7 +126,7 @@ static void *sigABSGN_new(void)
void absgn_tilde_setup(void)
{
sigABSGN_class = class_new(gensym("absgn~"), (t_newmethod)sigABSGN_new, 0,
- sizeof(t_absgn), 0, A_DEFFLOAT, 0);
+ sizeof(t_absgn), 0, A_DEFFLOAT, 0);
CLASS_MAINSIGNALIN(sigABSGN_class, t_absgn, x_f);
class_addmethod(sigABSGN_class, (t_method)sigABSGN_dsp, gensym("dsp"), 0);
diff --git a/src/abs~.c b/src/abs~.c
index 14001fe..c83e3da 100644
--- a/src/abs~.c
+++ b/src/abs~.c
@@ -25,7 +25,7 @@
typedef struct _abs
{
t_object x_obj;
- float x_f;
+ t_float x_f;
} t_abs;
@@ -35,8 +35,8 @@ static t_class *sigABS_class;
static t_int *sigABS_perform(t_int *w)
{
- t_float *in = (t_float *)(w[1]);
- t_float *out = (t_float *)(w[2]);
+ t_sample *in = (t_sample *)(w[1]);
+ t_sample *out = (t_sample *)(w[2]);
int n = (int)(w[3]);
while (n--) *out++ = fabsf(*in++);
@@ -71,7 +71,7 @@ static t_int *sigABS_performSSE(t_int *w)
* JMZ: the above (using intrinsics) is a little bit slower
* but still about 4* as fast as the generic code
* i prefer using intrinsics as i don't have to learn how to
- * assemble
+ * assembler
*/
asm(
".section .rodata \n"
@@ -119,12 +119,13 @@ static t_int *sigABS_performSSE(t_int *w)
static void sigABS_dsp(t_abs *x, t_signal **sp)
{
- ZEXY_USEVAR(x);
#ifdef __SSE__
if(
Z_SIMD_CHKBLOCKSIZE(sp[0]->s_n)&&
Z_SIMD_CHKALIGN(sp[0]->s_vec)&&
- Z_SIMD_CHKALIGN(sp[1]->s_vec))
+ Z_SIMD_CHKALIGN(sp[1]->s_vec)&&
+ ZEXY_TYPE_EQUAL(t_sample, float)
+ )
{
dsp_add(sigABS_performSSE, 3, sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n);
} else
diff --git a/src/avg~.c b/src/avg~.c
index b035c8e..2096e11 100644
--- a/src/avg~.c
+++ b/src/avg~.c
@@ -24,11 +24,10 @@ static t_class *avg_class;
typedef struct _avg
{
- t_object x_obj;
+ t_object x_obj;
- t_float n_inv;
- t_float buf;
- int blocks;
+ t_float n_inv;
+ int blocks;
} t_avg;
@@ -36,48 +35,48 @@ typedef struct _avg
static t_int *avg_perform(t_int *w)
{
- t_float *in = (t_float *)(w[1]);
+ t_sample *in = (t_sample *)(w[1]);
- t_avg *x = (t_avg *)w[2];
- int n = (int)(w[3]);
+ t_avg *x = (t_avg *)w[2];
+ int n = (int)(w[3]);
- t_float buf = 0.;
+ t_sample buf = 0.;
- while (n--)
+ while (n--)
{
- buf += *in++;
+ buf += *in++;
}
- outlet_float(x->x_obj.ob_outlet, buf*x->n_inv);
+ outlet_float(x->x_obj.ob_outlet, buf*x->n_inv);
- return (w+4);
+ return (w+4);
}
static void avg_dsp(t_avg *x, t_signal **sp)
{
- x->n_inv=1./sp[0]->s_n;
- dsp_add(avg_perform, 3, sp[0]->s_vec, x, sp[0]->s_n);
+ x->n_inv=1./sp[0]->s_n;
+ dsp_add(avg_perform, 3, sp[0]->s_vec, x, sp[0]->s_n);
}
static void *avg_new(void)
{
- t_avg *x = (t_avg *)pd_new(avg_class);
- outlet_new(&x->x_obj, gensym("float"));
- return (x);
+ t_avg *x = (t_avg *)pd_new(avg_class);
+ outlet_new(&x->x_obj, &s_float);
+ return (x);
}
static void avg_help(void)
{
- post("avg~\t:: outputs the arithmetic mean of each signal-vector");
+ post("avg~\t:: outputs the arithmetic mean of each signal-vector");
}
void avg_tilde_setup(void)
{
- avg_class = class_new(gensym("avg~"), (t_newmethod)avg_new, 0,
- sizeof(t_avg), 0, A_DEFFLOAT, 0);
- class_addmethod(avg_class, nullfn, gensym("signal"), 0);
- class_addmethod(avg_class, (t_method)avg_dsp, gensym("dsp"), 0);
+ avg_class = class_new(gensym("avg~"), (t_newmethod)avg_new, 0,
+ sizeof(t_avg), 0, A_DEFFLOAT, 0);
+ class_addmethod(avg_class, nullfn, gensym("signal"), 0);
+ class_addmethod(avg_class, (t_method)avg_dsp, gensym("dsp"), 0);
- class_addmethod(avg_class, (t_method)avg_help, gensym("help"), 0);
+ class_addmethod(avg_class, (t_method)avg_help, gensym("help"), 0);
zexy_register("avg~");
}
diff --git a/src/blockmirror~.c b/src/blockmirror~.c
index c7db690..e32a36c 100644
--- a/src/blockmirror~.c
+++ b/src/blockmirror~.c
@@ -33,7 +33,7 @@ typedef struct _blockmirror
t_object x_obj;
int doit;
int blocksize;
- t_float *blockbuffer;
+ t_sample *blockbuffer;
} t_blockmirror;
static void blockmirror_float(t_blockmirror *x, t_floatarg f)
@@ -44,13 +44,13 @@ static void blockmirror_float(t_blockmirror *x, t_floatarg f)
static t_int *blockmirror_perform(t_int *w)
{
t_blockmirror *x = (t_blockmirror *)(w[1]);
- t_float *in = (t_float *)(w[2]);
- t_float *out = (t_float *)(w[3]);
+ t_sample *in = (t_sample *)(w[2]);
+ t_sample *out = (t_sample *)(w[3]);
int n = (int)(w[4]);
if (x->doit) {
if (in==out){
int N=n;
- t_float *dummy=x->blockbuffer;
+ t_sample *dummy=x->blockbuffer;
while(n--)*dummy++=*in++;
dummy--;
while(N--)*out++=*dummy--;
@@ -65,9 +65,9 @@ static t_int *blockmirror_perform(t_int *w)
static void blockmirror_dsp(t_blockmirror *x, t_signal **sp)
{
if (x->blocksize<sp[0]->s_n){
- if(x->blockbuffer)freebytes(x->blockbuffer, sizeof(t_float)*x->blocksize);
+ if(x->blockbuffer)freebytes(x->blockbuffer, sizeof(*x->blockbuffer)*x->blocksize);
x->blocksize = sp[0]->s_n;
- x->blockbuffer = getbytes(sizeof(t_float)*x->blocksize);
+ x->blockbuffer = getbytes(sizeof(*x->blockbuffer)*x->blocksize);
}
dsp_add(blockmirror_perform, 4, x, sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n);
}
@@ -82,7 +82,7 @@ static void blockmirror_helper(t_blockmirror*x)
static void blockmirror_free(t_blockmirror*x)
{
if(x->blockbuffer)
- freebytes(x->blockbuffer, sizeof(t_float)*x->blocksize);
+ freebytes(x->blockbuffer, sizeof(*x->blockbuffer)*x->blocksize);
x->blockbuffer=0;
}
static void *blockmirror_new(void)
diff --git a/src/blockshuffle~.c b/src/blockshuffle~.c
index d8a337b..41f0301 100644
--- a/src/blockshuffle~.c
+++ b/src/blockshuffle~.c
@@ -67,7 +67,7 @@ static void blockshuffle_list(t_blockshuffle *x, t_symbol*s, int argc, t_atom*ar
x->shuffle=0;
}
x->shufflesize=argc;
- x->shuffle=getbytes(sizeof(t_float)*argc);
+ x->shuffle=getbytes(sizeof(*x->shuffle)*argc);
for(i=0; i<argc; i++){
x->shuffle[i]=atom_getfloat(argv++);
@@ -86,13 +86,13 @@ static t_int *blockshuffle_perform(t_int *w)
t_int *idx =x->indices;
if(idx){
- for(i=0; i<n; i++){
- temp[i]=in[idx[i]];
- }
- temp=x->blockbuf;
- for(i=0; i<n; i++){
- *out++=*temp++;
- }
+ for(i=0; i<n; i++){
+ temp[i]=in[idx[i]];
+ }
+ temp=x->blockbuf;
+ for(i=0; i<n; i++){
+ *out++=*temp++;
+ }
} else
while(n--)*out++=*in++;
@@ -114,9 +114,9 @@ static void blockshuffle_helper(void)
post("outlet : signal~");
}
static void blockshuffle_free(t_blockshuffle *x){
- if(x->indices) freebytes(x->indices, sizeof(t_int) *x->size);
- if(x->blockbuf)freebytes(x->blockbuf, sizeof(t_sample)*x->size);
- if(x->shuffle) freebytes(x->shuffle, sizeof(t_float) *x->shufflesize);
+ if(x->indices) freebytes(x->indices, sizeof(*x->indices) *x->size);
+ if(x->blockbuf)freebytes(x->blockbuf, sizeof(*x->blockbuf)*x->size);
+ if(x->shuffle) freebytes(x->shuffle, sizeof(*x->shuffle) *x->shufflesize);
}
static void *blockshuffle_new(void)
diff --git a/src/blockswap~.c b/src/blockswap~.c
index d8834b7..fe19703 100644
--- a/src/blockswap~.c
+++ b/src/blockswap~.c
@@ -29,7 +29,7 @@ typedef struct _blockswap
t_object x_obj;
int doit;
int blocksize;
- t_float *blockbuffer;
+ t_sample *blockbuffer;
} t_blockswap;
static void blockswap_float(t_blockswap *x, t_floatarg f)
@@ -40,13 +40,13 @@ static void blockswap_float(t_blockswap *x, t_floatarg f)
static t_int *blockswap_perform(t_int *w)
{
t_blockswap *x = (t_blockswap *)(w[1]);
- t_float *in = (t_float *)(w[2]);
- t_float *out = (t_float *)(w[3]);
+ t_sample *in = (t_sample *)(w[2]);
+ t_sample *out = (t_sample *)(w[3]);
int N = (int)(w[4]);
int N2=N/2;
if (x->doit) {
int n=N2;
- t_float *dummy=x->blockbuffer;
+ t_sample *dummy=x->blockbuffer;
while(n--)*dummy++=*in++;
n=N-N2;
while(n--)*out++=*in++;
@@ -60,9 +60,9 @@ static t_int *blockswap_perform(t_int *w)
static void blockswap_dsp(t_blockswap *x, t_signal **sp)
{
if (x->blocksize*2<sp[0]->s_n){
- if(x->blockbuffer)freebytes(x->blockbuffer, sizeof(t_float)*x->blocksize);
+ if(x->blockbuffer)freebytes(x->blockbuffer, sizeof(*x->blockbuffer)*x->blocksize);
x->blocksize = sp[0]->s_n/2;
- x->blockbuffer = getbytes(sizeof(t_float)*x->blocksize);
+ x->blockbuffer = getbytes(sizeof(*x->blockbuffer)*x->blocksize);
}
dsp_add(blockswap_perform, 4, x, sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n);
}
@@ -78,7 +78,7 @@ static void blockswap_helper(t_blockswap *x)
static void blockswap_free(t_blockswap *x)
{
if(x->blockbuffer){
- freebytes(x->blockbuffer, sizeof(t_float)*x->blocksize);
+ freebytes(x->blockbuffer, sizeof(*x->blockbuffer)*x->blocksize);
}
x->blockbuffer=0;
}
@@ -95,7 +95,7 @@ static void *blockswap_new(void)
void blockswap_tilde_setup(void)
{
blockswap_class = class_new(gensym("blockswap~"), (t_newmethod)blockswap_new, 0,
- sizeof(t_blockswap), 0, A_NULL);
+ sizeof(t_blockswap), 0, A_NULL);
class_addmethod(blockswap_class, nullfn, gensym("signal"), 0);
class_addmethod(blockswap_class, (t_method)blockswap_dsp, gensym("dsp"), 0);
diff --git a/src/demultiplex~.c b/src/demultiplex~.c
index 171cd8d..87e54cf 100644
--- a/src/demultiplex~.c
+++ b/src/demultiplex~.c
@@ -85,40 +85,40 @@ static void demux_free(t_demux *x)
static void *demux_new(t_symbol *s, int argc, t_atom *argv)
{
- t_demux *x = (t_demux *)pd_new(demux_class);
- int i;
- ZEXY_USEVAR(s);
- ZEXY_USEVAR(argv);
+ t_demux *x = (t_demux *)pd_new(demux_class);
+ int i;
+ ZEXY_USEVAR(s);
+ ZEXY_USEVAR(argv);
- if (!argc)argc=2;
- x->n_out=argc;
- x->output=0;
+ if (!argc)argc=2;
+ x->n_out=argc;
+ x->output=0;
- while(argc--)outlet_new(&x->x_obj, gensym("signal"));
+ while(argc--)outlet_new(&x->x_obj, gensym("signal"));
- x->out = (t_sample **)getbytes(x->n_out * sizeof(t_sample *));
- i=x->n_out;
- while(i--)x->out[i]=0;
+ x->out = (t_sample **)getbytes(x->n_out * sizeof(t_sample *));
+ i=x->n_out;
+ while(i--)x->out[i]=0;
- return (x);
+ return (x);
}
void demultiplex_tilde_setup(void)
{
- demux_class = class_new(gensym("demultiplex~"), (t_newmethod)demux_new, (t_method)demux_free, sizeof(t_demux), 0, A_GIMME, 0);
- class_addcreator((t_newmethod)demux_new, gensym("demux~"), A_GIMME, 0);
+ demux_class = class_new(gensym("demultiplex~"), (t_newmethod)demux_new, (t_method)demux_free, sizeof(t_demux), 0, A_GIMME, 0);
+ class_addcreator((t_newmethod)demux_new, gensym("demux~"), A_GIMME, 0);
- class_addfloat(demux_class, demux_output);
- class_addmethod(demux_class, (t_method)demux_dsp, gensym("dsp"), 0);
- class_addmethod(demux_class, nullfn, gensym("signal"), 0);
+ class_addfloat(demux_class, demux_output);
+ class_addmethod(demux_class, (t_method)demux_dsp, gensym("dsp"), 0);
+ class_addmethod(demux_class, nullfn, gensym("signal"), 0);
- class_addmethod(demux_class, (t_method)demux_helper, gensym("help"), 0);
+ class_addmethod(demux_class, (t_method)demux_helper, gensym("help"), 0);
zexy_register("demultiplex~");
}
void demux_tilde_setup(void)
{
- demultiplex_tilde_setup();
+ demultiplex_tilde_setup();
}
diff --git a/src/dfreq~.c b/src/dfreq~.c
index 0cec559..376196d 100644
--- a/src/dfreq~.c
+++ b/src/dfreq~.c
@@ -28,35 +28,37 @@ typedef struct _dfreq
{
t_object x_obj;
- t_float freq; /*freqenz variable */
- t_float alt;
- float sampcount;
- t_float sr;
+ t_sample freq; /*frequenz variable */
+ t_sample alt;
+ t_sample sampcount;
+ t_sample sr;
} t_dfreq;
static t_int *dfreq_perform(t_int *w)
{
- t_float *in = (t_float *)(w[1]);
- t_float *out = (t_float *)(w[2]);
+ t_sample *in = (t_sample *)(w[1]);
+ t_sample *out = (t_sample *)(w[2]);
int n = (int)(w[3]);
t_dfreq *x = (t_dfreq *) w[4];
- t_float a = x->alt, c = x->sampcount;
- t_float freq = x->freq, sr=x->sr;
+ t_sample a = x->alt;
+ t_sample c = x->sampcount;
+ t_sample freq = x->freq;
+ t_sample sr=x->sr;
- t_float delta_inv;
+ t_sample delta_inv;
while (n--) {
if( (a * *in) < 0 && (a < *in)){
- /* interpolate for real zerocross */
- delta_inv = 1./(*in-a);
+ /* interpolate for real zerocross */
+ delta_inv = 1./(*in-a);
if(c > 0.0)
- freq = sr / ((t_float) c + a*delta_inv);
+ freq = sr / ((t_sample) c + a*delta_inv);
else
- freq = sr;
+ freq = sr;
c = *in*delta_inv; /*rest of time */
};
@@ -76,7 +78,7 @@ static t_int *dfreq_perform(t_int *w)
static void dfreq_dsp(t_dfreq *x, t_signal **sp)
{
- dsp_add(dfreq_perform, 4, sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n,x);
+ dsp_add(dfreq_perform, 4, sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n,x);
}
@@ -93,19 +95,19 @@ static void *dfreq_new(void)
static void dfreq_tilde_helper(void)
{
- post("\n%c dfreq~\t :: pitch-detector that counts zero-crossings", HEARTSYMBOL);
- post("\noutputs a frequency estimate as a stream~ that will be updated every zero-X");
- post("\ncreation::\t'dfreq~': that's all");
+ post("\n%c dfreq~\t :: pitch-detector that counts zero-crossings", HEARTSYMBOL);
+ post("\noutputs a frequency estimate as a stream~ that will be updated every zero-X");
+ post("\ncreation::\t'dfreq~': that's all");
}
void dfreq_tilde_setup(void)
{
- dfreq_class = class_new(gensym("dfreq~"), (t_newmethod)dfreq_new, 0,
- sizeof(t_dfreq), 0, A_NULL);
- class_addmethod(dfreq_class, nullfn, gensym("signal"), 0);
- class_addmethod(dfreq_class, (t_method)dfreq_dsp, gensym("dsp"), 0);
+ dfreq_class = class_new(gensym("dfreq~"), (t_newmethod)dfreq_new, 0,
+ sizeof(t_dfreq), 0, A_NULL);
+ class_addmethod(dfreq_class, nullfn, gensym("signal"), 0);
+ class_addmethod(dfreq_class, (t_method)dfreq_dsp, gensym("dsp"), 0);
- class_addmethod(dfreq_class, (t_method)dfreq_tilde_helper, gensym("help"), 0);
+ class_addmethod(dfreq_class, (t_method)dfreq_tilde_helper, gensym("help"), 0);
zexy_register("dfreq~");
}
diff --git a/src/dirac~.c b/src/dirac~.c
index b30ab5b..90d9dbb 100644
--- a/src/dirac~.c
+++ b/src/dirac~.c
@@ -38,117 +38,117 @@ static t_class *dirac_class;
typedef struct _dirac
{
- t_object x_obj;
- t_int position;
- t_int do_it;
+ t_object x_obj;
+ t_int position;
+ t_int do_it;
} t_dirac;
static void dirac_bang(t_dirac *x)
{
- x->do_it = x->position;
+ x->do_it = x->position;
}
static void dirac_float(t_dirac *x, t_float where)
{
- x->do_it = x->position = (t_int)where;
+ x->do_it = x->position = (t_int)where;
}
static t_int *dirac_perform(t_int *w)
{
- t_dirac *x = (t_dirac *)(w[1]);
- t_float *out = (t_float *)(w[2]);
- int n = (int)(w[3]);
+ t_dirac *x = (t_dirac *)(w[1]);
+ t_sample *out = (t_sample *)(w[2]);
+ int n = (int)(w[3]);
- t_int do_it = x->do_it;
+ t_int do_it = x->do_it;
- zero_perform(w+1);
+ zero_perform(w+1);
- if (do_it >= n)
- x->do_it -= n;
- else if(do_it >= 0)
- {
- out[do_it] = 1.f;
- x->do_it = -1;
- }
+ if (do_it >= n)
+ x->do_it -= n;
+ else if(do_it >= 0)
+ {
+ out[do_it] = 1.f;
+ x->do_it = -1;
+ }
- return (w+4);
+ return (w+4);
}
static t_int *dirac_perf8(t_int *w)
{
- t_dirac *x = (t_dirac *)(w[1]);
- t_float *out = (t_float *)(w[2]);
- int n = (int)(w[3]);
+ t_dirac *x = (t_dirac *)(w[1]);
+ t_sample *out = (t_sample *)(w[2]);
+ int n = (int)(w[3]);
- t_int do_it = x->do_it;
+ t_int do_it = x->do_it;
#ifndef __WIN32__
- /* LATER: investigate the occurence of zero_perf8() */
- /* it seems, like pd has the symbol zero_perf8(),
- * but it is not exported by m_pd.h:
- * so linux can use it, but w32 not
- * have to tell miller about that
- */
- zero_perf8(w+1);
+ /* LATER: investigate the occurence of zero_perf8() */
+ /* it seems, like pd has the symbol zero_perf8(),
+ * but it is not exported by m_pd.h:
+ * so linux can use it, but w32 not
+ * have to tell miller about that
+ */
+ zero_perf8(w+1);
#else
- zero_perform(w+1);
+ zero_perform(w+1);
#endif
- if (do_it >= n)
- x->do_it -= n;
- else if(do_it >= 0)
- {
- out[do_it] = 1.f;
- x->do_it = -1;
- }
+ if (do_it >= n)
+ x->do_it -= n;
+ else if(do_it >= 0)
+ {
+ out[do_it] = 1.f;
+ x->do_it = -1;
+ }
- return (w+4);
+ return (w+4);
}
static void dirac_dsp(t_dirac *x, t_signal **sp)
{
- if (sp[0]->s_n & 7)
- dsp_add(dirac_perform, 3, x, sp[0]->s_vec, sp[0]->s_n);
- else
- dsp_add(dirac_perf8, 3, x, sp[0]->s_vec, sp[0]->s_n);
+ if (sp[0]->s_n & 7)
+ dsp_add(dirac_perform, 3, x, sp[0]->s_vec, sp[0]->s_n);
+ else
+ dsp_add(dirac_perf8, 3, x, sp[0]->s_vec, sp[0]->s_n);
}
static void dirac_helper(void)
{
- post("%c dirac~-object :: generates a dirac (unity-pulse)", HEARTSYMBOL);
- post("creation : \"dirac~ [<position>]\" : create a dirac at specified position (in samples)\n"
- "inlet\t: <position>\t: create a dirac at new position\n"
- "\t 'bang'\t: create a dirac at specified position\n"
- "\t 'help'\t: view this\n"
- "outlet\t: signal~");
+ post("%c dirac~-object :: generates a dirac (unity-pulse)", HEARTSYMBOL);
+ post("creation : \"dirac~ [<position>]\" : create a dirac at specified position (in samples)\n"
+ "inlet\t: <position>\t: create a dirac at new position\n"
+ "\t 'bang'\t: create a dirac at specified position\n"
+ "\t 'help'\t: view this\n"
+ "outlet\t: signal~");
}
static void *dirac_new(t_floatarg where)
{
- t_dirac *x = (t_dirac *)pd_new(dirac_class);
+ t_dirac *x = (t_dirac *)pd_new(dirac_class);
- outlet_new(&x->x_obj, gensym("signal"));
+ outlet_new(&x->x_obj, gensym("signal"));
- x->do_it = where;
+ x->do_it = where;
- if (where > 0)
- x->position = where;
- else
- x->position = -where;
- return (x);
+ if (where > 0)
+ x->position = where;
+ else
+ x->position = -where;
+ return (x);
}
void dirac_tilde_setup(void)
{
- dirac_class = class_new(gensym("dirac~"), (t_newmethod)dirac_new, 0,
- sizeof(t_dirac), 0, A_DEFFLOAT, 0);
- class_addfloat(dirac_class, dirac_float);
- class_addbang(dirac_class, dirac_bang);
- class_addmethod(dirac_class, (t_method)dirac_dsp, gensym("dsp"), 0);
+ dirac_class = class_new(gensym("dirac~"), (t_newmethod)dirac_new, 0,
+ sizeof(t_dirac), 0, A_DEFFLOAT, 0);
+ class_addfloat(dirac_class, dirac_float);
+ class_addbang(dirac_class, dirac_bang);
+ class_addmethod(dirac_class, (t_method)dirac_dsp, gensym("dsp"), 0);
- class_addmethod(dirac_class, (t_method)dirac_helper, gensym("help"), 0);
+ class_addmethod(dirac_class, (t_method)dirac_helper, gensym("help"), 0);
zexy_register("dirac~");
}
diff --git a/src/envrms~.c b/src/envrms~.c
index 2590346..847b9a3 100644
--- a/src/envrms~.c
+++ b/src/envrms~.c
@@ -27,122 +27,122 @@ t_class *sigenvrms_class;
typedef struct sigenvrms
{
- t_object x_obj; /* header */
- void *x_outlet; /* a "float" outlet */
- void *x_clock; /* a "clock" object */
- float *x_buf; /* a Hanning window */
- int x_phase; /* number of points since last output */
- int x_period; /* requested period of output */
- int x_realperiod; /* period rounded up to vecsize multiple */
- int x_npoints; /* analysis window size in samples */
- float x_result; /* result to output */
- float x_sumbuf[MAXOVERLAP]; /* summing buffer */
+ t_object x_obj; /* header */
+ void *x_outlet; /* a "float" outlet */
+ void *x_clock; /* a "clock" object */
+ t_sample *x_buf; /* a Hanning window */
+ int x_phase; /* number of points since last output */
+ int x_period; /* requested period of output */
+ int x_realperiod; /* period rounded up to vecsize multiple */
+ int x_npoints; /* analysis window size in samples */
+ t_float x_result; /* result to output */
+ t_sample x_sumbuf[MAXOVERLAP]; /* summing buffer */
} t_sigenvrms;
static void sigenvrms_tick(t_sigenvrms *x);
static void *sigenvrms_new(t_floatarg fnpoints, t_floatarg fperiod)
{
- int npoints = fnpoints;
- int period = fperiod;
- t_sigenvrms *x;
- float *buf;
- int i;
-
- if (npoints < 1) npoints = 1024;
- if (period < 1) period = npoints/2;
- if (period < npoints / MAXOVERLAP + 1)
- period = npoints / MAXOVERLAP + 1;
- if (!(buf = getbytes(sizeof(float) * (npoints + MAXVSTAKEN))))
+ int npoints = fnpoints;
+ int period = fperiod;
+ t_sigenvrms *x;
+ t_sample *buf;
+ int i;
+
+ if (npoints < 1) npoints = 1024;
+ if (period < 1) period = npoints/2;
+ if (period < npoints / MAXOVERLAP + 1)
+ period = npoints / MAXOVERLAP + 1;
+ if (!(buf = getbytes(sizeof(*buf) * (npoints + MAXVSTAKEN))))
{
- error("env: couldn't allocate buffer");
- return (0);
+ error("env: couldn't allocate buffer");
+ return (0);
}
- x = (t_sigenvrms *)pd_new(sigenvrms_class);
- x->x_buf = buf;
- x->x_npoints = npoints;
- x->x_phase = 0;
- x->x_period = period;
- for (i = 0; i < MAXOVERLAP; i++) x->x_sumbuf[i] = 0;
- for (i = 0; i < npoints; i++)
- buf[i] = (1. - cos((2 * 3.141592654 * i) / npoints))/npoints;
- for (; i < npoints+MAXVSTAKEN; i++) buf[i] = 0;
- x->x_clock = clock_new(x, (t_method)sigenvrms_tick);
- x->x_outlet = outlet_new(&x->x_obj, gensym("float"));
- return (x);
+ x = (t_sigenvrms *)pd_new(sigenvrms_class);
+ x->x_buf = buf;
+ x->x_npoints = npoints;
+ x->x_phase = 0;
+ x->x_period = period;
+ for (i = 0; i < MAXOVERLAP; i++) x->x_sumbuf[i] = 0;
+ for (i = 0; i < npoints; i++)
+ buf[i] = (1. - cos((2 * 3.141592654 * i) / npoints))/npoints;
+ for (; i < npoints+MAXVSTAKEN; i++) buf[i] = 0;
+ x->x_clock = clock_new(x, (t_method)sigenvrms_tick);
+ x->x_outlet = outlet_new(&x->x_obj, &s_float);
+ return (x);
}
static t_int *sigenvrms_perform(t_int *w)
{
- t_sigenvrms *x = (t_sigenvrms *)(w[1]);
- t_float *in = (t_float *)(w[2]);
- int n = (int)(w[3]);
- int count;
- float *sump;
- in += n;
- for (count = x->x_phase, sump = x->x_sumbuf;
- count < x->x_npoints; count += x->x_realperiod, sump++)
+ t_sigenvrms *x = (t_sigenvrms *)(w[1]);
+ t_sample *in = (t_sample *)(w[2]);
+ int n = (int)(w[3]);
+ int count;
+ t_sample *sump;
+ in += n;
+ for (count = x->x_phase, sump = x->x_sumbuf;
+ count < x->x_npoints; count += x->x_realperiod, sump++)
{
- float *hp = x->x_buf + count;
- float *fp = in;
- float sum = *sump;
- int i;
+ t_sample *hp = x->x_buf + count;
+ t_sample *fp = in;
+ t_sample sum = *sump;
+ int i;
- for (i = 0; i < n; i++)
+ for (i = 0; i < n; i++)
{
- fp--;
- sum += *hp++ * (*fp * *fp);
+ fp--;
+ sum += *hp++ * (*fp * *fp);
}
- *sump = sum;
+ *sump = sum;
}
- sump[0] = 0;
- x->x_phase -= n;
- if (x->x_phase < 0)
+ sump[0] = 0;
+ x->x_phase -= n;
+ if (x->x_phase < 0)
{
- x->x_result = x->x_sumbuf[0];
- for (count = x->x_realperiod, sump = x->x_sumbuf;
- count < x->x_npoints; count += x->x_realperiod, sump++)
- sump[0] = sump[1];
- sump[0] = 0;
- x->x_phase = x->x_realperiod - n;
- clock_delay(x->x_clock, 0L);
+ x->x_result = x->x_sumbuf[0];
+ for (count = x->x_realperiod, sump = x->x_sumbuf;
+ count < x->x_npoints; count += x->x_realperiod, sump++)
+ sump[0] = sump[1];
+ sump[0] = 0;
+ x->x_phase = x->x_realperiod - n;
+ clock_delay(x->x_clock, 0L);
}
- return (w+4);
+ return (w+4);
}
static void sigenvrms_dsp(t_sigenvrms *x, t_signal **sp)
{
- if (x->x_period % sp[0]->s_n) x->x_realperiod =
- x->x_period + sp[0]->s_n - (x->x_period % sp[0]->s_n);
- else x->x_realperiod = x->x_period;
- dsp_add(sigenvrms_perform, 3, x, sp[0]->s_vec, sp[0]->s_n);
- if (sp[0]->s_n > MAXVSTAKEN) bug("sigenvrms_dsp");
+ if (x->x_period % sp[0]->s_n) x->x_realperiod =
+ x->x_period + sp[0]->s_n - (x->x_period % sp[0]->s_n);
+ else x->x_realperiod = x->x_period;
+ dsp_add(sigenvrms_perform, 3, x, sp[0]->s_vec, sp[0]->s_n);
+ if (sp[0]->s_n > MAXVSTAKEN) bug("sigenvrms_dsp");
}
static void sigenvrms_tick(t_sigenvrms *x) /* callback function for the clock */
{
- outlet_float(x->x_outlet, sqrtf(x->x_result));
+ outlet_float(x->x_outlet, sqrtf(x->x_result));
}
static void sigenvrms_ff(t_sigenvrms *x) /* cleanup on free */
{
- clock_free(x->x_clock);
- freebytes(x->x_buf, (x->x_npoints + MAXVSTAKEN) * sizeof(float));
+ clock_free(x->x_clock);
+ freebytes(x->x_buf, (x->x_npoints + MAXVSTAKEN) * sizeof(*x->x_buf));
}
static void sigenvrms_help(void)
{
- post("envrms~\t:: envelope follower that does output rms instead of dB");
+ post("envrms~\t:: envelope follower that does output rms instead of dB");
}
void envrms_tilde_setup(void)
{
- sigenvrms_class = class_new(gensym("envrms~"), (t_newmethod)sigenvrms_new,
- (t_method)sigenvrms_ff, sizeof(t_sigenvrms), 0, A_DEFFLOAT, A_DEFFLOAT, 0);
- class_addmethod(sigenvrms_class, nullfn, gensym("signal"), 0);
- class_addmethod(sigenvrms_class, (t_method)sigenvrms_dsp, gensym("dsp"), 0);
+ sigenvrms_class = class_new(gensym("envrms~"), (t_newmethod)sigenvrms_new,
+ (t_method)sigenvrms_ff, sizeof(t_sigenvrms), 0, A_DEFFLOAT, A_DEFFLOAT, 0);
+ class_addmethod(sigenvrms_class, nullfn, gensym("signal"), 0);
+ class_addmethod(sigenvrms_class, (t_method)sigenvrms_dsp, gensym("dsp"), 0);
- class_addmethod(sigenvrms_class, (t_method)sigenvrms_help, gensym("help"), 0);
+ class_addmethod(sigenvrms_class, (t_method)sigenvrms_help, gensym("help"), 0);
zexy_register("envrms~");
}
diff --git a/src/limiter~.c b/src/limiter~.c
index ee473e6..ef2e039 100644
--- a/src/limiter~.c
+++ b/src/limiter~.c
@@ -16,12 +16,12 @@
/*
- --------------------------------- limiter/compressor ---------------------------------
+ --------------------------------- limiter/compressor ---------------------------------
- for details on how it works watch out for "http://iem.kug.ac.at/~zmoelnig/pd"
- ...and search for "limiter"
+ for details on how it works watch out for "http://iem.kug.ac.at/~zmoelnig/pd"
+ ...and search for "limiter"
- mail2me4more!n4m8ion : zmoelnig@iem.kug.ac.at
+ mail2me4more!n4m8ion : zmoelnig@iem.kug.ac.at
*/
/*
@@ -62,22 +62,22 @@ static t_class *limiter_class;
typedef struct _limctl
{ // variables changed by user
- float limit, hold_samples, change_of_amplification;
+ t_float limit, hold_samples, change_of_amplification;
} t_limctl;
typedef struct _cmpctl
{
- float treshold, ratio; // uclimit is the very same is the limiter1-limit (decalculated relative to our treshold)
- float uclimit, climit_inverse; // climit == compressed limit (uclimit == uncompressed limit)
+ t_float treshold, ratio; // uclimit is the very same is the limiter1-limit (decalculated relative to our treshold)
+ t_float uclimit, climit_inverse; // climit == compressed limit (uclimit == uncompressed limit)
- float limiter_limit; // start limiting (stop compressing); == tresh/limit;
+ t_float limiter_limit; // start limiting (stop compressing); == tresh/limit;
- float treshdB, oneminusratio;
+ t_float treshdB, oneminusratio;
} t_cmpctl;
typedef struct _inbuf
{
- float* ringbuf;
+ t_sample* ringbuf;
int buf_position;
} t_inbuf;
@@ -89,8 +89,8 @@ typedef struct _limiter
// variables changed by process
- float amplification;
- float samples_left, still_left;
+ t_sample amplification;
+ t_float samples_left, still_left;
int mode;
@@ -114,7 +114,7 @@ typedef struct _limiter
// calcs
static t_float calc_holdsamples(t_float htime, int buf)
{ // hold_time must be greater than buffer_time to make sure that any peak_sample is amplified with its own factor
- float min_hold = buf / sys_getsr();
+ t_float min_hold = buf / sys_getsr();
return (0.001 * sys_getsr() * ((htime > min_hold)?htime:((min_hold > 50)?min_hold:50)));
}
@@ -137,10 +137,10 @@ static void set_uclimit(t_limiter *x)
// settings
-static void set_treshold(t_limiter *x, float treshold)
+static void set_treshold(t_limiter *x, t_float treshold)
{
t_cmpctl *c = x->cmp;
- float tresh = dbtorms (treshold);
+ t_float tresh = dbtorms (treshold);
if (tresh > x->val1->limit) tresh = x->val1->limit;
c->treshold = tresh;
@@ -148,7 +148,7 @@ static void set_treshold(t_limiter *x, float treshold)
set_uclimit(x);
}
-static void set_ratio(t_limiter *x, float ratio)
+static void set_ratio(t_limiter *x, t_float ratio)
{
if (ratio < 0) ratio = 1;
x->cmp->ratio = ratio;
@@ -156,7 +156,7 @@ static void set_ratio(t_limiter *x, float ratio)
set_uclimit(x);
}
-static void set_mode(t_limiter *x, float mode)
+static void set_mode(t_limiter *x, t_float mode)
{
int modus = mode;
@@ -192,7 +192,7 @@ static void set_COMPRESS(t_limiter *x)
set_mode(x, COMPRESS);
}
-static void set_bufsize(t_limiter *x, float size)
+static void set_bufsize(t_limiter *x, int size)
{ // this is really unneeded...and for historical reasons only
if (size < BUFSIZE) size = BUFSIZE;
x->buf_size = size + XTRASAMPS;
@@ -358,22 +358,22 @@ static t_int *oversampling_maxima(t_int *w)
{
t_limiter *x = (t_limiter *)w[1];
t_inbuf *buf = (t_inbuf *)w[2];
- t_float *in = (t_float *)w[3];
- t_float *out = (t_float *)w[4];
+ t_sample *in = (t_sample *)w[3];
+ t_sample *out = (t_sample *)w[4];
int n = x->s_n;
int bufsize = x->buf_size;
int i = buf->buf_position;
- t_float *vp = buf->ringbuf, *ep = vp + bufsize, *bp = vp + XTRASAMPS + i;
+ t_sample *vp = buf->ringbuf, *ep = vp + bufsize, *bp = vp + XTRASAMPS + i;
i += n;
while (n--)
{
- t_float os1, os2, max;
- t_float last4, last3, last2, last1, sinccurrent, current, next1, next2, next3, next4;
+ t_sample os1, os2, max;
+ t_sample last4, last3, last2, last1, sinccurrent, current, next1, next2, next3, next4;
if (bp == ep)
{
@@ -436,8 +436,8 @@ static t_int *limiter_perform(t_int *w)
t_limiter *x=(t_limiter *)w[1];
int n = x->s_n;
- t_float *in = (t_float *)w[2];
- t_float *out= (t_float *)w[3];
+ t_sample *in = (t_sample *)w[2];
+ t_sample *out= (t_sample *)w[3];
t_limctl *v1 = (t_limctl *)(x->val1);
t_limctl *v2 = (t_limctl *)(x->val2);
@@ -481,15 +481,15 @@ static t_int *limiter_perform(t_int *w)
amp = limit / max_val;
samplesleft = holdlong;
} else
- {
- if (samplesleft > 0)
- {
- samplesleft--;
- } else
- {
- if ((amp *= coa_long) > 1) amp = 1;
- }
- }
+ {
+ if (samplesleft > 0)
+ {
+ samplesleft--;
+ } else
+ {
+ if ((amp *= coa_long) > 1) amp = 1;
+ }
+ }
*out++ = amp;
*in++ = 0;
@@ -506,28 +506,28 @@ static t_int *limiter_perform(t_int *w)
samplesleft = ((amp = (limit / max_val)) < alimit)?holdshort:holdlong;
stillleft = holdlong;
} else
- {
- if (samplesleft > 0)
- {
- samplesleft--;
- stillleft--;
- } else
- {
- if (amp < alimit)
- {
- if ((amp *= coa_short) > 1) amp = 1;
- } else
- {
- if (stillleft > 0)
- {
- samplesleft = stillleft;
- } else
- {
- if ((amp *= coa_long) > 1) amp = 1;
- }
- }
- }
- }
+ {
+ if (samplesleft > 0)
+ {
+ samplesleft--;
+ stillleft--;
+ } else
+ {
+ if (amp < alimit)
+ {
+ if ((amp *= coa_short) > 1) amp = 1;
+ } else
+ {
+ if (stillleft > 0)
+ {
+ samplesleft = stillleft;
+ } else
+ {
+ if ((amp *= coa_long) > 1) amp = 1;
+ }
+ }
+ }
+ }
*out++ = amp;
*in++ = 0;
}
@@ -572,7 +572,7 @@ static t_int *limiter_perform(t_int *w)
static void limiter_dsp(t_limiter *x, t_signal **sp)
{
int i = 0;
- t_float* sig_buf = (t_float *)getbytes(sizeof(t_float) * sp[0]->s_n);
+ t_sample* sig_buf = (t_sample *)getbytes(sizeof(*sig_buf) * sp[0]->s_n);
x->s_n = sp[0]->s_n;
@@ -622,7 +622,7 @@ static void *limiter_new(t_symbol *s, int argc, t_atom *argv)
while (i < x->number_of_inlets)
{
int n;
- t_float* buf = (float *)getbytes(sizeof(float) * x->buf_size);
+ t_sample* buf = (t_sample *)getbytes(sizeof(*buf) * x->buf_size);
x->in[i].ringbuf = buf;
x->in[i].buf_position = 0;
for (n = 0; n < x->buf_size; n++) x->in[i].ringbuf[n] = 0.;
@@ -653,7 +653,7 @@ static void limiter_free(t_limiter *x)
freebytes(x->val2, sizeof(t_limctl));
freebytes(x->cmp , sizeof(t_cmpctl));
- while (i < x->number_of_inlets) freebytes(x->in[i++].ringbuf, x->buf_size * sizeof(t_float));
+ while (i < x->number_of_inlets) freebytes(x->in[i++].ringbuf, x->buf_size * sizeof(t_sample));
freebytes(x->in, x->number_of_inlets * sizeof(t_inbuf));
}
diff --git a/src/multiline~.c b/src/multiline~.c
index 4eb5e15..f48cc4c 100644
--- a/src/multiline~.c
+++ b/src/multiline~.c
@@ -46,13 +46,13 @@ typedef struct _mline {
t_float msec2tick;
- t_float *value;
- t_float *target;
- t_float *increment; /* single precision is really a bad */
+ t_sample *value;
+ t_sample *target;
+ t_sample *increment; /* single precision is really a bad */
- t_float **sigIN;
- t_float **sigOUT;
- t_float *sigBUF;
+ t_sample **sigIN;
+ t_sample **sigOUT;
+ t_sample *sigBUF;
int sigNUM;
} t_mline;
@@ -103,12 +103,12 @@ static t_int *mline_perform(t_int *w)
t_mline *x = (t_mline *)(w[1]);
int n = (int)(w[2]);
- t_float **out = x->sigOUT;
- t_float **in = x->sigIN;
- t_float *buf = x->sigBUF, *sigBUF = buf;
- t_float *inc = x->increment, *increment = inc;
- t_float *val = x->value, *value = val;
- t_float *tgt = x->target, *target = tgt;
+ t_sample **out = x->sigOUT;
+ t_sample **in = x->sigIN;
+ t_sample *buf = x->sigBUF, *sigBUF = buf;
+ t_sample *inc = x->increment, *increment = inc;
+ t_sample *val = x->value, *value = val;
+ t_sample *tgt = x->target, *target = tgt;
int sigNUM = x->sigNUM;
@@ -123,7 +123,7 @@ static t_int *mline_perform(t_int *w)
if (x->ticksleft) {
int N=n-1;
- t_float oneovernos = 1./(x->ticksleft*n);
+ t_sample oneovernos = 1./(x->ticksleft*n);
int i=sigNUM;
while(i--)*inc++=(*tgt++-*val++)*oneovernos;
@@ -169,7 +169,7 @@ static t_int *mline_perform(t_int *w)
static void mline_dsp(t_mline *x, t_signal **sp)
{
int i = x->sigNUM, n = 0;
- t_float **dummy = x->sigIN;
+ t_sample **dummy = x->sigIN;
while(i--)*dummy++=sp[n++]->s_vec;
i = x->sigNUM;
@@ -197,54 +197,54 @@ static void mline_free(t_mline *x)
static void *mline_new(t_symbol *s, int argc, t_atom *argv)
{
- t_mline *x = (t_mline *)pd_new(mline_class);
- int i;
- ZEXY_USEVAR(s);
+ t_mline *x = (t_mline *)pd_new(mline_class);
+ int i;
+ ZEXY_USEVAR(s);
- if (!argc) {
- argc = 1;
- x->time = 0;
- } else {
- x->time = atom_getfloat(argv+argc-1);
- if (x->time < 0) x->time = 0;
+ if (!argc) {
+ argc = 1;
+ x->time = 0;
+ } else {
+ x->time = atom_getfloat(argv+argc-1);
+ if (x->time < 0) x->time = 0;
- argc--;
- if (!argc) argc = 1;
- }
+ argc--;
+ if (!argc) argc = 1;
+ }
- x->sigNUM = argc;
+ x->sigNUM = argc;
- i = argc-1;
+ i = argc-1;
- outlet_new(&x->x_obj, &s_signal);
+ outlet_new(&x->x_obj, &s_signal);
- while (i--) {
- inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_signal, &s_signal);
- outlet_new(&x->x_obj, &s_signal);
- }
+ while (i--) {
+ inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_signal, &s_signal);
+ outlet_new(&x->x_obj, &s_signal);
+ }
- inlet_new(&x->x_obj, &x->x_obj.ob_pd, gensym("float"), gensym(""));
- floatinlet_new(&x->x_obj, &x->time);
+ inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_float, gensym(""));
+ floatinlet_new(&x->x_obj, &x->time);
- x->sigIN = (t_float **)getbytes(x->sigNUM * sizeof(t_float **));
- x->sigOUT = (t_float **)getbytes(x->sigNUM * sizeof(t_float **));
- x->sigBUF = (t_float *)getbytes(x->sigNUM * sizeof(t_float *));
+ x->sigIN = (t_sample **)getbytes(x->sigNUM * sizeof(t_sample **));
+ x->sigOUT = (t_sample **)getbytes(x->sigNUM * sizeof(t_sample **));
+ x->sigBUF = (t_sample *)getbytes(x->sigNUM * sizeof(t_sample *));
- x->value = (t_float *)getbytes(x->sigNUM * sizeof(t_float *));
- x->target = (t_float *)getbytes(x->sigNUM * sizeof(t_float *));
- x->increment = (t_float *)getbytes(x->sigNUM * sizeof(t_float *));
+ x->value = (t_sample *)getbytes(x->sigNUM * sizeof(t_sample *));
+ x->target = (t_sample *)getbytes(x->sigNUM * sizeof(t_sample *));
+ x->increment = (t_sample *)getbytes(x->sigNUM * sizeof(t_sample *));
- i = x->sigNUM;
+ i = x->sigNUM;
- while (i--) {
- x->sigIN[i] = x->sigOUT[i] = 0;
- x->increment[i] = 0;
- x->value[x->sigNUM-i-1] = x->target[x->sigNUM-i-1] = atom_getfloat(argv+i);
- }
+ while (i--) {
+ x->sigIN[i] = x->sigOUT[i] = 0;
+ x->increment[i] = 0;
+ x->value[x->sigNUM-i-1] = x->target[x->sigNUM-i-1] = atom_getfloat(argv+i);
+ }
- x->msec2tick = x->ticksleft = x->retarget = 0;
+ x->msec2tick = x->ticksleft = x->retarget = 0;
- return (x);
+ return (x);
}
diff --git a/src/multiplex~.c b/src/multiplex~.c
index 78973a5..de8f5e3 100644
--- a/src/multiplex~.c
+++ b/src/multiplex~.c
@@ -28,7 +28,7 @@ typedef struct _mux {
int input;
int n_in;
- t_float **in;
+ t_sample **in;
} t_mux;
static void mux_input(t_mux *x, t_floatarg f)
@@ -43,10 +43,10 @@ static void mux_input(t_mux *x, t_floatarg f)
static t_int *mux_perform(t_int *w)
{
t_mux *x = (t_mux *)(w[1]);
- t_float *out = (t_float *)(w[2]);
+ t_sample *out = (t_sample *)(w[2]);
int n = (int)(w[3]);
- t_float *in = x->in[x->input];
+ t_sample *in = x->in[x->input];
while(n--)*out++=*in++;
@@ -56,7 +56,7 @@ static t_int *mux_perform(t_int *w)
static void mux_dsp(t_mux *x, t_signal **sp)
{
int n = 0;
- t_float **dummy=x->in;
+ t_sample **dummy=x->in;
for(n=0;n<x->n_in;n++)*dummy++=sp[n]->s_vec;
@@ -73,46 +73,46 @@ static void mux_helper(void)
static void mux_free(t_mux *x)
{
- freebytes(x->in, x->n_in * sizeof(t_float *));
+ freebytes(x->in, x->n_in * sizeof(t_sample *));
}
static void *mux_new(t_symbol *s, int argc, t_atom *argv)
{
- t_mux *x = (t_mux *)pd_new(mux_class);
- int i;
- ZEXY_USEVAR(s);
- ZEXY_USEVAR(argv);
+ t_mux *x = (t_mux *)pd_new(mux_class);
+ int i;
+ ZEXY_USEVAR(s);
+ ZEXY_USEVAR(argv);
- if (!argc)argc=2;
- x->n_in=argc;
- x->input=0;
+ if (!argc)argc=2;
+ x->n_in=argc;
+ x->input=0;
- argc--;
- while(argc--)inlet_new(&x->x_obj,&x->x_obj.ob_pd,&s_signal,&s_signal);
+ argc--;
+ while(argc--)inlet_new(&x->x_obj,&x->x_obj.ob_pd,&s_signal,&s_signal);
- x->in = (t_float **)getbytes(x->n_in * sizeof(t_float *));
- i=x->n_in;
- while(i--)x->in[i]=0;
+ x->in = (t_sample **)getbytes(x->n_in * sizeof(t_sample *));
+ i=x->n_in;
+ while(i--)x->in[i]=0;
- outlet_new(&x->x_obj, gensym("signal"));
+ outlet_new(&x->x_obj, gensym("signal"));
- return (x);
+ return (x);
}
void multiplex_tilde_setup(void)
{
- mux_class = class_new(gensym("multiplex~"), (t_newmethod)mux_new, (t_method)mux_free, sizeof(t_mux), 0, A_GIMME, 0);
- class_addcreator((t_newmethod)mux_new, gensym("mux~"), A_GIMME, 0);
+ mux_class = class_new(gensym("multiplex~"), (t_newmethod)mux_new, (t_method)mux_free, sizeof(t_mux), 0, A_GIMME, 0);
+ class_addcreator((t_newmethod)mux_new, gensym("mux~"), A_GIMME, 0);
- class_addfloat(mux_class, mux_input);
- class_addmethod(mux_class, (t_method)mux_dsp, gensym("dsp"), 0);
- class_addmethod(mux_class, nullfn, gensym("signal"), 0);
+ class_addfloat(mux_class, mux_input);
+ class_addmethod(mux_class, (t_method)mux_dsp, gensym("dsp"), 0);
+ class_addmethod(mux_class, nullfn, gensym("signal"), 0);
- class_addmethod(mux_class, (t_method)mux_helper, gensym("help"), 0);
+ class_addmethod(mux_class, (t_method)mux_helper, gensym("help"), 0);
zexy_register("multiplex~");
}
void mux_tilde_setup(void)
{
- multiplex_tilde_setup();
+ multiplex_tilde_setup();
}
diff --git a/src/noish~.c b/src/noish~.c
index a237e71..dba7770 100644
--- a/src/noish~.c
+++ b/src/noish~.c
@@ -41,10 +41,10 @@ typedef struct _nois
{
t_object x_obj;
int val;
- t_float current;
- t_float decrement;
- t_float updater;
- t_float to_go;
+ t_sample current;
+ t_sample decrement;
+ t_sample updater;
+ t_sample to_go;
} t_nois;
@@ -59,6 +59,11 @@ static void set_freq(t_nois *x, t_floatarg freq)
}
+static void set_noisseed(t_nois *x, t_floatarg seed)
+{
+ x->val = seed;
+}
+
/* ------------------------ noish~ ----------------------------- */
static t_class *noish_class;
@@ -66,15 +71,15 @@ static t_class *noish_class;
static t_int *noish_perform(t_int *w)
{
t_nois *x = (t_nois *)(w[1]);
- t_float *out = (t_float *)(w[2]);
+ t_sample *out = (t_sample *)(w[2]);
int n = (int)(w[3]);
int *vp = (int *)(&x->val);
int i_value = *vp;
- t_float f_value = ((float)((i_value & 0x7fffffff) - 0x40000000)) *
- (float)(1.0 / 0x40000000);
- t_float all_to_go = x->updater;
- t_float still_to_go = x->to_go;
+ t_sample f_value = ((t_sample)((i_value & 0x7fffffff) - 0x40000000)) *
+ (t_sample)(1.0 / 0x40000000);
+ t_sample all_to_go = x->updater;
+ t_sample still_to_go = x->to_go;
if (all_to_go == 1)
{ /* this is "pure white" noise, so we have to calculate each sample */
@@ -82,7 +87,7 @@ static t_int *noish_perform(t_int *w)
{
i_value *= 435898247;
i_value += 382842987;
- *out++ = ((float)((i_value & 0x7fffffff) - 0x40000000)) * (float)(1.0 / 0x40000000);
+ *out++ = ((t_sample)((i_value & 0x7fffffff) - 0x40000000)) * (t_sample)(1.0 / 0x40000000);
}
}
else
@@ -107,7 +112,7 @@ static t_int *noish_perform(t_int *w)
i_value *= 435898247;
i_value += 382842987;
- f_value = ( (float)((i_value & 0x7fffffff) - 0x40000000) ) * (float)(1.0 / 0x40000000);
+ f_value = ( (t_sample)((i_value & 0x7fffffff) - 0x40000000) ) * (t_sample)(1.0 / 0x40000000);
while (n--)
{
@@ -126,7 +131,7 @@ static t_int *noish_perform(t_int *w)
i_value *= 435898247;
i_value += 382842987;
- f_value = ( (float)((i_value & 0x7fffffff) - 0x40000000) ) * (float)(1.0 / 0x40000000);
+ f_value = ( (t_sample)((i_value & 0x7fffffff) - 0x40000000) ) * (t_sample)(1.0 / 0x40000000);
}
*out++ = f_value;
}
@@ -179,6 +184,8 @@ void noish_tilde_setup(void)
class_addfloat(noish_class, set_freq);
class_addmethod(noish_class, (t_method)noish_dsp, gensym("dsp"), 0);
+ class_addmethod(noish_class, (t_method)set_noisseed, gensym("seed"), A_FLOAT, 0);
+
class_addmethod(noish_class, (t_method)noish_helper, gensym("help"), 0);
zexy_register("noish~");
}
diff --git a/src/noisi~.c b/src/noisi~.c
index 0fb42e1..e42cd74 100644
--- a/src/noisi~.c
+++ b/src/noisi~.c
@@ -41,10 +41,10 @@ typedef struct _nois
{
t_object x_obj;
int val;
- t_float current;
- t_float decrement;
- t_float updater;
- t_float to_go;
+ t_sample current;
+ t_sample decrement;
+ t_sample updater;
+ t_sample to_go;
} t_nois;
@@ -58,21 +58,28 @@ static void set_noisfreq(t_nois *x, t_floatarg freq)
x->to_go = 0;
}
+
+static void set_noisseed(t_nois *x, t_floatarg seed)
+{
+ x->val = seed;
+}
+
+
+
/* ------------------------ noisi~ ----------------------------- */
static t_class *noisi_class;
static t_int *noisi_perform(t_int *w){
t_nois *x = (t_nois *)(w[1]);
- t_float *out = (t_float *)(w[2]);
+ t_sample *out = (t_sample *)(w[2]);
int n = (int)(w[3]);
- int *vp = (int *)(&x->val); /* what the ... */
- int i_value = *vp;
- t_float f_value = x->current;
- t_float decrement = x->decrement;
- t_float all_to_go = x->updater;
- t_float still_to_go = x->to_go;
+ int i_value = x->val;
+ t_sample f_value = x->current;
+ t_sample decrement = x->decrement;
+ t_sample all_to_go = x->updater;
+ t_sample still_to_go = x->to_go;
if (all_to_go == 1) {
/* this is "pure white" noise, so we have to calculate each sample */
@@ -98,7 +105,7 @@ static t_int *noisi_perform(t_int *w){
(f_value =
((t_sample)((i_value & 0x7fffffff)-0x40000000))*(t_sample)(1.0 / 0x40000000)) -
((t_sample)(((i_value = i_value * 435898247 + 382842987) & 0x7fffffff)
- - 0x40000000)) * (t_sample)(1.0 / 0x40000000)
+ - 0x40000000)) * (t_sample)(1.0 / 0x40000000)
) / all_to_go;
while (n--) {
@@ -119,7 +126,7 @@ static t_int *noisi_perform(t_int *w){
}
}
- *vp = i_value;
+ x->val = i_value;
x->current = f_value;
x->decrement = decrement;
x->to_go = still_to_go;
@@ -162,6 +169,8 @@ void noisi_tilde_setup(void){
class_addfloat(noisi_class, set_noisfreq);
class_addmethod(noisi_class, (t_method)noisi_dsp, gensym("dsp"), 0);
+ class_addmethod(noisi_class, (t_method)set_noisseed, gensym("seed"), A_FLOAT, 0);
+
class_addmethod(noisi_class, (t_method)noisi_helper, gensym("help"), 0);
zexy_register("noisi~");
}
diff --git a/src/pack~.c b/src/pack~.c
index 1f19c72..ab904b0 100644
--- a/src/pack~.c
+++ b/src/pack~.c
@@ -33,15 +33,18 @@ typedef struct _sigpack
static t_int *sigpack_perform(t_int *w)
{
- t_float *in = (t_float *)(w[1]);
+ t_sample *in = (t_sample *)(w[1]);
t_sigpack *x = (t_sigpack *)w[2];
int n = (int)(w[3]), i = 0;
t_atom *buf = x->buffer;
while (n--) {
- SETFLOAT(&buf[i], *in++);
+ t_float f=*in++;
+ SETFLOAT(&buf[i], f);
i++;
}
+#warning defer list-output to next block with a clock!
+
outlet_list(x->x_obj.ob_outlet, &s_list, x->vector_length, x->buffer);
return (w+4);
@@ -75,7 +78,7 @@ static void sigpack_help(void)
void pack_tilde_setup(void)
{
sigpack_class = class_new(gensym("pack~"), (t_newmethod)sigpack_new, 0,
- sizeof(t_sigpack), 0, A_DEFFLOAT, 0);
+ sizeof(t_sigpack), 0, A_DEFFLOAT, 0);
class_addmethod(sigpack_class, nullfn, gensym("signal"), 0);
class_addmethod(sigpack_class, (t_method)sigpack_dsp, gensym("dsp"), 0);
diff --git a/src/pdf~.c b/src/pdf~.c
index 76c9dcc..8d53512 100644
--- a/src/pdf~.c
+++ b/src/pdf~.c
@@ -68,7 +68,7 @@ static void pdf_float(t_pdf *x, t_floatarg f)
static t_int *pdf_perform(t_int *w)
{
- t_float *in = (t_float *)(w[1]);
+ t_sample *in = (t_sample *)(w[1]);
t_pdf *x = (t_pdf *)(w[2]);
int n = (int)(w[3]);
@@ -77,7 +77,7 @@ static t_int *pdf_perform(t_int *w)
while (n--)
{
- t_float f = *in++;
+ t_sample f = *in++;
int iindex = ((f + 1.0) * halfsize)+0.5;
buf[(iindex<0)?0:((iindex>=x->size)?x->size-1:iindex)]+=1.;
}
@@ -98,7 +98,7 @@ static void *pdf_new(t_floatarg f)
t_float *buf;
x->size = (i)?i:64;
- x->buf = (t_float *)getbytes(x->size * sizeof(t_float));
+ x->buf = (t_float *)getbytes(x->size * sizeof(*x->buf));
buf = x->buf;
clear_pdfbuf(x);
@@ -109,17 +109,18 @@ static void *pdf_new(t_floatarg f)
static void pdf_free(t_pdf *x)
{
- freebytes(x->buf, x->size*sizeof(t_float));
+ if(x->buf)
+ freebytes(x->buf, x->size*sizeof(*x->buf));
}
static void pdf_tilde_helper(void)
{
- post("\n%c pdf~\t:: get the probability density function of a signal (-1.0 to +1.0)", HEARTSYMBOL);
- post("'bang'\t : output a list of the probabilities of 'n' function values"
- "\n'clear'\t : clear the buffer (set all probabilities to zero)"
- "\n<1/0>\t : short for 'bang' and 'clear'"
- "\n'help'\t : view this");
- post("creation :: 'pdf~ [<n>]':: get the pdf for <n> (default: 64) values");
+ post("\n%c pdf~\t:: get the probability density function of a signal (-1.0 to +1.0)", HEARTSYMBOL);
+ post("'bang'\t : output a list of the probabilities of 'n' function values"
+ "\n'clear'\t : clear the buffer (set all probabilities to zero)"
+ "\n<1/0>\t : short for 'bang' and 'clear'"
+ "\n'help'\t : view this");
+ post("creation :: 'pdf~ [<n>]':: get the pdf for <n> (default: 64) values");
}
void pdf_tilde_setup(void)
diff --git a/src/quantize~.c b/src/quantize~.c
index bb6a759..a87e3e4 100644
--- a/src/quantize~.c
+++ b/src/quantize~.c
@@ -30,71 +30,71 @@ static t_class *quantize_class;
typedef struct _quantize
{
- t_object x_obj;
- t_float quantiz, dequantiz;
+ t_object x_obj;
+ t_sample quantiz, dequantiz;
} t_quantize;
static void quantize_float(t_quantize *x, t_floatarg f)
{
- x->quantiz = f;
- x->dequantiz = 1./f;
+ x->quantiz = f;
+ x->dequantiz = 1./f;
}
static void quantize_16bit(t_quantize *x)
{
- x->quantiz = 32768.;
- x->dequantiz = 1./32768.;
+ x->quantiz = 32768.;
+ x->dequantiz = 1./32768.;
}
static void quantize_8bit(t_quantize *x)
{
- x->quantiz = 128.;
- x->dequantiz = 1./128.;
+ x->quantiz = 128.;
+ x->dequantiz = 1./128.;
}
static t_int *quantize_perform(t_int *w)
{
- t_quantize *x = (t_quantize *)(w[1]);
- t_float *in = (t_float *)(w[2]);
- t_float *out = (t_float *)(w[3]);
- int n = (int)(w[4]);
+ t_quantize *x = (t_quantize *)(w[1]);
+ t_sample *in = (t_sample *)(w[2]);
+ t_sample *out = (t_sample *)(w[3]);
+ int n = (int)(w[4]);
- t_float quantiz = x->quantiz, dequantiz = x->dequantiz;
+ t_sample quantiz = x->quantiz, dequantiz = x->dequantiz;
- if (quantiz)
- while (n--) *out++ = dequantiz*(int)(quantiz**in++);
- else while (n--) *out++ = *in++;
+ if (quantiz)
+ while (n--) *out++ = dequantiz*(int)(quantiz**in++);
+ else while (n--) *out++ = *in++;
- return (w+5);
+ return (w+5);
}
static void quantize_dsp(t_quantize *x, t_signal **sp)
{
- dsp_add(quantize_perform, 4, x, sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n);
+ dsp_add(quantize_perform, 4, x, sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n);
}
static void quantize_tilde_helper(t_quantize *x)
{
ZEXY_USEVAR(x);
- post("%c quantize~-object\t:: used for quantizing signals by various degrees", HEARTSYMBOL);
- post("<quants> : quantize a signal into <quants> steps ('0' turns quantizing off)\n"
- "'8bit' : quantize to 8 bit\n"
- "'16bit' : quantize to 16 bit (default)\n"
- "'float' : pass-through the signal unchanged\n"
- "'help' : view this\n"
- "signal~\n");
- post("creation:: \"quantize~ [<quants>]\"");
+ post("%c quantize~-object\t:: used for quantizing signals by various degrees", HEARTSYMBOL);
+ post("<quants> : quantize a signal into <quants> steps ('0' turns quantizing off)\n"
+ "'8bit' : quantize to 8 bit\n"
+ "'16bit' : quantize to 16 bit (default)\n"
+ "'float' : pass-through the signal unchanged\n"
+ "'help' : view this\n"
+ "signal~\n");
+ post("creation:: \"quantize~ [<quants>]\"");
}
static void *quantize_new(t_floatarg f)
{
- t_quantize *x = (t_quantize *)pd_new(quantize_class);
- outlet_new(&x->x_obj, gensym("signal"));
- if (f) quantize_float(x, f);
- else quantize_16bit(x);
+ t_quantize *x = (t_quantize *)pd_new(quantize_class);
+ outlet_new(&x->x_obj, gensym("signal"));
+ if (f) quantize_float(x, f);
+ else quantize_16bit(x);
- return (x);
+ return (x);
}
void quantize_tilde_setup(void)
diff --git a/src/sgn~.c b/src/sgn~.c
index d139a5d..2797916 100644
--- a/src/sgn~.c
+++ b/src/sgn~.c
@@ -34,10 +34,10 @@ static t_class *sgnTilde_class;
static t_int *sgnTilde_perform(t_int *w)
{
- t_float *in = (t_float *)(w[1]);
- t_float *out = (t_float *)(w[2]);
+ t_sample *in = (t_sample *)(w[1]);
+ t_sample *out = (t_sample *)(w[2]);
int n = (int)(w[3]);
- t_float x;
+ t_sample x;
while (n--) {
if ((x=*in++)>0.) *out++=1.;
else if (x<0.) *out++=-1.;
@@ -48,25 +48,25 @@ static t_int *sgnTilde_perform(t_int *w)
}
static t_int *sgnTilde_perform8(t_int *w)
{
- t_float *in = (t_float *)(w[1]);
- t_float *out = (t_float *)(w[2]);
+ t_sample *in = (t_sample *)(w[1]);
+ t_sample *out = (t_sample *)(w[2]);
int n = (int)(w[3])>>3;
- t_float x;
-
- while(n--){
- /* weirdly enough, the if/else/if/else is a lot faster than ()?:(()?:) */
- if ((x=in[0])>0.) out[0]=1.; else if(x<0.) out[0]=-1.; else out[0]=0.;
- if ((x=in[1])>0.) out[1]=1.; else if(x<0.) out[1]=-1.; else out[1]=0.;
- if ((x=in[2])>0.) out[2]=1.; else if(x<0.) out[2]=-1.; else out[2]=0.;
- if ((x=in[3])>0.) out[3]=1.; else if(x<0.) out[3]=-1.; else out[3]=0.;
- if ((x=in[4])>0.) out[4]=1.; else if(x<0.) out[4]=-1.; else out[4]=0.;
- if ((x=in[5])>0.) out[5]=1.; else if(x<0.) out[5]=-1.; else out[5]=0.;
- if ((x=in[6])>0.) out[6]=1.; else if(x<0.) out[6]=-1.; else out[6]=0.;
- if ((x=in[7])>0.) out[7]=1.; else if(x<0.) out[7]=-1.; else out[7]=0.;
-
- in+=8;
- out+=8;
- }
+ t_sample x;
+
+ while(n--){
+ /* weirdly enough, the if/else/if/else is a lot faster than ()?:(()?:) */
+ if ((x=in[0])>0.) out[0]=1.; else if(x<0.) out[0]=-1.; else out[0]=0.;
+ if ((x=in[1])>0.) out[1]=1.; else if(x<0.) out[1]=-1.; else out[1]=0.;
+ if ((x=in[2])>0.) out[2]=1.; else if(x<0.) out[2]=-1.; else out[2]=0.;
+ if ((x=in[3])>0.) out[3]=1.; else if(x<0.) out[3]=-1.; else out[3]=0.;
+ if ((x=in[4])>0.) out[4]=1.; else if(x<0.) out[4]=-1.; else out[4]=0.;
+ if ((x=in[5])>0.) out[5]=1.; else if(x<0.) out[5]=-1.; else out[5]=0.;
+ if ((x=in[6])>0.) out[6]=1.; else if(x<0.) out[6]=-1.; else out[6]=0.;
+ if ((x=in[7])>0.) out[7]=1.; else if(x<0.) out[7]=-1.; else out[7]=0.;
+
+ in+=8;
+ out+=8;
+ }
return (w+4);
}
@@ -111,12 +111,13 @@ static t_int *sgnTilde_performSSE(t_int *w)
static void sgnTilde_dsp(t_sgnTilde *x, t_signal **sp)
{
- ZEXY_USEVAR(x);
#ifdef __SSE__
if(
Z_SIMD_CHKBLOCKSIZE(sp[0]->s_n)&&
Z_SIMD_CHKALIGN(sp[0]->s_vec)&&
- Z_SIMD_CHKALIGN(sp[1]->s_vec))
+ Z_SIMD_CHKALIGN(sp[1]->s_vec)&&
+ ZEXY_TYPE_EQUAL(t_sample, float) // currently SSE2 code is only for float (not for double)
+ )
{
dsp_add(sgnTilde_performSSE, 3, sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n);
} else
@@ -145,7 +146,7 @@ static void *sgnTilde_new(void)
void sgn_tilde_setup(void)
{
sgnTilde_class = class_new(gensym("sgn~"), (t_newmethod)sgnTilde_new, 0,
- sizeof(t_sgnTilde), 0, A_DEFFLOAT, 0);
+ sizeof(t_sgnTilde), 0, A_DEFFLOAT, 0);
class_addmethod(sgnTilde_class, nullfn, gensym("signal"), 0);
class_addmethod(sgnTilde_class, (t_method)sgnTilde_dsp, gensym("dsp"), 0);
diff --git a/src/sigzero~.c b/src/sigzero~.c
index bbedc9e..85012d7 100644
--- a/src/sigzero~.c
+++ b/src/sigzero~.c
@@ -15,8 +15,8 @@
/* ------------------------ sigzero~ ----------------------------- */
/*
- a very useful function, which detects, whether a signal is zeroes-only this block or not
- this is really great together with the "switch~"-object
+ a very useful function, which detects, whether a signal is zeroes-only this block or not
+ this is really great together with the "switch~"-object
*/
#include "zexy.h"
@@ -26,65 +26,64 @@ static t_class *sigzero_class;
typedef struct _sigzero
{
- t_object x_obj;
- int activate;
- int current; /* 0 == (signalblock == 0); 1==(signalblock != 0) */
+ t_object x_obj;
+ int activate;
+ int current; /* 0 == (signalblock == 0); 1==(signalblock != 0) */
} t_sigzero;
static void sigzero_activate(t_sigzero *x, t_floatarg activate)
{
- x->activate = (activate)?1:0;
+ x->activate = (activate)?1:0;
}
static void sigzero_banged(t_sigzero *x)
{
- x->activate = 1;
+ x->activate = 1;
}
static void sigzero_off(t_sigzero *x)
{
- x->activate = 0;
+ x->activate = 0;
}
static t_int *sigzero_perform(t_int *w)
{
- t_float *in = (t_float *)w[1];
- t_sigzero *x = (t_sigzero *)w[2];
- int n = (int)w[3];
-
- int non_zero = 0;
-
- if (x->activate) {
- while (n--)
- {
- if (*in++ != 0.) {
- non_zero = 1;
- break;
- }
- }
- if (non_zero != x->current) {
- outlet_float(x->x_obj.ob_outlet, x->current = non_zero);
- }
-// else post("non_zero=%d\tcurrent=%d", non_zero, x->current);
- }
-
- return (w+4);
+ t_sample *in = (t_sample *)w[1];
+ t_sigzero *x = (t_sigzero *)w[2];
+ int n = (int)w[3];
+
+ int non_zero = 0;
+
+ if (x->activate) {
+ while (n--)
+ {
+ if (*in++ != 0.) {
+ non_zero = 1;
+ break;
+ }
+ }
+ if (non_zero != x->current) {
+ outlet_float(x->x_obj.ob_outlet, x->current = non_zero);
+ }
+ }
+
+ return (w+4);
}
static void sigzero_dsp(t_sigzero *x, t_signal **sp)
{
- dsp_add(sigzero_perform, 3, sp[0]->s_vec, x, sp[0]->s_n);
+ dsp_add(sigzero_perform, 3, sp[0]->s_vec, x, sp[0]->s_n);
}
static void sigzero_tilde_helper(void)
{
- post("\n%c sigzero~-object :: for detecting whether a signal is currently zero or not", HEARTSYMBOL);
- post("'bang'\t: turn the detector on\n"
- "'off'\t: turn it off\n"
- "<1/0>\t: turn it on/off\n"
- "'help'\t: view this\n"
- "signal~");
- post("outlet :: 1/0\t: signal turned to non-zero/zero\n");
+ post("\n%c sigzero~-object :: for detecting whether a signal is currently zero or not", HEARTSYMBOL);
+ post("'bang'\t: turn the detector on\n"
+ "'off'\t: turn it off\n"
+ "<1/0>\t: turn it on/off\n"
+ "'help'\t: view this\n"
+ "signal~");
+ post("outlet :: 1/0\t: signal turned to non-zero/zero\n");
}
static void *sigzero_new(void)
@@ -96,15 +95,15 @@ static void *sigzero_new(void)
void sigzero_tilde_setup(void)
{
- sigzero_class = class_new(gensym("sigzero~"), (t_newmethod)sigzero_new, 0,
- sizeof(t_sigzero), 0, 0);
- class_addfloat(sigzero_class, sigzero_activate);
- class_addbang(sigzero_class, sigzero_banged);
- class_addmethod(sigzero_class, (t_method)sigzero_off, gensym("off"), 0);
+ sigzero_class = class_new(gensym("sigzero~"), (t_newmethod)sigzero_new, 0,
+ sizeof(t_sigzero), 0, 0);
+ class_addfloat(sigzero_class, sigzero_activate);
+ class_addbang(sigzero_class, sigzero_banged);
+ class_addmethod(sigzero_class, (t_method)sigzero_off, gensym("off"), 0);
- class_addmethod(sigzero_class, nullfn, gensym("signal"), 0);
- class_addmethod(sigzero_class, (t_method)sigzero_dsp, gensym("dsp"), 0);
+ class_addmethod(sigzero_class, nullfn, gensym("signal"), 0);
+ class_addmethod(sigzero_class, (t_method)sigzero_dsp, gensym("dsp"), 0);
- class_addmethod(sigzero_class, (t_method)sigzero_tilde_helper, gensym("help"), 0);
+ class_addmethod(sigzero_class, (t_method)sigzero_tilde_helper, gensym("help"), 0);
zexy_register("sigzero~");
}
diff --git a/src/step~.c b/src/step~.c
index fbc15d2..9b6fed1 100644
--- a/src/step~.c
+++ b/src/step~.c
@@ -14,15 +14,15 @@
******************************************************/
/*
-step~ : will make a unity step at a desired point in the signal-vector; the second input specifies a
- length: after the so-specified time has elapsed, the step will toggle back to the previous
- value;
- the length can be passed as an argument when creating the object
- with length==1 you might do the dirac~ thing a little bit more complicated
- with length==0 the output just toggles between 0 and 1 every time you bang the object
-
-NOTE : the inlets do NOT specify any times but sample-NUMBERS; there are 64 samples in a signal-vector,
- each "lasting" for 1/44100 secs.
+ step~ : will make a unity step at a desired point in the signal-vector; the second input specifies a
+ length: after the so-specified time has elapsed, the step will toggle back to the previous
+ value;
+ the length can be passed as an argument when creating the object
+ with length==1 you might do the dirac~ thing a little bit more complicated
+ with length==0 the output just toggles between 0 and 1 every time you bang the object
+
+ NOTE : the inlets do NOT specify any times but sample-NUMBERS; there are 64 samples in a signal-vector,
+ each "lasting" for 1/44100 secs.
*/
#include "zexy.h"
@@ -33,108 +33,108 @@ static t_class *step_class;
typedef struct _step
{
- t_object x_obj;
- int position;
- int length;
+ t_object x_obj;
+ int position;
+ int length;
- int toggle;
+ int toggle;
- int wait4start;
- int wait4stop;
+ int wait4start;
+ int wait4stop;
} t_step;
static void step_bang(t_step *x)
{
- x->wait4stop = x->length + (x->wait4start = x->position);
+ x->wait4stop = x->length + (x->wait4start = x->position);
}
static void step_float(t_step *x, t_float where)
{
- x->wait4stop = x->length +
- (x->wait4start =
- (x->position = (where>0)*where)
- );
+ x->wait4stop = x->length +
+ (x->wait4start =
+ (x->position = (where>0)*where)
+ );
}
static void step_setlength(t_step *x, t_float arg)
{
- x->length = 1 + (arg>0)*arg;
+ x->length = 1 + (arg>0)*arg;
}
static t_int *step_perform(t_int *w)
{
- t_step *x = (t_step *)(w[1]);
- t_float *out = (t_float *)(w[2]);
- int n = (int)(w[3]);
+ t_step *x = (t_step *)(w[1]);
+ t_sample *out = (t_sample *)(w[2]);
+ int n = (int)(w[3]);
- int toggle = x->toggle;
+ int toggle = x->toggle;
- int wait4start = x->wait4start, wait4stop = x->wait4stop;
+ int wait4start = x->wait4start, wait4stop = x->wait4stop;
- while (n--)
- {
- wait4stop--;
- if (!wait4start--) toggle ^= 1;
- else if (!wait4stop) toggle ^= 1;
+ while (n--)
+ {
+ wait4stop--;
+ if (!wait4start--) toggle ^= 1;
+ else if (!wait4stop) toggle ^= 1;
- *out++ = toggle;
- }
+ *out++ = toggle;
+ }
- x->wait4start = wait4start;
- x->wait4stop = wait4stop;
+ x->wait4start = wait4start;
+ x->wait4stop = wait4stop;
- x->toggle = toggle;
- return (w+4);
+ x->toggle = toggle;
+ return (w+4);
}
static void step_dsp(t_step *x, t_signal **sp)
{
- dsp_add(step_perform, 3, x, sp[0]->s_vec, sp[0]->s_n);
+ dsp_add(step_perform, 3, x, sp[0]->s_vec, sp[0]->s_n);
}
static void step_helper(void)
{
- post("%c step~-object :: generates a unity-step", HEARTSYMBOL);
- post("creation : \"dirac~ [<position> [<length>]]\" : create a rectangular window\n"
- "\t\t\tat specified position and with specified length (in samples)\n"
- "inlet1\t: <position>\t: create a rectangular window at new position\n"
- "\t 'bang'\t: create a rectangular window at specified position\n"
- "\t 'help'\t: view this\n"
- "inlet2\t: <length>\t: define new window length ('0' will make a unity-step)\n"
- "outlet\t: signal~");
+ post("%c step~-object :: generates a unity-step", HEARTSYMBOL);
+ post("creation : \"dirac~ [<position> [<length>]]\" : create a rectangular window\n"
+ "\t\t\tat specified position and with specified length (in samples)\n"
+ "inlet1\t: <position>\t: create a rectangular window at new position\n"
+ "\t 'bang'\t: create a rectangular window at specified position\n"
+ "\t 'help'\t: view this\n"
+ "inlet2\t: <length>\t: define new window length ('0' will make a unity-step)\n"
+ "outlet\t: signal~");
}
static void *step_new(t_floatarg farg)
{
- t_step *x = (t_step *)pd_new(step_class);
+ t_step *x = (t_step *)pd_new(step_class);
- inlet_new(&x->x_obj, &x->x_obj.ob_pd, gensym("float"), gensym("ft1"));
- outlet_new(&x->x_obj, gensym("signal"));
+ inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_float, gensym("ft1"));
+ outlet_new(&x->x_obj, &s_signal);
- x->position = 0;
- x->wait4start = x->wait4stop = 0;
- x->toggle = 1;
+ x->position = 0;
+ x->wait4start = x->wait4stop = 0;
+ x->toggle = 1;
- step_setlength(x, farg);
+ step_setlength(x, farg);
- return (x);
+ return (x);
}
void step_tilde_setup(void)
{
- step_class = class_new(gensym("step~"), (t_newmethod)step_new, 0,
- sizeof(t_step), 0, A_DEFFLOAT, 0);
+ step_class = class_new(gensym("step~"), (t_newmethod)step_new, 0,
+ sizeof(t_step), 0, A_DEFFLOAT, 0);
- class_addfloat(step_class, step_float);
- class_addbang(step_class, step_bang);
- class_addmethod(step_class, (t_method)step_setlength, gensym("ft1"), A_FLOAT, 0);
- class_addmethod(step_class, (t_method)step_dsp, gensym("dsp"), 0);
+ class_addfloat(step_class, step_float);
+ class_addbang(step_class, step_bang);
+ class_addmethod(step_class, (t_method)step_setlength, gensym("ft1"), A_FLOAT, 0);
+ class_addmethod(step_class, (t_method)step_dsp, gensym("dsp"), 0);
- class_addmethod(step_class, (t_method)step_helper, gensym("help"), 0);
+ class_addmethod(step_class, (t_method)step_helper, gensym("help"), 0);
zexy_register("step~");
}
diff --git a/src/swap~.c b/src/swap~.c
index 41b9023..65ecb5b 100644
--- a/src/swap~.c
+++ b/src/swap~.c
@@ -14,10 +14,10 @@
******************************************************/
/*
- the long waited for swap~-object that does a byte swap
- of course, we unfortunately have to quantize the float-signal to 16bit (to get bytes)
+ the long waited for swap~-object that does a byte swap
+ of course, we unfortunately have to quantize the float-signal to 16bit (to get bytes)
- 1110:forum::für::umläute:1999
+ 1110:forum::für::umläute:1999
*/
#include "zexy.h"
@@ -47,8 +47,8 @@ static void swap_bang(t_swap *x)
static t_int *swap_perform(t_int *w)
{
t_swap *x = (t_swap *)(w[1]);
- t_float *in = (t_float *)(w[2]);
- t_float *out = (t_float *)(w[3]);
+ t_sample *in = (t_sample *)(w[2]);
+ t_sample *out = (t_sample *)(w[3]);
int n = (int)(w[4]);
diff --git a/src/tavg~.c b/src/tavg~.c
index d8355c8..bdd33ed 100644
--- a/src/tavg~.c
+++ b/src/tavg~.c
@@ -23,16 +23,17 @@ static t_class *tavg_class;
typedef struct _tavg
{
t_object x_obj;
- t_float n_inv;
- t_float buf;
- int blocks;
+ t_sample n_inv;
+ t_sample buf;
+ unsigned int blocks;
} t_tavgtilde;
static void tavg_bang(t_tavgtilde *x)
{
if (x->blocks) {
- outlet_float(x->x_obj.ob_outlet, x->buf*x->n_inv/x->blocks);
+ t_float result=x->buf*x->n_inv/x->blocks;
+ outlet_float(x->x_obj.ob_outlet, result);
x->blocks = 0;
x->buf = 0.;
}
@@ -40,48 +41,45 @@ static void tavg_bang(t_tavgtilde *x)
static t_int *tavg_perform(t_int *w)
{
- t_float *in = (t_float *)(w[1]);
- t_tavgtilde *x = (t_tavgtilde *)w[2];
- int n = (int)(w[3]);
-
- t_float buf = x->buf;
-
- while (n--) buf += *in++;
-
- x->buf = buf;
- x->blocks++;
-
- return (w+4);
+ t_sample *in = (t_sample *)(w[1]);
+ t_tavgtilde *x = (t_tavgtilde *)w[2];
+ int n = (int)(w[3]);
+ t_sample buf = x->buf;
+
+ while (n--) buf += *in++;
+ x->buf = buf;
+ x->blocks++;
+ return (w+4);
}
static void tavg_dsp(t_tavgtilde *x, t_signal **sp)
{
- x->n_inv=1./sp[0]->s_n;
- dsp_add(tavg_perform, 3, sp[0]->s_vec, x, sp[0]->s_n);
+ x->n_inv=1./sp[0]->s_n;
+ dsp_add(tavg_perform, 3, sp[0]->s_vec, x, sp[0]->s_n);
}
static void *tavg_new(void)
{
- t_tavgtilde *x = (t_tavgtilde *)pd_new(tavg_class);
- outlet_new(&x->x_obj, gensym("float"));
- return (x);
+ t_tavgtilde *x = (t_tavgtilde *)pd_new(tavg_class);
+ outlet_new(&x->x_obj, &s_float);
+ return (x);
}
static void tavg_help(void)
{
- post("tavg~\t\t:: outputs the arithmetic mean of a signal when triggered");
- post("<bang>\t\t: triggers the output");
+ post("tavg~\t\t:: outputs the arithmetic mean of a signal when triggered");
+ post("<bang>\t\t: triggers the output");
}
void tavg_tilde_setup(void)
{
- tavg_class = class_new(gensym("tavg~"), (t_newmethod)tavg_new, 0,
- sizeof(t_tavgtilde), 0, A_DEFFLOAT, 0);
- class_addmethod(tavg_class, nullfn, gensym("signal"), 0);
- class_addmethod(tavg_class, (t_method)tavg_dsp, gensym("dsp"), 0);
+ tavg_class = class_new(gensym("tavg~"), (t_newmethod)tavg_new, 0,
+ sizeof(t_tavgtilde), 0, A_DEFFLOAT, 0);
+ class_addmethod(tavg_class, nullfn, gensym("signal"), 0);
+ class_addmethod(tavg_class, (t_method)tavg_dsp, gensym("dsp"), 0);
- class_addbang(tavg_class, tavg_bang);
+ class_addbang(tavg_class, tavg_bang);
- class_addmethod(tavg_class, (t_method)tavg_help, gensym("help"), 0);
+ class_addmethod(tavg_class, (t_method)tavg_help, gensym("help"), 0);
zexy_register("tavg~");
}
diff --git a/src/unpack~.c b/src/unpack~.c
index 6e54a7d..c27f5f4 100644
--- a/src/unpack~.c
+++ b/src/unpack~.c
@@ -29,8 +29,8 @@ static t_class *sigunpack_class;
typedef struct _sigunpack
{
t_object x_obj;
- t_float *buffer;
- t_float *rp, *wp;
+ t_sample *buffer;
+ t_sample *rp, *wp;
int bufsize;
} t_sigunpack;
@@ -47,26 +47,22 @@ static void sigunpack_list(t_sigunpack *x, t_symbol *s, int argc, t_atom *argv)
{
t_atom *ap = argv;
int i;
- ZEXY_USEVAR(s);
-
for (i = 0, ap = argv; i < argc; ap++, i++) {
- // if (ap->a_type == A_FLOAT) {
- if (x->wp + 1 != x->rp) {
- *(x->wp)++ = atom_getfloat(ap);
- if (x->wp == x->buffer + x->bufsize) x->wp = x->buffer;
- }
- // }
+ if (x->wp + 1 != x->rp) {
+ *(x->wp)++ = atom_getfloat(ap);
+ if (x->wp == x->buffer + x->bufsize) x->wp = x->buffer;
+ }
}
}
static t_int *sigunpack_perform(t_int *w)
{
- t_float *out = (t_float *)(w[1]);
+ t_sample *out = (t_sample *)(w[1]);
t_sigunpack *x = (t_sigunpack *)w[2];
int n = (int)(w[3]);
- t_float *buf = x->rp;
+ t_sample *buf = x->rp;
int hitchhike = 0;
if ((x->wp >= x->rp) && (x->wp < x->rp+n)) hitchhike=1;
@@ -86,8 +82,8 @@ static void sigunpack_dsp(t_sigunpack *x, t_signal **sp)
{
if (x->bufsize % sp[0]->s_n) {
int newsize = sp[0]->s_n*(1+(int)(x->bufsize/sp[0]->s_n));
- freebytes(x->buffer, x->bufsize * sizeof(t_float));
- x->buffer = (t_float *)getbytes(newsize * sizeof(t_float));
+ freebytes(x->buffer, x->bufsize * sizeof(*x->buffer));
+ x->buffer = (t_sample *)getbytes(newsize * sizeof(*x->buffer));
x->rp = x->wp = x->buffer;
x->bufsize = newsize;
@@ -105,7 +101,7 @@ static void *sigunpack_new(t_floatarg f)
if (!suggestedsize) bufsize = 64;
else bufsize = (suggestedsize % 64)?(64*(1+(int)(suggestedsize/64))):suggestedsize;
- x->buffer = (t_float *)getbytes(bufsize * sizeof(t_float));
+ x->buffer = (t_sample *)getbytes(bufsize * sizeof(*x->buffer));
x->bufsize = bufsize;
x->rp = x->wp = x->buffer;
@@ -122,7 +118,7 @@ static void sigunpack_help(void)
void unpack_tilde_setup(void)
{
sigunpack_class = class_new(gensym("unpack~"), (t_newmethod)sigunpack_new, 0,
- sizeof(t_sigunpack), 0, A_DEFFLOAT, 0);
+ sizeof(t_sigunpack), 0, A_DEFFLOAT, 0);
class_addmethod(sigunpack_class, (t_method)sigunpack_dsp, gensym("dsp"), 0);
class_addfloat(sigunpack_class, (t_method)sigunpack_float);
class_addlist (sigunpack_class, (t_method)sigunpack_list);
diff --git a/src/z~.c b/src/z~.c
index 5969eae..644f5e5 100644
--- a/src/z~.c
+++ b/src/z~.c
@@ -15,11 +15,11 @@
******************************************************/
/*
- here we do some sample-wise delay, so you can do your own FIR-filter-designs
- here are :: "z^(-1)", "z^(-N)"
- to do :: a "lattice~" section ...
+ here we do some sample-wise delay, so you can do your own FIR-filter-designs
+ here are :: "z^(-1)", "z^(-N)"
+ to do :: a "lattice~" section ...
- 1302:forum::für::umläute:2000
+ 1302:forum::für::umläute:2000
*/
#include "zexy.h"
@@ -32,7 +32,7 @@ typedef struct _zNdelay
{
t_object x_obj;
- t_float *buf;
+ t_sample *buf;
int bufsize, phase;
} t_zNdelay;
@@ -42,26 +42,26 @@ static void zdel_float(t_zNdelay *x, t_floatarg f)
int i = f+1;
if (i<1)i=1;
if (i==x->bufsize)return;
- freebytes(x->buf, x->bufsize*sizeof(t_float));
+ freebytes(x->buf, x->bufsize*sizeof(t_sample));
x->bufsize=i;
- x->buf=(t_float *)getbytes(x->bufsize*sizeof(t_float));
+ x->buf=(t_sample *)getbytes(x->bufsize*sizeof(t_sample));
x->phase=0;
}
static t_int *zN_perform(t_int *w)
{
- t_float *in = (t_float *)(w[1]);
- t_float *out = (t_float *)(w[2]);
+ t_sample *in = (t_sample *)(w[1]);
+ t_sample *out = (t_sample *)(w[2]);
t_zNdelay *x = (t_zNdelay *)(w[3]);
int n = (int)(w[4]);
- t_float *buf = x->buf;
+ t_sample *buf = x->buf;
int bufsize=x->bufsize, ph=x->phase;
if (bufsize==1) {
if (in!=out)while(n--)*out++=*in++;
} else if (bufsize==2) {
- register t_float f, last=*buf;
+ register t_sample f, last=*buf;
while(n--){
f=*in++;
*out++=last;
@@ -88,13 +88,13 @@ static void *zNdelay_new(t_floatarg f)
{
t_zNdelay *x = (t_zNdelay *)pd_new(zNdelay_class);
int i = f;
- t_float *b;
+ t_sample *b;
if (i<=0) i=1;
i++;
x->bufsize = i;
- x->buf = (t_float *)getbytes(sizeof(t_float) * x->bufsize);
+ x->buf = (t_sample *)getbytes(sizeof(t_sample) * x->bufsize);
b=x->buf;
while (i--) {
*b++=0;
@@ -108,7 +108,7 @@ static void *zNdelay_new(t_floatarg f)
static void zNdelay_free(t_zNdelay *x)
{
- freebytes(x->buf, sizeof(t_float) * x->bufsize);
+ freebytes(x->buf, sizeof(t_sample) * x->bufsize);
}