diff options
author | Cyrille Henry <nusmuk@users.sourceforge.net> | 2015-10-02 12:45:42 +0000 |
---|---|---|
committer | Cyrille Henry <nusmuk@users.sourceforge.net> | 2015-10-02 12:45:42 +0000 |
commit | b05a9c45123938fa76e448ae55f9007b319d7d9f (patch) | |
tree | db96c6d2eae1e394dc678849763e6d48dad968ae /nusmuk-utils/tab_downsample.c | |
parent | 04d4f420be4be2480f86238cb5e5a61a04f63817 (diff) |
protection to avoir division by zeroHEADsvn2git-head.1master
svn path=/trunk/externals/nusmuk/; revision=17570
Diffstat (limited to 'nusmuk-utils/tab_downsample.c')
-rw-r--r-- | nusmuk-utils/tab_downsample.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/nusmuk-utils/tab_downsample.c b/nusmuk-utils/tab_downsample.c index b94c458..f584426 100644 --- a/nusmuk-utils/tab_downsample.c +++ b/nusmuk-utils/tab_downsample.c @@ -20,6 +20,8 @@ void *tab_downsample_new(t_symbol *s_src,t_symbol *s_dst, t_float factor) x->x_arrayname_src = s_src; x->x_arrayname_dst = s_dst; x->factor = factor; + x->factor = MAX(1, factor); + x->offset = 0; x->b_out = outlet_new(&x->x_obj, &s_bang); @@ -47,6 +49,7 @@ void tab_downsample_compute(t_tab_downsample *x) else { nb_max = MIN((npoints_src - x->offset)/x->factor, npoints_dst); + //nb_max = MAX(nb_max, 1); // post("nb_max = %d",nb_max); index_src = x->offset; @@ -80,7 +83,7 @@ void tab_downsample_dst(t_tab_downsample *x, t_symbol *s_dst) { } void tab_downsample_factor(t_tab_downsample *x, t_float factor) { - x->factor = factor; + x->factor = MAX(1, factor); } void tab_downsample_setup(void) { |