Added some small boring scripts and programs writen in few last years
[mirrors/Programs.git] / puredata / 6.externs / obj4.c
CommitLineData
21c4e167
H
1/* code for the "obj4" pd class. This adds a creation argument, of
2type "float". */
3
4#include "m_pd.h"
5
6typedef struct obj4
7{
8 t_object x_ob;
9 t_outlet *x_outlet;
10 float x_value;
11} t_obj4;
12
13void obj4_float(t_obj4 *x, t_floatarg f)
14{
15 outlet_float(x->x_outlet, x->x_value + f);
16}
17
18void obj4_ft1(t_obj4 *x, t_floatarg g)
19{
20 x->x_value = g;
21}
22
23t_class *obj4_class;
24
25 /* as requested by the new invocation of "class_new" below, the new
26 routine will be called with a "float" argument. */
27void *obj4_new(t_floatarg f)
28{
29 t_obj4 *x = (t_obj4 *)pd_new(obj4_class);
30 inlet_new(&x->x_ob, &x->x_ob.ob_pd, gensym("float"), gensym("ft1"));
31 x->x_outlet = outlet_new(&x->x_ob, gensym("float"));
32 /* just stick the argument in the object structure for later. */
33 x->x_value = f;
34 return (void *)x;
35}
36
37void obj4_setup(void)
38{
39 /* here we add "A_DEFFLOAT" to the (zero-terminated) list of arg
40 types we declare for a new object. The value will be filled
41 in as 0 if not given in the object box. */
42 obj4_class = class_new(gensym("obj4"), (t_newmethod)obj4_new,
43 0, sizeof(t_obj4), 0, A_DEFFLOAT, 0);
44 class_addmethod(obj4_class, (t_method)obj4_ft1, gensym("ft1"), A_FLOAT, 0);
45 class_addfloat(obj4_class, obj4_float);
46}
47
This page took 0.105959 seconds and 4 git commands to generate.