[PD] extensions to expr object
Orm Finnendahl
finnendahl at folkwang-hochschule.de
Wed May 22 20:48:55 CEST 2002
Hi,
I extended the expr object so that it now includes the floor, ceil and
fmod functions from ANSI C as well. The patch for vexpr_fun.c and a
short demonstration of the new extensions is attached.
Miller, would you be willing to incorporate that in a future release?
That'd save the hassle of patching it for every upgrade on my machine
:-)
Yours,
Orm
-------------- next part --------------
28a29
> /* May 2002 - additional floor, ceil and fmod for expr -- Orm Finnendahl */
83a85,87
> static void ex_floor(t_expr *expr, long int argc, struct ex_ex *argv, struct ex_ex *optr);
> static void ex_fmod(t_expr *expr, long int argc, struct ex_ex *argv, struct ex_ex *optr);
> static void ex_ceil(t_expr *expr, long int argc, struct ex_ex *argv, struct ex_ex *optr);
109a114,116
> {"floor", ex_floor, 1},
> {"fmod", ex_fmod, 2},
> {"ceil", ex_ceil, 1},
356c363
< * ex_min -- if any of the arfuments are or the output are vectors, a vector
---
> * ex_min -- if any of the arguments are or the output are vectors, a vector
481a489,541
>
> /*
> * ex_floor -- floor
> */
> static void
> ex_floor(t_expr *e, long int argc, struct ex_ex *argv, struct ex_ex *optr)
> {
> struct ex_ex *left;
> float *op; /* output pointer */
> float *lp, *rp; /* left and right vector pointers */
> float scalar;
> int j;
> left = argv++;
>
> FUNC_EVAL_UNARY(left, floor, (double), optr);
> }
>
>
> /*
> * ex_fmod -- fmod
> */
> static void
> ex_fmod(t_expr *e, long int argc, struct ex_ex *argv, struct ex_ex *optr)
> {
> struct ex_ex *left, *right;
> float *op; /* output pointer */
> float *lp, *rp; /* left and right vector pointers */
> float scalar;
> int j;
>
> left = argv++;
> right = argv;
> FUNC_EVAL(left, right, fmod, (double), (double), optr);
> }
>
> /*
> * ex_ceil -- ceil
> */
> static void
> ex_ceil(t_expr *e, long int argc, struct ex_ex *argv, struct ex_ex *optr)
> {
> struct ex_ex *left;
> float *op; /* output pointer */
> float *lp, *rp; /* left and right vector pointers */
> float scalar;
> int j;
>
> left = argv++;
>
> FUNC_EVAL_UNARY(left, ceil, (double), optr);
> }
>
>
-------------- next part --------------
#N canvas 0 0 709 300 10;
#X msg 163 92 7.31;
#X floatatom 181 213 5 0 0;
#X obj 169 122 expr fmod($f1 \, 1.0);
#X msg 205 94 -0.3;
#X obj 194 167 < 0;
#X obj 181 191 +;
#X obj 143 37 expr floor($f1);
#X floatatom 144 61 5 0 0;
#X msg 144 9 3.4;
#X obj 41 38 expr ceil($f1);
#X floatatom 42 60 5 0 0;
#X floatatom 142 213 5 0 0;
#X obj 169 143 t 0 0;
#X text 290 122 alert: to get float values at the outlet \, the second
argument to fmod has to be written as a float;
#X connect 0 0 2 0;
#X connect 2 0 12 0;
#X connect 3 0 2 0;
#X connect 4 0 5 1;
#X connect 5 0 1 0;
#X connect 6 0 7 0;
#X connect 8 0 6 0;
#X connect 8 0 9 0;
#X connect 9 0 10 0;
#X connect 12 0 5 0;
#X connect 12 0 11 0;
#X connect 12 1 4 0;
More information about the Pd-list
mailing list