aboutsummaryrefslogtreecommitdiff
path: root/control/osctl
blob: a6ab2462b43a9306d7ef0395d312d9b19c7f1c8b (plain)
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
#include <m_pd.h>
#include <math.h>
#include <string.h>
#ifdef NT
#pragma warning( disable : 4244 )
#pragma warning( disable : 4305 )
#endif

/* ------------------------ osctl ----------------------------- */
#ifndef M_PI
#define M_PI 3.141593f
#endif

void InitOSCReceive() {
    struct OSCReceiveMemoryTuner rt;
    Boolean result;

    rt.InitTimeMemoryAllocator = MyInitTimeMalloc;
    rt.RealTimeMemoryAllocator = MyRealTimeMalloc;
    rt.receiveBufferSize = 1000;
    rt.numReceiveBuffers = 100;
    rt.numQueuedObjects = 200;
    rt.numCallbackListNodes = 100;

    result = OSCInitReceive(&rt);

    if (result == FALSE) {
	fatal_error("OSCInitReceive returned FALSE!\n");
    }
}



static t_class *osctl_class;


typedef struct _osctl
{
     t_object x_obj;
} t_osctl;


void osctl_bang(t_osctl *x)
{
     outlet_float(x->x_obj.ob_outlet, x->x_osctl);
}

static void *osctl_new(t_symbol* s)
{
    t_osctl *x = (t_osctl *)pd_new(osctl_class);
    
    InitOSCReceive();


    outlet_new(&x->x_obj, &s_float);
    return (x);
}

void osctl_setup(void)
{
    osctl_class = class_new(gensym("osctl"), (t_newmethod)osctl_new, 0,
				sizeof(t_osctl), 0,0);
    class_addbang(osctl_class,osctl_bang);
}