aboutsummaryrefslogtreecommitdiff
path: root/src/tabread4~~.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/tabread4~~.c')
-rw-r--r--src/tabread4~~.c97
1 files changed, 49 insertions, 48 deletions
diff --git a/src/tabread4~~.c b/src/tabread4~~.c
index 6c53508..96d2003 100644
--- a/src/tabread4~~.c
+++ b/src/tabread4~~.c
@@ -1,4 +1,4 @@
-/*
+/*
* tabread4~~: a tabread with 2 inputs for higher precision
*
* (c) 1999-2011 IOhannes m zmölnig, forum::für::umläute, institute of electronic music and acoustics (iem)
@@ -7,12 +7,12 @@
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
@@ -25,8 +25,7 @@
static t_class *tabread4_tilde_class;
-typedef struct _tabread4_tilde
-{
+typedef struct _tabread4_tilde {
t_object x_obj;
int x_npoints;
zarray_t *x_vec;
@@ -53,64 +52,66 @@ static t_int *tabread4_tilde_perform(t_int *w)
t_sample *in = (t_sample *)(w[2]);
t_sample *in1 = (t_sample *)(w[3]);
t_sample *out = (t_sample *)(w[4]);
- int n = (int)(w[5]);
+ int n = (int)(w[5]);
int maxindex;
zarray_t *buf = x->x_vec, *wp;
int i;
-
+
maxindex = x->x_npoints - 3;
- if (!buf){
- while (n--) *out++ = 0;
+ if (!buf) {
+ while (n--) {
+ *out++ = 0;
+ }
return (w+6);
}
- for (i = 0; i < n; i++)
- {
- t_sample in0_s=*in++;
- t_sample in1_s=*in1++;
- double findex = (double)in0_s + (double)in1_s;
- long int index = findex;
- double frac;
- t_sample a, b, c, d, cminusb;
- if (index < 1)
- index = 1, frac = 0;
- else if (index > maxindex)
- index = maxindex, frac = 1;
- else frac = findex - index;
-
- wp = buf + index;
-
- a = zarray_getfloat(wp,-1);
- b = zarray_getfloat(wp, 0);
- c = zarray_getfloat(wp, 1);
- d = zarray_getfloat(wp, 2);
-
- cminusb = c-b;
- *out++ = b + frac * (
- cminusb - 0.1666667f * (1.-frac) * (
- (d - a - 3.0f * cminusb) * frac + (d + 2.0f*a - 3.0f*b)
- )
- );
+ for (i = 0; i < n; i++) {
+ t_sample in0_s=*in++;
+ t_sample in1_s=*in1++;
+ double findex = (double)in0_s + (double)in1_s;
+ long int index = findex;
+ double frac;
+ t_sample a, b, c, d, cminusb;
+ if (index < 1) {
+ index = 1, frac = 0;
+ } else if (index > maxindex) {
+ index = maxindex, frac = 1;
+ } else {
+ frac = findex - index;
}
+
+ wp = buf + index;
+
+ a = zarray_getfloat(wp,-1);
+ b = zarray_getfloat(wp, 0);
+ c = zarray_getfloat(wp, 1);
+ d = zarray_getfloat(wp, 2);
+
+ cminusb = c-b;
+ *out++ = b + frac * (
+ cminusb - 0.1666667f * (1.-frac) * (
+ (d - a - 3.0f * cminusb) * frac + (d + 2.0f*a - 3.0f*b)
+ )
+ );
+ }
return (w+6);
}
static void tabread4_tilde_set(t_tabread4_tilde *x, t_symbol *s)
{
t_garray *a;
-
+
x->x_arrayname = s;
- if (!(a = (t_garray *)pd_findbyclass(x->x_arrayname, garray_class)))
- {
- if (*s->s_name)
- pd_error(x, "tabread4~~: %s: no such array", x->x_arrayname->s_name);
- x->x_vec = 0;
- }
- else if (!zarray_getarray(a, &x->x_npoints, &x->x_vec))
- {
- pd_error(x, "%s: bad template for tabread4~~", x->x_arrayname->s_name);
- x->x_vec = 0;
+ if (!(a = (t_garray *)pd_findbyclass(x->x_arrayname, garray_class))) {
+ if (*s->s_name) {
+ pd_error(x, "tabread4~~: %s: no such array", x->x_arrayname->s_name);
}
- else garray_usedindsp(a);
+ x->x_vec = 0;
+ } else if (!zarray_getarray(a, &x->x_npoints, &x->x_vec)) {
+ pd_error(x, "%s: bad template for tabread4~~", x->x_arrayname->s_name);
+ x->x_vec = 0;
+ } else {
+ garray_usedindsp(a);
+ }
}
static void tabread4_tilde_dsp(t_tabread4_tilde *x, t_signal **sp)