forked from comoc/UnityAbletonLink
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPlugin.cpp
107 lines (92 loc) · 3.24 KB
/
Plugin.cpp
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
105
106
107
#include "Plugin.h"
#include "MyAbletonLink.h"
#ifdef __cplusplus
extern "C" {
#endif
UNITY_INTERFACE_EXPORT void* UNITY_INTERFACE_API CreateAbletonLink()
{
return new MyAbletonLink();
}
UNITY_INTERFACE_EXPORT void UNITY_INTERFACE_API DestroyAbletonLink(void* ptr)
{
MyAbletonLink* link = static_cast<MyAbletonLink*>(ptr);
delete link;
}
UNITY_INTERFACE_EXPORT void UNITY_INTERFACE_API setup(void* ptr, double bpm)
{
MyAbletonLink* link = static_cast<MyAbletonLink*>(ptr);
link->setup(bpm);
}
UNITY_INTERFACE_EXPORT void UNITY_INTERFACE_API setTempo(void* ptr, double bpm)
{
MyAbletonLink* link = static_cast<MyAbletonLink*>(ptr);
link->setTempo(bpm);
}
UNITY_INTERFACE_EXPORT double UNITY_INTERFACE_API tempo(void* ptr)
{
MyAbletonLink* link = static_cast<MyAbletonLink*>(ptr);
return link->tempo();
}
UNITY_INTERFACE_EXPORT void UNITY_INTERFACE_API setQuantum(void* ptr, double quantum)
{
MyAbletonLink* link = static_cast<MyAbletonLink*>(ptr);
link->setQuantum(quantum);
}
UNITY_INTERFACE_EXPORT double UNITY_INTERFACE_API quantum(void* ptr)
{
MyAbletonLink* link = static_cast<MyAbletonLink*>(ptr);
return link->quantum();
}
UNITY_INTERFACE_EXPORT void UNITY_INTERFACE_API forceBeatAtTime(void* ptr, double beat)
{
MyAbletonLink* link = static_cast<MyAbletonLink*>(ptr);
link->forceBeatAtTime(beat);
}
UNITY_INTERFACE_EXPORT void UNITY_INTERFACE_API requestBeatAtTime(void* ptr, double beat)
{
MyAbletonLink* link = static_cast<MyAbletonLink*>(ptr);
link->requestBeatAtTime(beat);
}
UNITY_INTERFACE_EXPORT void UNITY_INTERFACE_API enable(void* ptr, bool bEnable)
{
MyAbletonLink* link = static_cast<MyAbletonLink*>(ptr);
link->enable(bEnable);
}
UNITY_INTERFACE_EXPORT bool UNITY_INTERFACE_API isEnabled(void* ptr)
{
MyAbletonLink* link = static_cast<MyAbletonLink*>(ptr);
return link->isEnabled();
}
UNITY_INTERFACE_EXPORT int UNITY_INTERFACE_API numPeers(void* ptr)
{
MyAbletonLink* link = static_cast<MyAbletonLink*>(ptr);
return static_cast<int>(link->numPeers());
}
UNITY_INTERFACE_EXPORT void UNITY_INTERFACE_API update(void* ptr, double* rbeat, double* rphase, double* rtempo, double* rtime, int* rnumPeers)
{
// double tempo;
// double quantam;
// double time;
// int numPeers;
MyAbletonLink* link = static_cast<MyAbletonLink*>(ptr);
MyAbletonLink::Status s = link->update();
*rbeat = s.beat;
*rphase = s.phase;
*rtempo = s.tempo;
*rtime = s.time;
*rnumPeers = s.numPeers;
}
//UNITY_INTERFACE_EXPORT void UNITY_INTERFACE_API setNumPeersCallback(void* ptr, numPeersCallback func)
//{
// MyAbletonLink* link = static_cast<MyAbletonLink*>(ptr);
// link->setNumPeersCallback(func);
//}
//
//UNITY_INTERFACE_EXPORT void UNITY_INTERFACE_API setTempoCallback(void* ptr, tempoCallback func)
//{
// MyAbletonLink* link = static_cast<MyAbletonLink*>(ptr);
// link->setTempoCallback(func);
//}
#ifdef __cplusplus
}
#endif