2
* Pure Data Packet module.
3
* Copyright (c) by Tom Schouten <pdp@zzz.kotnet.org>
5
* This program is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License as published by
7
* the Free Software Foundation; either version 2 of the License, or
8
* (at your option) any later version.
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with this program; if not, write to the Free Software
17
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21
/* a for loop for 3dp packets
22
this can later be adapted to a for loop for dpd packets. */
24
#include "pdp_opengl.h"
25
#include "pdp_internals.h"
28
typedef struct pdp_3d_for_struct
34
t_outlet *x_outlet_dpd;
35
t_outlet *x_outlet_float;
41
static void pdp_3d_for_input_0(t_pdp_3d_for *x, t_symbol *s, t_floatarg f)
45
/* trigger on "accumulate" */
47
if (s == gensym("accumulate")){
48
for (i=0; i<x->x_count; i++){
49
outlet_float(x->x_outlet_float, (float)i);
50
outlet_dpd(x->x_outlet_dpd, (int)f);
55
static void pdp_3d_for_count(t_pdp_3d_for *x, t_floatarg f)
58
if (count >= 0) x->x_count = count;
62
static void pdp_3d_for_free(t_pdp_3d_for *x)
66
t_class *pdp_3d_for_class;
70
void *pdp_3d_for_new(t_floatarg f)
74
t_pdp_3d_for *x = (t_pdp_3d_for *)pd_new(pdp_3d_for_class);
76
inlet_new(&x->x_obj, &x->x_obj.ob_pd, gensym("float"), gensym("count"));
78
x->x_outlet_dpd = outlet_new(&x->x_obj, &s_anything);
79
x->x_outlet_float = outlet_new(&x->x_obj, &s_float);
80
x->x_count = (count > 0) ? count : 1;
92
void pdp_3d_for_setup(void)
96
pdp_3d_for_class = class_new(gensym("3dp_for"), (t_newmethod)pdp_3d_for_new,
97
(t_method)pdp_3d_for_free, sizeof(t_pdp_3d_for), 0, A_DEFFLOAT, A_NULL);
99
class_addmethod(pdp_3d_for_class, (t_method)pdp_3d_for_input_0, gensym("dpd"), A_SYMBOL, A_DEFFLOAT, A_NULL);
100
class_addmethod(pdp_3d_for_class, (t_method)pdp_3d_for_count, gensym("count"), A_FLOAT, A_NULL);