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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
|
using System;
namespace PureData
{
public class External
{
private IntPtr x;
public External()
{
x = IntPtr.Zero;
}
// this function MUST exist
public void SetUp(IntPtr pdClass)
{
// you must assign pdclass to x !
x = pdClass;
// now you can do what you like...
Console.WriteLine("pointer set!");
Console.WriteLine("setting selectors..");
pd.AddSelector(x, "sel1", "Sel1", ParametersType.None);
pd.AddSelector(x, "sel2", "Sel2", ParametersType.None);
pd.AddSelector(x, "selFloat", "SelFloat", ParametersType.Float);
pd.AddSelector(x, "selString", "SelString", ParametersType.Symbol);
pd.AddSelector(x, "selList", "SelList", ParametersType.List);
pd.AddSelector(x, "selStringList", "SelStringList", ParametersType.List);
pd.AddSelector(x, "selFloatList", "SelFloatList", ParametersType.List);
Console.WriteLine("selectors set");
pd.AddOutlet(x, ParametersType.Float);
pd.AddInlet(x, "selFloat", ParametersType.Float);
}
public void Sel1()
{
pd.PostMessage("Sel1 invoked!");
}
public void Sel2()
{
pd.PostMessage("Sel2 invoked!");
}
public void SelFloat(float f)
{
pd.PostMessage("SelFloat received " + f);
}
public void SelString(ref string s)
{
pd.PostMessage("SelString received " + s);
}
public void SelList(int [] list)
{
pd.PostMessage("SelList received " + list.Length + " elements");
for (int i = 0; i<list.Length; i++)
{
pd.PostMessage("int " + i + " = " + list[i]);
}
}
public void SelStringList(string [] list)
{
pd.PostMessage("SetStringList received a " + list.Length + " long list");
for (int i = 0; i<list.Length; i++)
{
pd.PostMessage("string " + i + " = " + list[i]);
}
}
public void SelFloatList(int [] list)
{
pd.PostMessage("SetStringList received a " + list.Length + " long list");
for (int i = 0; i<list.Length; i++)
{
pd.PostMessage("float " + i + " = " + list[0]);
}
}
public int test(int a)
{
Console.WriteLine("test("+a+")");
return a+1;
}
}
}
|