aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormusil <tmusil@users.sourceforge.net>2013-07-04 17:27:45 +0000
committermusil <tmusil@users.sourceforge.net>2013-07-04 17:27:45 +0000
commit5c09e01a431bd9c9f5462e8913a0181d8718dda1 (patch)
tree2a8690104322b2c1ed65f6d95d32a1ffffd813de
parent1971590ae628cb23bfd4224917d67510e4d1e61e (diff)
changed t_signal, t_float, and date
svn path=/trunk/externals/iem/iem_delay/; revision=17187
-rw-r--r--src/block_delay~.c32
-rw-r--r--src/iem_delay.c8
-rw-r--r--src/n_delay1p_line~.c147
-rw-r--r--src/n_delay2p_line~.c167
-rw-r--r--src/nz~.c76
5 files changed, 201 insertions, 229 deletions
diff --git a/src/block_delay~.c b/src/block_delay~.c
index 78e2ea1..f4bc876 100644
--- a/src/block_delay~.c
+++ b/src/block_delay~.c
@@ -1,30 +1,31 @@
/* For information on usage and redistribution, and for a DISCLAIMER OF ALL
* WARRANTIES, see the file, "LICENSE.txt," in this distribution.
-iem_delay written by Thomas Musil (c) IEM KUG Graz Austria 2002 - 2006 */
+iem_delay written by Thomas Musil (c) IEM KUG Graz Austria 2002 - 2011 */
#include "m_pd.h"
#include "iemlib.h"
#include "iem_delay.h"
/* -------------------------- block_delay~ ------------------------------ */
+/* ----------------- delys a signal by blocksize samples ---------------- */
static t_class *block_delay_tilde_class;
typedef struct _block_delay_tilde
{
t_object x_obj;
- t_float *x_begmem;
+ t_sample *x_begmem;
int x_blocksize;
- t_float x_msi;
+ t_float x_scalar_sig_in;
} t_block_delay_tilde;
static t_int *block_delay_tilde_perform(t_int *w)
{
- t_float *in = (float *)(w[1]);
- t_float *out = (float *)(w[2]);
+ t_sample *in = (float *)(w[1]);
+ t_sample *out = (float *)(w[2]);
t_block_delay_tilde *x = (t_block_delay_tilde *)(w[3]);
int i, n = (t_int)(w[4]);
- t_float *rw_vec, f;
+ t_sample *rw_vec, f;
rw_vec = x->x_begmem;
for(i=0; i<n; i++)
@@ -38,11 +39,11 @@ static t_int *block_delay_tilde_perform(t_int *w)
static t_int *block_delay_tilde_perf8(t_int *w)
{
- t_float *in = (float *)(w[1]);
- t_float *out = (float *)(w[2]);
+ t_sample *in = (float *)(w[1]);
+ t_sample *out = (float *)(w[2]);
t_block_delay_tilde *x = (t_block_delay_tilde *)(w[3]);
int i, n = (t_int)(w[4]);
- t_float *rw_vec, f[8];
+ t_sample *rw_vec, f[8];
rw_vec = x->x_begmem;
while(n)
@@ -87,9 +88,9 @@ static void block_delay_tilde_dsp(t_block_delay_tilde *x, t_signal **sp)
int n = sp[0]->s_n;
if(!x->x_blocksize)/*first time*/
- x->x_begmem = (t_float *)getbytes(n * sizeof(t_float));
+ x->x_begmem = (t_sample *)getbytes(n * sizeof(t_sample));
else if(x->x_blocksize != n)
- x->x_begmem = (t_float *)resizebytes(x->x_begmem, x->x_blocksize*sizeof(t_float), n*sizeof(t_float));
+ x->x_begmem = (t_sample *)resizebytes(x->x_begmem, x->x_blocksize*sizeof(t_sample), n*sizeof(t_sample));
x->x_blocksize = n;
if(n&7)
dsp_add(block_delay_tilde_perform, 4, sp[0]->s_vec, sp[1]->s_vec, x, sp[0]->s_n);
@@ -102,23 +103,22 @@ static void *block_delay_tilde_new(void)
t_block_delay_tilde *x = (t_block_delay_tilde *)pd_new(block_delay_tilde_class);
x->x_blocksize = 0;
- x->x_begmem = (t_float *)0;
+ x->x_begmem = (t_sample *)0;
outlet_new(&x->x_obj, &s_signal);
- x->x_msi = 0.0f;
+ x->x_scalar_sig_in = (t_float)0.0;
return (x);
}
static void block_delay_tilde_free(t_block_delay_tilde *x)
{
if(x->x_begmem)
- freebytes(x->x_begmem, x->x_blocksize * sizeof(t_float));
+ freebytes(x->x_begmem, x->x_blocksize * sizeof(t_sample));
}
void block_delay_tilde_setup(void)
{
block_delay_tilde_class = class_new(gensym("block_delay~"), (t_newmethod)block_delay_tilde_new, (t_method)block_delay_tilde_free,
sizeof(t_block_delay_tilde), 0, 0);
- CLASS_MAINSIGNALIN(block_delay_tilde_class, t_block_delay_tilde, x_msi);
+ CLASS_MAINSIGNALIN(block_delay_tilde_class, t_block_delay_tilde, x_scalar_sig_in);
class_addmethod(block_delay_tilde_class, (t_method)block_delay_tilde_dsp, gensym("dsp"), 0);
-// class_sethelpsymbol(block_delay_tilde_class, gensym("iemhelp2/block_delay~-help"));
}
diff --git a/src/iem_delay.c b/src/iem_delay.c
index 206fb61..9b3469b 100644
--- a/src/iem_delay.c
+++ b/src/iem_delay.c
@@ -1,7 +1,7 @@
/* For information on usage and redistribution, and for a DISCLAIMER OF ALL
* WARRANTIES, see the file, "LICENSE.txt," in this distribution.
-iem_delay written by Thomas Musil (c) IEM KUG Graz Austria 2002 - 2006 */
+iem_delay written by Thomas Musil (c) IEM KUG Graz Austria 2002 - 2013 */
#include "m_pd.h"
#include "iemlib.h"
@@ -24,11 +24,11 @@ void block_delay_tilde_setup(void);
void iem_delay_setup(void)
{
- n_delay1p_line_tilde_setup();
- n_delay2p_line_tilde_setup();
+ n_delay1p_tilde_setup();
+ n_delay2p_tilde_setup();
nz_tilde_setup();
block_delay_tilde_setup();
- post("iem_delay (R-1.17) library loaded! (c) Thomas Musil 11.2006");
+ post("iem_delay (R-1.20) library loaded! (c) Thomas Musil 07.2013");
post(" musil%ciem.at iem KUG Graz Austria", '@');
}
diff --git a/src/n_delay1p_line~.c b/src/n_delay1p_line~.c
index e345aac..50ad6dc 100644
--- a/src/n_delay1p_line~.c
+++ b/src/n_delay1p_line~.c
@@ -1,7 +1,9 @@
/* For information on usage and redistribution, and for a DISCLAIMER OF ALL
* WARRANTIES, see the file, "LICENSE.txt," in this distribution.
-iem_delay written by Thomas Musil (c) IEM KUG Graz Austria 2002 - 2006 */
+iem_delay written by Thomas Musil (c) IEM KUG Graz Austria 2002 - 2011 */
+
+/* no good, hat schwirigkeiten bei help patch, kontinuierlich die formanten interpolation zu schaffen */
#include "m_pd.h"
@@ -9,6 +11,8 @@ iem_delay written by Thomas Musil (c) IEM KUG Graz Austria 2002 - 2006 */
#include "iem_delay.h"
/* -------------------------- n_delay1p_line_tilde~ ------------------------------ */
+/* ----------- n non interpolated line~-signal driven delay taps ------------- */
+
static t_class *n_delay1p_line_tilde_class;
typedef struct _n_delay1p_line_tilde
@@ -16,8 +20,8 @@ typedef struct _n_delay1p_line_tilde
t_object x_obj;
int x_mallocsize;
t_float x_max_delay_ms;
- t_float *x_begmem0;
- t_float *x_begmem1;
+ t_sample *x_begmem1;
+ t_sample *x_begmem2;
int x_writeindex;
int x_n_delays;
int *x_del_samp256_end;
@@ -33,8 +37,8 @@ typedef struct _n_delay1p_line_tilde
int x_ticksleft;
int x_old;
int x_retarget;
- t_float **x_io;
- t_float x_msi;
+ t_sample **x_io;
+ t_float x_scalar_sig_in;
} t_n_delay1p_line_tilde;
static void n_delay1p_line_tilde_list(t_n_delay1p_line_tilde *x, t_symbol *s, int argc, t_atom *argv)
@@ -44,29 +48,29 @@ static void n_delay1p_line_tilde_list(t_n_delay1p_line_tilde *x, t_symbol *s, in
int i;
t_float delay, max=x->x_max_delay_ms;
- if(x->x_interpol_ms <= 0.0f)
+ if(x->x_interpol_ms <= (t_float)0.0)
x->x_ticksleft = x->x_retarget = 0;
else
x->x_retarget = 1;
for(i=0; i<argc; i++)
{
delay = atom_getfloat(argv++);
- if(delay < 0.0f)
- delay = 0.0f;
+ if(delay < (t_float)0.0)
+ delay = (t_float)0.0;
if(delay > max)
delay = max;
- if(x->x_interpol_ms <= 0.0f)
- x->x_del_samp256_end[i] = x->x_del_samp256_cur[i] = (int)(x->x_ms2samples256 * delay + 0.5f) + 127;
+ if(x->x_interpol_ms <= (t_float)0.0)
+ x->x_del_samp256_end[i] = x->x_del_samp256_cur[i] = (int)(x->x_ms2samples256 * delay + (t_float)0.5) + 127;
else
- x->x_del_samp256_end[i] = (int)(x->x_ms2samples256 * delay + 0.5f) + 127;
+ x->x_del_samp256_end[i] = (int)(x->x_ms2samples256 * delay + (t_float)0.5) + 127;
}
}
}
static void n_delay1p_line_tilde_time(t_n_delay1p_line_tilde *x, t_floatarg interpol_ms)
{
- if(interpol_ms < 0.0f)
- interpol_ms = 0.0f;
+ if(interpol_ms < (t_float)0.0)
+ interpol_ms = (t_float)0.0;
x->x_interpol_ms = interpol_ms;
x->x_interpol_ticks = (int)(x->x_ms2tick * interpol_ms);
}
@@ -85,30 +89,25 @@ static t_int *n_delay1p_line_tilde_perform(t_int *w)
t_n_delay1p_line_tilde *x = (t_n_delay1p_line_tilde *)(w[1]);
int hn=(int)(w[2]);
int nout=x->x_n_delays;
- t_float *in;
- t_float *out;
+ t_sample *in;
+ t_sample *out;
int writeindex = x->x_writeindex;
int i, j, n;
int malloc_samples = x->x_mallocsize;
- t_float *begvec0 = x->x_begmem0;
- t_float *begvec1 = x->x_begmem1;
- t_float *writevec;
- t_float *readvec;
+ t_sample *begvec1 = x->x_begmem1;
+ t_sample *begvec2 = x->x_begmem2;
+ t_sample *writevec;
+ t_sample *readvec;
int del256, inc256;
- writevec = begvec0 + writeindex;
- in=x->x_io[0];
- n = hn;
- while(n--)
- {
- *writevec++ = *in++;
- }
- writevec = begvec1 + writeindex;
+ begvec1 += writeindex;
+ writevec = begvec2 + writeindex;
in=x->x_io[0];
n = hn;
while(n--)
{
- *writevec++ = *in++;
+ *begvec1++ = *in;
+ *writevec++ = *in++;
}
if(x->x_retarget)
@@ -135,7 +134,7 @@ static t_int *n_delay1p_line_tilde_perform(t_int *w)
out = x->x_io[j+1];
for(i=0; i<hn; i++)
{
- readvec = begvec1 + writeindex - (del256 >> 8) + i;
+ readvec = begvec2 + writeindex - (del256 >> 8) + i;
*out++ = *readvec;
del256 += inc256;
}
@@ -148,7 +147,7 @@ static t_int *n_delay1p_line_tilde_perform(t_int *w)
for(j=0; j<nout; j++)
{
del256 = x->x_del_samp256_cur[j] = x->x_del_samp256_end[j];
- readvec = begvec1 + writeindex - (del256 >> 8);
+ readvec = begvec2 + writeindex - (del256 >> 8);
out = x->x_io[j+1];
n = hn;
while(n--)
@@ -171,42 +170,34 @@ static t_int *n_delay1p_line_tilde_perf8(t_int *w)
t_n_delay1p_line_tilde *x = (t_n_delay1p_line_tilde *)(w[1]);
int hn=(int)(w[2]);
int nout=x->x_n_delays;
- t_float *in;
- t_float *out;
+ t_sample *in;
+ t_sample *out;
int writeindex = x->x_writeindex;
int i, j, k, n;
int malloc_samples = x->x_mallocsize;
- t_float *begvec0 = x->x_begmem0;
- t_float *begvec1 = x->x_begmem1;
- t_float *writevec;
- t_float *readvec;
+ t_sample *begvec1 = x->x_begmem1;
+ t_sample *begvec2 = x->x_begmem2;
+ t_sample *writevec;
+ t_sample *readvec;
int del256, inc256;
// post("writevec = %d",writeindex);
- writevec = begvec0 + writeindex;
- in=x->x_io[0];
- n = hn;
- while(n)
- {
- writevec[0] = in[0];
- writevec[1] = in[1];
- writevec[2] = in[2];
- writevec[3] = in[3];
- writevec[4] = in[4];
- writevec[5] = in[5];
- writevec[6] = in[6];
- writevec[7] = in[7];
-
- writevec += 8;
- n -= 8;
- in += 8;
- }
- writevec = begvec1 + writeindex;
+ begvec1 += writeindex;
+ writevec = begvec2 + writeindex;
in=x->x_io[0];
n = hn;
while(n)
{
- writevec[0] = in[0];
+ begvec1[0] = in[0];
+ begvec1[1] = in[1];
+ begvec1[2] = in[2];
+ begvec1[3] = in[3];
+ begvec1[4] = in[4];
+ begvec1[5] = in[5];
+ begvec1[6] = in[6];
+ begvec1[7] = in[7];
+
+ writevec[0] = in[0];
writevec[1] = in[1];
writevec[2] = in[2];
writevec[3] = in[3];
@@ -215,6 +206,7 @@ static t_int *n_delay1p_line_tilde_perf8(t_int *w)
writevec[6] = in[6];
writevec[7] = in[7];
+ begvec1 += 8;
writevec += 8;
n -= 8;
in += 8;
@@ -242,7 +234,7 @@ static t_int *n_delay1p_line_tilde_perf8(t_int *w)
inc256 = x->x_inc256[j];
del256 = x->x_del_samp256_cur[j];
out = x->x_io[j+1];
- readvec = begvec1 + writeindex;
+ readvec = begvec2 + writeindex;
for(i=0; i<hn; i+=8)
{
k = del256 >> 8;
@@ -289,7 +281,7 @@ static t_int *n_delay1p_line_tilde_perf8(t_int *w)
for(j=0; j<nout; j++)
{
del256 = x->x_del_samp256_cur[j] = x->x_del_samp256_end[j];
- readvec = begvec1 + writeindex - (del256 >> 8);
+ readvec = begvec2 + writeindex - (del256 >> 8);
out = x->x_io[j+1];
n = hn;
while(n)
@@ -326,35 +318,35 @@ static void n_delay1p_line_tilde_dsp(t_n_delay1p_line_tilde *x, t_signal **sp)
if(!x->x_blocksize)/*first time*/
{
- int nsamps = x->x_max_delay_ms * (t_float)sp[0]->s_sr * 0.001f;
+ int nsamps = x->x_max_delay_ms * (t_float)sp[0]->s_sr * (t_float)0.001;
if(nsamps < 1)
nsamps = 1;
nsamps += ((- nsamps) & (n - 1));
nsamps += n;
x->x_mallocsize = nsamps;
- x->x_begmem0 = (t_float *)getbytes(2 * x->x_mallocsize * sizeof(t_float));
- x->x_begmem1 = x->x_begmem0 + x->x_mallocsize;
+ x->x_begmem1 = (t_sample *)getbytes(2 * x->x_mallocsize * sizeof(t_sample));
+ x->x_begmem2 = x->x_begmem1 + x->x_mallocsize;
x->x_writeindex = n;
}
else if((x->x_blocksize != n) || ((t_float)sp[0]->s_sr != x->x_sr))
{
- int nsamps = x->x_max_delay_ms * (t_float)sp[0]->s_sr * 0.001f;
+ int nsamps = x->x_max_delay_ms * (t_float)sp[0]->s_sr * (t_float)0.001;
if(nsamps < 1)
nsamps = 1;
nsamps += ((- nsamps) & (n - 1));
nsamps += n;
- x->x_begmem0 = (t_float *)resizebytes(x->x_begmem0, 2*x->x_mallocsize*sizeof(t_float), 2*nsamps*sizeof(t_float));
+ x->x_begmem1 = (t_sample *)resizebytes(x->x_begmem1, 2*x->x_mallocsize*sizeof(t_sample), 2*nsamps*sizeof(t_sample));
x->x_mallocsize = nsamps;
- x->x_begmem1 = x->x_begmem0 + x->x_mallocsize;
+ x->x_begmem2 = x->x_begmem1 + x->x_mallocsize;
if(x->x_writeindex >= nsamps)
x->x_writeindex -= nsamps;
}
x->x_blocksize = n;
- x->x_ms2tick = 0.001f * (t_float)sp[0]->s_sr / (t_float)n;
- x->x_ms2samples256 = 0.256f * (t_float)sp[0]->s_sr;
+ x->x_ms2tick = (t_float)0.001 * (t_float)sp[0]->s_sr / (t_float)n;
+ x->x_ms2samples256 = (t_float)0.256 * (t_float)sp[0]->s_sr;
x->x_interpol_ticks = (int)(x->x_ms2tick * x->x_interpol_ms);
for(i=0; i<nd; i++)
x->x_io[i] = sp[i]->s_vec;
@@ -368,7 +360,7 @@ static void *n_delay1p_line_tilde_new(t_floatarg fout, t_floatarg delay_ms, t_fl
{
t_n_delay1p_line_tilde *x = (t_n_delay1p_line_tilde *)pd_new(n_delay1p_line_tilde_class);
int i, n_out = (int)fout;
- int nsamps = delay_ms * sys_getsr() * 0.001f;
+ int nsamps = delay_ms * sys_getsr() * (t_float)0.001;
if(n_out < 1)
n_out = 1;
@@ -379,15 +371,15 @@ static void *n_delay1p_line_tilde_new(t_floatarg fout, t_floatarg delay_ms, t_fl
nsamps += ((- nsamps) & (DELLINE_DEF_VEC_SIZE - 1));
nsamps += DELLINE_DEF_VEC_SIZE;
x->x_mallocsize = nsamps;
- x->x_begmem0 = (t_float *)getbytes(2 * x->x_mallocsize * sizeof(t_float));
- x->x_begmem1 = x->x_begmem0 + x->x_mallocsize;
+ x->x_begmem1 = (t_sample *)getbytes(2 * x->x_mallocsize * sizeof(t_sample));
+ x->x_begmem2 = x->x_begmem1 + x->x_mallocsize;
x->x_writeindex = DELLINE_DEF_VEC_SIZE;
x->x_blocksize = 0;
- x->x_sr = 0.0f;
- if(interpol_ms < 0.0f)
- interpol_ms = 0.0f;
+ x->x_sr = (t_float)0.0;
+ if(interpol_ms < (t_float)0.0)
+ interpol_ms = (t_float)0.0;
x->x_interpol_ms = interpol_ms;
- x->x_io = (t_float **)getbytes((x->x_n_delays + 1) * sizeof(t_float *));
+ x->x_io = (t_sample **)getbytes((x->x_n_delays + 1) * sizeof(t_sample *));
for(i=0; i<n_out; i++)
outlet_new(&x->x_obj, &s_signal);
x->x_del_samp256_end = (int *)getbytes(x->x_n_delays * sizeof(int));
@@ -401,7 +393,7 @@ static void *n_delay1p_line_tilde_new(t_floatarg fout, t_floatarg delay_ms, t_fl
x->x_inc256[i] = x->x_biginc256[i] = 0;
}
x->x_interpol_ticks = 0;
- x->x_msi = 0.0f;
+ x->x_scalar_sig_in = (t_float)0.0;
return (x);
}
@@ -411,18 +403,17 @@ static void n_delay1p_line_tilde_free(t_n_delay1p_line_tilde *x)
freebytes(x->x_del_samp256_cur, x->x_n_delays * sizeof(int));
freebytes(x->x_inc256, x->x_n_delays * sizeof(int));
freebytes(x->x_biginc256, x->x_n_delays * sizeof(int));
- freebytes(x->x_io, (x->x_n_delays + 1) * sizeof(t_float *));
- freebytes(x->x_begmem0, 2 * x->x_mallocsize * sizeof(t_float));
+ freebytes(x->x_io, (x->x_n_delays + 1) * sizeof(t_sample *));
+ freebytes(x->x_begmem1, 2 * x->x_mallocsize * sizeof(t_sample));
}
void n_delay1p_line_tilde_setup(void)
{
n_delay1p_line_tilde_class = class_new(gensym("n_delay1p_line~"), (t_newmethod)n_delay1p_line_tilde_new, (t_method)n_delay1p_line_tilde_free,
sizeof(t_n_delay1p_line_tilde), 0, A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT, 0);
- CLASS_MAINSIGNALIN(n_delay1p_line_tilde_class, t_n_delay1p_line_tilde, x_msi);
+ CLASS_MAINSIGNALIN(n_delay1p_line_tilde_class, t_n_delay1p_line_tilde, x_scalar_sig_in);
class_addlist(n_delay1p_line_tilde_class, (t_method)n_delay1p_line_tilde_list);
class_addmethod(n_delay1p_line_tilde_class, (t_method)n_delay1p_line_tilde_dsp, gensym("dsp"), 0);
class_addmethod(n_delay1p_line_tilde_class, (t_method)n_delay1p_line_tilde_stop, gensym("stop"), 0);
class_addmethod(n_delay1p_line_tilde_class, (t_method)n_delay1p_line_tilde_time, gensym("time"), A_FLOAT, 0);
-// class_sethelpsymbol(n_delay1p_line_tilde_class, gensym("iemhelp2/n_delay1p_line~-help"));
}
diff --git a/src/n_delay2p_line~.c b/src/n_delay2p_line~.c
index 32da69e..dc948b6 100644
--- a/src/n_delay2p_line~.c
+++ b/src/n_delay2p_line~.c
@@ -1,7 +1,7 @@
/* For information on usage and redistribution, and for a DISCLAIMER OF ALL
* WARRANTIES, see the file, "LICENSE.txt," in this distribution.
-iem_delay written by Thomas Musil (c) IEM KUG Graz Austria 2002 - 2006 */
+iem_delay written by Thomas Musil (c) IEM KUG Graz Austria 2002 - 2011 */
#include "m_pd.h"
@@ -9,6 +9,8 @@ iem_delay written by Thomas Musil (c) IEM KUG Graz Austria 2002 - 2006 */
#include "iem_delay.h"
/* -------------------------- n_delay2p_line_tilde~ ------------------------------ */
+/* ----------- n 2-point interpolated line~-signal driven delay taps ------------- */
+
static t_class *n_delay2p_line_tilde_class;
t_float n_delay2p_line_tilde_256f[258];
@@ -18,8 +20,8 @@ typedef struct _n_delay2p_line_tilde
t_object x_obj;
int x_mallocsize;
t_float x_max_delay_ms;
- t_float *x_begmem0;
- t_float *x_begmem1;
+ t_sample *x_begmem1;
+ t_sample *x_begmem2;
int x_writeindex;
int x_n_delays;
int *x_del_samp256_end;
@@ -35,21 +37,21 @@ typedef struct _n_delay2p_line_tilde
int x_ticksleft;
int x_old;
int x_retarget;
- t_float **x_io;
- t_float x_msi;
+ t_sample **x_io;
+ t_float x_scalar_sig_in;
} t_n_delay2p_line_tilde;
static void n_delay2p_line_tilde_init_f(t_n_delay2p_line_tilde *x)
{
- if(n_delay2p_line_tilde_256f[257] == 0.0f)
+ if(n_delay2p_line_tilde_256f[257] == (t_float)0.0)
{
int i;
for(i=0; i<257; i++)
{
- n_delay2p_line_tilde_256f[i] = (t_float)i / 256.0f;
+ n_delay2p_line_tilde_256f[i] = (t_float)i / (t_float)256.0;
}
- n_delay2p_line_tilde_256f[257] = 1.0f;
+ n_delay2p_line_tilde_256f[257] = (t_float)1.0;
}
}
@@ -60,29 +62,29 @@ static void n_delay2p_line_tilde_list(t_n_delay2p_line_tilde *x, t_symbol *s, in
int i;
t_float delay, max=x->x_max_delay_ms;
- if(x->x_interpol_ms <= 0.0f)
+ if(x->x_interpol_ms <= (t_float)0.0)
x->x_ticksleft = x->x_retarget = 0;
else
x->x_retarget = 1;
for(i=0; i<argc; i++)
{
delay = atom_getfloat(argv++);
- if(delay < 0.0f)
- delay = 0.0f;
+ if(delay < (t_float)0.0)
+ delay = (t_float)0.0;
if(delay > max)
delay = max;
- if(x->x_interpol_ms <= 0.0f)
- x->x_del_samp256_end[i] = x->x_del_samp256_cur[i] = (int)(x->x_ms2samples256 * delay + 0.5f) + 127;
+ if(x->x_interpol_ms <= (t_float)0.0)
+ x->x_del_samp256_end[i] = x->x_del_samp256_cur[i] = (int)(x->x_ms2samples256 * delay + (t_float)0.5) + 127;
else
- x->x_del_samp256_end[i] = (int)(x->x_ms2samples256 * delay + 0.5f) + 127;
+ x->x_del_samp256_end[i] = (int)(x->x_ms2samples256 * delay + (t_float)0.5) + 127;
}
}
}
static void n_delay2p_line_tilde_time(t_n_delay2p_line_tilde *x, t_floatarg interpol_ms)
{
- if(interpol_ms < 0.0f)
- interpol_ms = 0.0f;
+ if(interpol_ms < (t_float)0.0)
+ interpol_ms = (t_float)0.0;
x->x_interpol_ms = interpol_ms;
x->x_interpol_ticks = (int)(x->x_ms2tick * interpol_ms);
}
@@ -101,30 +103,25 @@ static t_int *n_delay2p_line_tilde_perform(t_int *w)
t_n_delay2p_line_tilde *x = (t_n_delay2p_line_tilde *)(w[1]);
int hn=(int)(w[2]);
int nout=x->x_n_delays;
- t_float *in;
- t_float *out;
+ t_sample *in;
+ t_sample *out;
int writeindex = x->x_writeindex;
int i, j, n, fractindex;
int malloc_samples = x->x_mallocsize;
- t_float *begvec0 = x->x_begmem0;
- t_float *begvec1 = x->x_begmem1;
- t_float *writevec;
- t_float *readvec;
+ t_sample *begvec1 = x->x_begmem1;
+ t_sample *begvec2 = x->x_begmem2;
+ t_sample *writevec;
+ t_sample *readvec;
t_float fract;
int del256, inc256;
- writevec = begvec0 + writeindex;
- in=x->x_io[0];
- n = hn;
- while(n--)
- {
- *writevec++ = *in++;
- }
- writevec = begvec1 + writeindex;
+ begvec1 += writeindex;
+ writevec = begvec2 + writeindex;
in=x->x_io[0];
n = hn;
while(n--)
{
+ *begvec1++ = *in;
*writevec++ = *in++;
}
@@ -154,8 +151,8 @@ static t_int *n_delay2p_line_tilde_perform(t_int *w)
{
fractindex = del256 & 0xff;
fract = n_delay2p_line_tilde_256f[fractindex];
- readvec = begvec1 + writeindex - (del256 >> 8) + i;
- *out++ = readvec[0] - (readvec[0] - readvec[-1])*fract;
+ readvec = begvec2 + writeindex - (del256 >> 8) + i;
+ *out++ = readvec[0] - (readvec[0] - readvec[-1])*(t_sample)fract;
del256 += inc256;
}
x->x_del_samp256_cur[j] += x->x_biginc256[j];
@@ -167,7 +164,7 @@ static t_int *n_delay2p_line_tilde_perform(t_int *w)
for(j=0; j<nout; j++)
{
del256 = x->x_del_samp256_cur[j] = x->x_del_samp256_end[j];
- readvec = begvec1 + writeindex - (del256 >> 8);
+ readvec = begvec2 + writeindex - (del256 >> 8);
out = x->x_io[j+1];
n = hn;
while(n--)
@@ -190,43 +187,35 @@ static t_int *n_delay2p_line_tilde_perf8(t_int *w)
t_n_delay2p_line_tilde *x = (t_n_delay2p_line_tilde *)(w[1]);
int hn=(int)(w[2]);
int nout=x->x_n_delays;
- t_float *in;
- t_float *out;
+ t_sample *in;
+ t_sample *out;
int writeindex = x->x_writeindex;
int i, j, k, n, fractindex;
int malloc_samples = x->x_mallocsize;
- t_float *begvec0 = x->x_begmem0;
- t_float *begvec1 = x->x_begmem1;
- t_float *writevec;
- t_float *readvec;
+ t_sample *begvec1 = x->x_begmem1;
+ t_sample *begvec2 = x->x_begmem2;
+ t_sample *writevec;
+ t_sample *readvec;
t_float fract;
int del256, inc256;
// post("writevec = %d",writeindex);
- writevec = begvec0 + writeindex;
- in=x->x_io[0];
- n = hn;
- while(n)
- {
- writevec[0] = in[0];
- writevec[1] = in[1];
- writevec[2] = in[2];
- writevec[3] = in[3];
- writevec[4] = in[4];
- writevec[5] = in[5];
- writevec[6] = in[6];
- writevec[7] = in[7];
-
- writevec += 8;
- n -= 8;
- in += 8;
- }
- writevec = begvec1 + writeindex;
+ begvec1 += writeindex;
+ writevec = begvec2 + writeindex;
in=x->x_io[0];
n = hn;
while(n)
{
- writevec[0] = in[0];
+ begvec1[0] = in[0];
+ begvec1[1] = in[1];
+ begvec1[2] = in[2];
+ begvec1[3] = in[3];
+ begvec1[4] = in[4];
+ begvec1[5] = in[5];
+ begvec1[6] = in[6];
+ begvec1[7] = in[7];
+
+ writevec[0] = in[0];
writevec[1] = in[1];
writevec[2] = in[2];
writevec[3] = in[3];
@@ -235,6 +224,7 @@ static t_int *n_delay2p_line_tilde_perf8(t_int *w)
writevec[6] = in[6];
writevec[7] = in[7];
+ begvec1 += 8;
writevec += 8;
n -= 8;
in += 8;
@@ -262,55 +252,55 @@ static t_int *n_delay2p_line_tilde_perf8(t_int *w)
inc256 = x->x_inc256[j];
del256 = x->x_del_samp256_cur[j];
out = x->x_io[j+1];
- readvec = begvec1 + writeindex;
+ readvec = begvec2 + writeindex;
for(i=0; i<hn; i+=8)
{
fractindex = del256 & 0xff;
fract = n_delay2p_line_tilde_256f[fractindex];
k = del256 >> 8;
- out[0] = readvec[0-k] - (readvec[0-k] - readvec[-1-k])*fract;
+ out[0] = readvec[0-k] - (readvec[0-k] - readvec[-1-k])*(t_sample)fract;
del256 += inc256;
fractindex = del256 & 0xff;
fract = n_delay2p_line_tilde_256f[fractindex];
k = del256 >> 8;
- out[1] = readvec[1-k] - (readvec[1-k] - readvec[0-k])*fract;
+ out[1] = readvec[1-k] - (readvec[1-k] - readvec[0-k])*(t_sample)fract;
del256 += inc256;
fractindex = del256 & 0xff;
fract = n_delay2p_line_tilde_256f[fractindex];
k = del256 >> 8;
- out[2] = readvec[2-k] - (readvec[2-k] - readvec[1-k])*fract;
+ out[2] = readvec[2-k] - (readvec[2-k] - readvec[1-k])*(t_sample)fract;
del256 += inc256;
fractindex = del256 & 0xff;
fract = n_delay2p_line_tilde_256f[fractindex];
k = del256 >> 8;
- out[3] = readvec[3-k] - (readvec[3-k] - readvec[2-k])*fract;
+ out[3] = readvec[3-k] - (readvec[3-k] - readvec[2-k])*(t_sample)fract;
del256 += inc256;
fractindex = del256 & 0xff;
fract = n_delay2p_line_tilde_256f[fractindex];
k = del256 >> 8;
- out[4] = readvec[4-k] - (readvec[4-k] - readvec[3-k])*fract;
+ out[4] = readvec[4-k] - (readvec[4-k] - readvec[3-k])*(t_sample)fract;
del256 += inc256;
fractindex = del256 & 0xff;
fract = n_delay2p_line_tilde_256f[fractindex];
k = del256 >> 8;
- out[5] = readvec[5-k] - (readvec[5-k] - readvec[4-k])*fract;
+ out[5] = readvec[5-k] - (readvec[5-k] - readvec[4-k])*(t_sample)fract;
del256 += inc256;
fractindex = del256 & 0xff;
fract = n_delay2p_line_tilde_256f[fractindex];
k = del256 >> 8;
- out[6] = readvec[6-k] - (readvec[6-k] - readvec[5-k])*fract;
+ out[6] = readvec[6-k] - (readvec[6-k] - readvec[5-k])*(t_sample)fract;
del256 += inc256;
fractindex = del256 & 0xff;
fract = n_delay2p_line_tilde_256f[fractindex];
k = del256 >> 8;
- out[7] = readvec[7-k] - (readvec[7-k] - readvec[6-k])*fract;
+ out[7] = readvec[7-k] - (readvec[7-k] - readvec[6-k])*(t_sample)fract;
del256 += inc256;
out += 8;
@@ -325,7 +315,7 @@ static t_int *n_delay2p_line_tilde_perf8(t_int *w)
for(j=0; j<nout; j++)
{
del256 = x->x_del_samp256_cur[j] = x->x_del_samp256_end[j];
- readvec = begvec1 + writeindex - (del256 >> 8);
+ readvec = begvec2 + writeindex - (del256 >> 8);
out = x->x_io[j+1];
n = hn;
while(n)
@@ -360,34 +350,34 @@ static void n_delay2p_line_tilde_dsp(t_n_delay2p_line_tilde *x, t_signal **sp)
if(!x->x_blocksize)/*first time*/
{
- int nsamps = x->x_max_delay_ms * (t_float)sp[0]->s_sr * 0.001f;
+ int nsamps = x->x_max_delay_ms * (t_float)sp[0]->s_sr * (t_float)0.001;
if(nsamps < 1)
nsamps = 1;
nsamps += ((- nsamps) & (n - 1));
nsamps += n;
x->x_mallocsize = nsamps;
- x->x_begmem0 = (t_float *)getbytes(2 * x->x_mallocsize * sizeof(t_float));
- x->x_begmem1 = x->x_begmem0 + x->x_mallocsize;
+ x->x_begmem1 = (t_sample *)getbytes(2 * x->x_mallocsize * sizeof(t_sample));
+ x->x_begmem2 = x->x_begmem1 + x->x_mallocsize;
x->x_writeindex = n;
}
else if((x->x_blocksize != n) || ((t_float)sp[0]->s_sr != x->x_sr))
{
- int nsamps = x->x_max_delay_ms * (t_float)sp[0]->s_sr * 0.001f;
+ int nsamps = x->x_max_delay_ms * (t_float)sp[0]->s_sr * (t_float)0.001;
if(nsamps < 1)
nsamps = 1;
nsamps += ((- nsamps) & (n - 1));
nsamps += n;
- x->x_begmem0 = (t_float *)resizebytes(x->x_begmem0, 2*x->x_mallocsize*sizeof(t_float), 2*nsamps*sizeof(t_float));
+ x->x_begmem1 = (t_sample *)resizebytes(x->x_begmem1, 2*x->x_mallocsize*sizeof(t_sample), 2*nsamps*sizeof(t_sample));
x->x_mallocsize = nsamps;
- x->x_begmem1 = x->x_begmem0 + x->x_mallocsize;
+ x->x_begmem2 = x->x_begmem1 + x->x_mallocsize;
if(x->x_writeindex >= nsamps)
x->x_writeindex -= nsamps;
}
x->x_blocksize = n;
- x->x_ms2tick = 0.001f * (t_float)sp[0]->s_sr / (t_float)n;
- x->x_ms2samples256 = 0.256f * (t_float)sp[0]->s_sr;
+ x->x_ms2tick = (t_float)0.001 * (t_float)sp[0]->s_sr / (t_float)n;
+ x->x_ms2samples256 = (t_float)0.256 * (t_float)sp[0]->s_sr;
x->x_interpol_ticks = (int)(x->x_ms2tick * x->x_interpol_ms);
for(i=0; i<nd; i++)
x->x_io[i] = sp[i]->s_vec;
@@ -401,7 +391,7 @@ static void *n_delay2p_line_tilde_new(t_floatarg fout, t_floatarg delay_ms, t_fl
{
t_n_delay2p_line_tilde *x = (t_n_delay2p_line_tilde *)pd_new(n_delay2p_line_tilde_class);
int i, n_out = (int)fout;
- int nsamps = delay_ms * sys_getsr() * 0.001f;
+ int nsamps = delay_ms * sys_getsr() * (t_float)0.001;
if(n_out < 1)
n_out = 1;
@@ -412,15 +402,15 @@ static void *n_delay2p_line_tilde_new(t_floatarg fout, t_floatarg delay_ms, t_fl
nsamps += ((- nsamps) & (DELLINE_DEF_VEC_SIZE - 1));
nsamps += DELLINE_DEF_VEC_SIZE;
x->x_mallocsize = nsamps;
- x->x_begmem0 = (t_float *)getbytes(2 * x->x_mallocsize * sizeof(t_float));
- x->x_begmem1 = x->x_begmem0 + x->x_mallocsize;
+ x->x_begmem1 = (t_sample *)getbytes(2 * x->x_mallocsize * sizeof(t_sample));
+ x->x_begmem2 = x->x_begmem1 + x->x_mallocsize;
x->x_writeindex = DELLINE_DEF_VEC_SIZE;
x->x_blocksize = 0;
- x->x_sr = 0.0f;
- if(interpol_ms < 0.0f)
- interpol_ms = 0.0f;
+ x->x_sr = (t_float)0.0;
+ if(interpol_ms < (t_float)0.0)
+ interpol_ms = (t_float)0.0;
x->x_interpol_ms = interpol_ms;
- x->x_io = (t_float **)getbytes((x->x_n_delays + 1) * sizeof(t_float *));
+ x->x_io = (t_sample **)getbytes((x->x_n_delays + 1) * sizeof(t_sample *));
for(i=0; i<n_out; i++)
outlet_new(&x->x_obj, &s_signal);
x->x_del_samp256_end = (int *)getbytes(x->x_n_delays * sizeof(int));
@@ -434,7 +424,7 @@ static void *n_delay2p_line_tilde_new(t_floatarg fout, t_floatarg delay_ms, t_fl
x->x_inc256[i] = x->x_biginc256[i] = 0;
}
x->x_interpol_ticks = 0;
- x->x_msi = 0.0f;
+ x->x_scalar_sig_in = (t_float)0.0;
n_delay2p_line_tilde_init_f(x);
return (x);
}
@@ -445,18 +435,17 @@ static void n_delay2p_line_tilde_free(t_n_delay2p_line_tilde *x)
freebytes(x->x_del_samp256_cur, x->x_n_delays * sizeof(int));
freebytes(x->x_inc256, x->x_n_delays * sizeof(int));
freebytes(x->x_biginc256, x->x_n_delays * sizeof(int));
- freebytes(x->x_io, (x->x_n_delays + 1) * sizeof(t_float *));
- freebytes(x->x_begmem0, 2 * x->x_mallocsize * sizeof(t_float));
+ freebytes(x->x_io, (x->x_n_delays + 1) * sizeof(t_sample *));
+ freebytes(x->x_begmem1, 2 * x->x_mallocsize * sizeof(t_sample));
}
void n_delay2p_line_tilde_setup(void)
{
n_delay2p_line_tilde_class = class_new(gensym("n_delay2p_line~"), (t_newmethod)n_delay2p_line_tilde_new, (t_method)n_delay2p_line_tilde_free,
sizeof(t_n_delay2p_line_tilde), 0, A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT, 0);
- CLASS_MAINSIGNALIN(n_delay2p_line_tilde_class, t_n_delay2p_line_tilde, x_msi);
+ CLASS_MAINSIGNALIN(n_delay2p_line_tilde_class, t_n_delay2p_line_tilde, x_scalar_sig_in);
class_addlist(n_delay2p_line_tilde_class, (t_method)n_delay2p_line_tilde_list);
class_addmethod(n_delay2p_line_tilde_class, (t_method)n_delay2p_line_tilde_dsp, gensym("dsp"), 0);
class_addmethod(n_delay2p_line_tilde_class, (t_method)n_delay2p_line_tilde_stop, gensym("stop"), 0);
class_addmethod(n_delay2p_line_tilde_class, (t_method)n_delay2p_line_tilde_time, gensym("time"), A_FLOAT, 0);
-// class_sethelpsymbol(n_delay2p_line_tilde_class, gensym("iemhelp2/n_delay2p_line~-help"));
}
diff --git a/src/nz~.c b/src/nz~.c
index 0f8b249..09aa05c 100644
--- a/src/nz~.c
+++ b/src/nz~.c
@@ -1,29 +1,30 @@
/* For information on usage and redistribution, and for a DISCLAIMER OF ALL
* WARRANTIES, see the file, "LICENSE.txt," in this distribution.
-iem_delay written by Thomas Musil (c) IEM KUG Graz Austria 2002 - 2006 */
+iem_delay written by Thomas Musil (c) IEM KUG Graz Austria 2002 - 2011 */
#include "m_pd.h"
#include "iemlib.h"
#include "iem_delay.h"
-/* -------------------------- nz_tilde~ ------------------------------ */
+/* --------------------------- nz_tilde~ ------------------------------ */
+/* --- one delwrite~and several delread~, independend of samplerate --- */
static t_class *nz_tilde_class;
typedef struct _nz_tilde
{
t_object x_obj;
- t_float *x_begmem1;
- t_float *x_begmem2;
+ t_sample *x_begmem1;
+ t_sample *x_begmem2;
int x_mallocsize;
int x_max_delay_samples;
int x_n_delays;
int x_writeindex;
int *x_del_samples;
int x_blocksize;
- t_float **x_io;
- t_float x_msi;
+ t_sample **x_io;
+ t_float x_scalar_sig_in;
} t_nz_tilde;
static void nz_tilde_list(t_nz_tilde *x, t_symbol *s, int argc, t_atom *argv)
@@ -51,12 +52,12 @@ static t_int *nz_tilde_perform(t_int *w)
t_nz_tilde *x = (t_nz_tilde *)(w[1]);
int n=(int)(w[2]);
int num_dels=x->x_n_delays;
- t_float *in;
- t_float *out;
+ t_sample *in;
+ t_sample *out;
int i, j;
- t_float *writevec1;
- t_float *writevec2;
- t_float *readvec;
+ t_sample *writevec1;
+ t_sample *writevec2;
+ t_sample *readvec;
writevec2 = x->x_begmem2 + x->x_writeindex;
writevec1 = x->x_begmem1 + x->x_writeindex;
@@ -87,12 +88,12 @@ static t_int *nz_tilde_perf8(t_int *w)
t_nz_tilde *x = (t_nz_tilde *)(w[1]);
int n=(int)(w[2]);
int num_dels=x->x_n_delays;
- t_float *in;
- t_float *out;
+ t_sample *in;
+ t_sample *out;
int i, j;
- t_float *writevec1;
- t_float *writevec2;
- t_float *readvec;
+ t_sample *writevec1;
+ t_sample *writevec2;
+ t_sample *readvec;
writevec2 = x->x_begmem2 + x->x_writeindex;
writevec1 = x->x_begmem1 + x->x_writeindex;
@@ -127,7 +128,7 @@ static t_int *nz_tilde_perf8(t_int *w)
for(j=0; j<num_dels; j++)
{
out = x->x_io[j+1];
- readvec = writevec2 - x->x_del_samples[j];
+ readvec = x->x_begmem2 + x->x_writeindex - x->x_del_samples[j];
i = n;
while(i)
{
@@ -155,40 +156,32 @@ static t_int *nz_tilde_perf8(t_int *w)
static void nz_tilde_dsp(t_nz_tilde *x, t_signal **sp)
{
int n = sp[0]->s_n;
- int i, j, max_samps, num_dels = x->x_n_delays + 1;
+ int i, max_samps, num_io = x->x_n_delays + 1;
if(!x->x_blocksize)/*first time*/
{
max_samps = x->x_max_delay_samples;
- i = max_samps / n;
- j = max_samps - i * n;
+ max_samps += ((- max_samps) & (n - 1));
+ max_samps += n;
/* allocate memory as a multiple of blocksize */
- if(j)
- max_samps = (i+1) * n;
- else
- max_samps = i * n;
-// post("malloc = %d, maxdel = %d", max_samps, x->x_max_delay_samples);
x->x_mallocsize = max_samps;
- x->x_begmem1 = (t_float *)getbytes(2 * x->x_mallocsize * sizeof(t_float));
+ x->x_begmem1 = (t_sample *)getbytes(2 * x->x_mallocsize * sizeof(t_sample));
x->x_begmem2 = x->x_begmem1 + x->x_mallocsize;
x->x_writeindex = 0;
}
else if(x->x_blocksize != n)
{
max_samps = x->x_max_delay_samples;
- i = max_samps / n;
- j = max_samps - i * n;
- if(j)
- max_samps = (i+1) * n;
- else
- max_samps = i * n;
- x->x_begmem1 = (t_float *)resizebytes(x->x_begmem1, 2*x->x_mallocsize*sizeof(t_float), 2*max_samps*sizeof(t_float));
+ max_samps += ((- max_samps) & (n - 1));
+ max_samps += n;
+ /* allocate memory as a multiple of blocksize */
+ x->x_begmem1 = (t_sample *)resizebytes(x->x_begmem1, 2*x->x_mallocsize*sizeof(t_sample), 2*max_samps*sizeof(t_sample));
x->x_mallocsize = max_samps;
x->x_begmem2 = x->x_begmem1 + x->x_mallocsize;
x->x_writeindex = 0;
}
x->x_blocksize = n;
- for(i=0; i<num_dels; i++)
+ for(i=0; i<num_io; i++)
x->x_io[i] = sp[i]->s_vec;
if(n&7)
dsp_add(nz_tilde_perform, 2, x, n);
@@ -209,35 +202,34 @@ static void *nz_tilde_new(t_floatarg n_delays, t_floatarg max_delay_samples)
max_samps = 1;
x->x_max_delay_samples = max_samps;
x->x_mallocsize = 0;
- x->x_begmem1 = (t_float *)0;
- x->x_begmem2 = (t_float *)0;
+ x->x_begmem1 = (t_sample *)0;
+ x->x_begmem2 = (t_sample *)0;
x->x_writeindex = 0;
x->x_blocksize = 0;
- x->x_io = (t_float **)getbytes((x->x_n_delays + 1) * sizeof(t_float *));
+ x->x_io = (t_sample **)getbytes((x->x_n_delays + 1) * sizeof(t_sample *));
x->x_del_samples = (int *)getbytes(x->x_n_delays * sizeof(int));
for(i=0; i<n_out; i++)
{
outlet_new(&x->x_obj, &s_signal);
x->x_del_samples[i] = 0;
}
- x->x_msi = 0.0f;
+ x->x_scalar_sig_in = (t_float)0.0;
return (x);
}
static void nz_tilde_free(t_nz_tilde *x)
{
freebytes(x->x_del_samples, x->x_n_delays * sizeof(int));
- freebytes(x->x_io, (x->x_n_delays + 1) * sizeof(t_float *));
+ freebytes(x->x_io, (x->x_n_delays + 1) * sizeof(t_sample *));
if(x->x_begmem1)
- freebytes(x->x_begmem1, 2 * x->x_mallocsize * sizeof(t_float));
+ freebytes(x->x_begmem1, 2 * x->x_mallocsize * sizeof(t_sample));
}
void nz_tilde_setup(void)
{
nz_tilde_class = class_new(gensym("nz~"), (t_newmethod)nz_tilde_new, (t_method)nz_tilde_free,
sizeof(t_nz_tilde), 0, A_DEFFLOAT, A_DEFFLOAT, 0);
- CLASS_MAINSIGNALIN(nz_tilde_class, t_nz_tilde, x_msi);
+ CLASS_MAINSIGNALIN(nz_tilde_class, t_nz_tilde, x_scalar_sig_in);
class_addlist(nz_tilde_class, (t_method)nz_tilde_list);
class_addmethod(nz_tilde_class, (t_method)nz_tilde_dsp, gensym("dsp"), 0);
-// class_sethelpsymbol(nz_tilde_class, gensym("iemhelp2/nz~-help"));
}