aboutsummaryrefslogtreecommitdiff
path: root/iemlib1/src
diff options
context:
space:
mode:
authorIOhannes m zmölnig <zmoelnig@users.sourceforge.net>2015-09-08 17:39:40 +0000
committerIOhannes m zmölnig <zmoelnig@users.sourceforge.net>2015-09-08 17:39:40 +0000
commit1a17da71d4c1b6f64da439eb975012d8384d736e (patch)
treed5a41f90279912e11a69aa06dbb53c489f6f6796 /iemlib1/src
parentb2fcfea5f72fcecb86ee93d12dfb551ef6be541d (diff)
added 'table-offset' to [FIR~]HEADsvn2git-headexternals/iemlib
svn path=/trunk/externals/iemlib/; revision=17560
Diffstat (limited to 'iemlib1/src')
-rw-r--r--iemlib1/src/FIR~.c22
1 files changed, 15 insertions, 7 deletions
diff --git a/iemlib1/src/FIR~.c b/iemlib1/src/FIR~.c
index 07f8417..0dc82c6 100644
--- a/iemlib1/src/FIR~.c
+++ b/iemlib1/src/FIR~.c
@@ -17,6 +17,7 @@ typedef struct _FIR_tilde
t_sample *x_history_beg;
int x_rw_index;
int x_fir_order;
+ int x_fir_offset;
int x_malloc_history;
t_symbol *x_table_name;
t_float x_float_sig_in;
@@ -33,9 +34,10 @@ static t_int *FIR_tilde_perform(t_int *w)
int rw_index = x->x_rw_index;
int i, j;
int order = x->x_fir_order;
+ int offset = x->x_fir_offset;
int ord16 = order / 16;
t_sample sum=0.0;
- iemarray_t *coef = x->x_array_coef_beg;
+ iemarray_t *coef = x->x_array_coef_beg + offset;
t_sample *write_hist1=x->x_history_beg;
t_sample *write_hist2;
t_sample *read_hist;
@@ -99,17 +101,19 @@ FIR_tildeperfzero:
return(w+5);
}
-void FIR_tilde_set(t_FIR_tilde *x, t_symbol *table_name, t_floatarg forder)
+void FIR_tilde_set(t_FIR_tilde *x, t_symbol *table_name, t_floatarg forder, t_floatarg foffset)
{
t_garray *ga;
int table_size;
int order = (int)forder;
+ int offset = (foffset<1.0)?0:(int)foffset;
int i;
x->x_table_name = table_name;
if(order < 1)
order = 1;
x->x_fir_order = order;
+ x->x_fir_offset = offset;
if(!(ga = (t_garray *)pd_findbyclass(x->x_table_name, garray_class)))
{
if(*table_name->s_name)
@@ -123,7 +127,7 @@ void FIR_tilde_set(t_FIR_tilde *x, t_symbol *table_name, t_floatarg forder)
}
else if(table_size < order)
{
- error("FIR~: tablesize %d < order %d !!!!", table_size, order);
+ error("FIR~: tablesize %d < order %d + offset %d !!!!", table_size, order, offset);
x->x_array_coef_beg = (iemarray_t *)0;
}
else
@@ -140,14 +144,15 @@ void FIR_tilde_set(t_FIR_tilde *x, t_symbol *table_name, t_floatarg forder)
static void FIR_tilde_dsp(t_FIR_tilde *x, t_signal **sp)
{
- FIR_tilde_set(x, x->x_table_name, x->x_fir_order);
+ FIR_tilde_set(x, x->x_table_name, x->x_fir_order, x->x_fir_offset);
dsp_add(FIR_tilde_perform, 4, sp[0]->s_vec, sp[1]->s_vec, x, sp[0]->s_n);
}
-static void *FIR_tilde_new(t_symbol *array_name, t_floatarg forder)
+static void *FIR_tilde_new(t_symbol *array_name, t_floatarg forder, t_floatarg foffset)
{
t_FIR_tilde *x = (t_FIR_tilde *)pd_new(FIR_tilde_class);
int order = (int)forder;
+ int offset= (int)foffset;
outlet_new(&x->x_obj, &s_signal);
x->x_float_sig_in = 0;
@@ -155,7 +160,10 @@ static void *FIR_tilde_new(t_symbol *array_name, t_floatarg forder)
x->x_array_coef_beg = 0;
if(order < 1)
order = 1;
+ if(offset < 0)
+ offset = 0;
x->x_fir_order = order;
+ x->x_fir_offset = offset;
x->x_malloc_history = order;
x->x_history_beg = (t_sample *)getbytes((2*x->x_malloc_history)*sizeof(t_sample));
x->x_rw_index = 0;
@@ -171,8 +179,8 @@ static void FIR_tilde_free(t_FIR_tilde *x)
void FIR_tilde_setup(void)
{
FIR_tilde_class = class_new(gensym("FIR~"), (t_newmethod)FIR_tilde_new,
- (t_method)FIR_tilde_free, sizeof(t_FIR_tilde), 0, A_DEFSYM, A_DEFFLOAT, 0);
+ (t_method)FIR_tilde_free, sizeof(t_FIR_tilde), 0, A_DEFSYM, A_DEFFLOAT, A_DEFFLOAT, 0);
CLASS_MAINSIGNALIN(FIR_tilde_class, t_FIR_tilde, x_float_sig_in);
class_addmethod(FIR_tilde_class, (t_method)FIR_tilde_dsp, gensym("dsp"), 0);
- class_addmethod(FIR_tilde_class, (t_method)FIR_tilde_set, gensym("set"), A_SYMBOL, A_FLOAT, 0);
+ class_addmethod(FIR_tilde_class, (t_method)FIR_tilde_set, gensym("set"), A_SYMBOL, A_FLOAT, A_DEFFLOAT, 0);
}