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
|
/* 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 *midiclkin_sym;
static t_class *midiclkin_class;
typedef struct _midiclkin
{
t_object x_obj;
t_outlet *x_outlet1;
t_outlet *x_outlet2;
} t_midiclkin;
static void *midiclkin_new(t_floatarg f)
{
t_midiclkin *x = (t_midiclkin *)pd_new(midiclkin_class);
x->x_outlet1 = outlet_new(&x->x_obj, &s_float);
x->x_outlet2 = outlet_new(&x->x_obj, &s_float);
pd_bind(&x->x_obj.ob_pd, midiclkin_sym);
return (x);
}
static void midiclkin_list(t_midiclkin *x, t_symbol *s, int argc, t_atom *argv)
{
t_float value = atom_getfloatarg(0, argc, argv);
t_float count = atom_getfloatarg(1, argc, argv);
outlet_float(x->x_outlet2, count);
outlet_float(x->x_outlet1, value);
}
static void midiclkin_free(t_midiclkin *x)
{
pd_unbind(&x->x_obj.ob_pd, midiclkin_sym);
}
void midiclkin_setup(void)
{
midiclkin_class = class_new(gensym("midiclkin"),
(t_newmethod)midiclkin_new, (t_method)midiclkin_free,
sizeof(t_midiclkin), CLASS_NOINLET, A_DEFFLOAT, 0);
class_addlist(midiclkin_class, midiclkin_list);
class_sethelpsymbol(midiclkin_class, gensym("midi"));
midiclkin_sym = gensym("#midiclkin");
}
|