aboutsummaryrefslogtreecommitdiff
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
parentb2fcfea5f72fcecb86ee93d12dfb551ef6be541d (diff)
added 'table-offset' to [FIR~]HEADsvn2git-headexternals/iemlib
svn path=/trunk/externals/iemlib/; revision=17560
-rw-r--r--iemlib1/FIR~-help.pd37
-rw-r--r--iemlib1/src/FIR~.c22
2 files changed, 35 insertions, 24 deletions
diff --git a/iemlib1/FIR~-help.pd b/iemlib1/FIR~-help.pd
index 0f1f517..2333f18 100644
--- a/iemlib1/FIR~-help.pd
+++ b/iemlib1/FIR~-help.pd
@@ -1,50 +1,52 @@
-#N canvas 345 25 559 627 10;
-#N canvas 0 22 450 300 (subpatch) 0;
+#N canvas 347 49 624 627 10;
+#N canvas 0 50 450 300 (subpatch) 0;
#X array fir_coeff 256 float 0;
#X coords 0 1 255 -1 256 140 1;
#X restore 63 195 graph;
#X obj 109 154 soundfiler;
-#X floatatom 4 133 5 0 0 0 - - -;
+#X floatatom 4 133 5 0 0 0 - - -, f 5;
#X text 32 96 % cpu;
#X obj 4 93 dsp;
#X obj 4 73 tgl 15 0 empty empty dsp_ON/OFF 2 -8 0 10 -225271 -42246
-90881 1 1;
-#X floatatom 413 444 7 0 0 0 - - -;
+#X floatatom 413 444 7 0 0 0 - - -, f 7;
#X obj 342 323 dac~;
#X obj 342 297 gainvu~ 300;
#X obj 404 319 vu 15 120 empty empty 8 -8 0 10 -66577 -1 1 0;
#X obj 491 166 vsl 15 128 0 127 0 1 empty empty gain -7 -8 0 10 -225271
--42246 -90881 4400 1;
-#X obj 343 75 noise~;
-#X floatatom 403 462 7 0 0 0 - - -;
+-42246 -90881 0 1;
+#X obj 343 55 noise~;
+#X floatatom 403 462 7 0 0 0 - - -, f 7;
#X obj 109 71 bng 15 250 50 1 empty empty loadbang 0 -8 0 10 -225271
-24198 -90881;
#X msg 109 91 read -resize lp1.wav fir_coeff;
#X msg 114 112 read -resize lp2.wav fir_coeff;
#X msg 121 132 read -resize lp3.wav fir_coeff;
#X obj 19 406 soundfiler;
-#N canvas 0 22 450 300 (subpatch) 0;
+#N canvas 0 50 450 300 (subpatch) 0;
#X array fir_coeff2 256 float 0;
#X coords 0 1 255 -1 256 140 1;
#X restore 70 452 graph;
#X msg 20 385 read -resize lp3.wav fir_coeff2;
#X obj 20 365 bng 15 250 50 1 empty empty loadbang 0 -8 0 10 -225271
-24198 -90881;
-#X msg 359 105 set fir_coeff 256;
-#X msg 373 127 set fir_coeff2 256;
-#X floatatom 17 113 5 0 0 0 - - -;
+#X msg 359 85 set fir_coeff 256;
+#X msg 373 107 set fir_coeff2 256;
+#X floatatom 17 113 5 0 0 0 - - -, f 5;
#X obj 343 155 FIR~ fir_coeff 256;
-#X text 398 517 IEM KUG;
-#X text 382 505 musil;
-#X text 412 505 @;
-#X text 418 505 iem.at;
+#X text 398 527 IEM KUG;
+#X text 378 506 musil;
+#X text 413 505 @;
+#X text 422 506 iem.at;
#X text 333 494 (c) Thomas Musil 2000 - 2005;
-#X text 381 527 Graz \, Austria;
+#X text 381 537 Graz \, Austria;
#X text 15 13 FIR~;
#X text 50 12 convolve a signal with an array;
#X text 276 5 1.arg: <symbol> array-name;
#X text 276 15 2.arg: <float> convolution-length;
-#X floatatom 376 273 5 0 0 0 - - -;
+#X floatatom 376 273 5 0 0 0 - - -, f 5;
+#X text 277 27 3.arg: <float> optional table onset;
+#X msg 393 127 set fir_coeff 128 64;
#X connect 4 0 2 0;
#X connect 4 1 23 0;
#X connect 5 0 4 0;
@@ -65,3 +67,4 @@
#X connect 21 0 24 0;
#X connect 22 0 24 0;
#X connect 24 0 8 0;
+#X connect 37 0 24 0;
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);
}