1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
/* Copyright (c) 1997-2001 Miller Puckette and others.
* For information on usage and redistribution, and for a DISCLAIMER OF ALL
* WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
/* MIDI. */
#include "m_pd.h"
static t_symbol *polytouchin_sym;
static t_class *polytouchin_class;
typedef struct _polytouchin
{
t_object x_obj;
t_float x_channel;
t_outlet *x_outlet1;
t_outlet *x_outlet2;
t_outlet *x_outlet3;
} t_polytouchin;
static void *polytouchin_new(t_floatarg f)
{
t_polytouchin *x = (t_polytouchin *)pd_new(polytouchin_class);
x->x_channel = f;
x->x_outlet1 = outlet_new(&x->x_obj, &s_float);
x->x_outlet2 = outlet_new(&x->x_obj, &s_float);
if (f == 0) x->x_outlet3 = outlet_new(&x->x_obj, &s_float);
pd_bind(&x->x_obj.ob_pd, polytouchin_sym);
return (x);
}
static void polytouchin_list(t_polytouchin *x, t_symbol *s, int argc,
t_atom *argv)
{
t_float pitch = atom_getfloatarg(0, argc, argv);
t_float value = atom_getfloatarg(1, argc, argv);
t_float channel = atom_getfloatarg(2, argc, argv);
if (x->x_channel != 0)
{
if (channel != x->x_channel) return;
outlet_float(x->x_outlet2, pitch);
outlet_float(x->x_outlet1, value);
}
else
{
outlet_float(x->x_outlet3, channel);
outlet_float(x->x_outlet2, pitch);
outlet_float(x->x_outlet1, value);
}
}
static void polytouchin_free(t_polytouchin *x)
{
pd_unbind(&x->x_obj.ob_pd, polytouchin_sym);
}
void polytouchin_setup(void)
{
polytouchin_class = class_new(gensym("polytouchin"),
(t_newmethod)polytouchin_new, (t_method)polytouchin_free,
sizeof(t_polytouchin), CLASS_NOINLET, A_DEFFLOAT, 0);
class_addlist(polytouchin_class, polytouchin_list);
class_sethelpsymbol(polytouchin_class, gensym("midi"));
polytouchin_sym = gensym("#polytouchin");
}
|