-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathMyAbletonLink.h
97 lines (77 loc) · 2.06 KB
/
MyAbletonLink.h
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
#ifndef MyAbletonLink_h
#define MyAbletonLink_h
#if defined(_MSC_VER)
# if _MSC_VER < 1800
# error This project needs atleast Visual Studio 2013
# endif
#elif __cplusplus<201103L
#error C++11 features are required to compile this source code.
#endif
#if defined(__APPLE__)
#define LINK_PLATFORM_MACOSX 1
#elif defined(_WIN32)
#define LINK_PLATFORM_WINDOWS 1
#elif defined(__linux__)
#define LINK_PLATFORM_LINUX 1
#else
#error This platform is not supported.
#endif
#ifdef _WIN32
#define LINKHUT_AUDIO_PLATFORM_ASIO 1
#endif
#include "ableton/Link.hpp"
#include <algorithm>
#include <atomic>
#include <chrono>
#include <iostream>
#include <thread>
//#ifdef __cplusplus
//extern "C" {
//#endif
// using numPeersCallback = void(UNITY_INTERFACE_API *)(int);
// using tempoCallback = void(UNITY_INTERFACE_API *)(double);
//#ifdef __cplusplus
//}
//#endif
class MyAbletonLink {
public:
struct Status
{
double beat;
double phase;
double tempo;
double quantam;
double time;
int numPeers;
Status() : beat(0.0), phase(0.0), tempo(0.0), quantam(0.0), time(0.0), numPeers(0) {}
};
MyAbletonLink();
~MyAbletonLink();
MyAbletonLink(const MyAbletonLink&) = delete;
MyAbletonLink& operator=(const ableton::Link&) = delete;
MyAbletonLink(MyAbletonLink&&) = delete;
MyAbletonLink& operator=(MyAbletonLink&&) = delete;
void setup(double bpm);
void setTempo(double bpm);
double tempo();
void setQuantum(double quantum);
double quantum();
void forceBeatAtTime(double beat);
void requestBeatAtTime(double beat);
void enable(bool bEnable);
bool isEnabled() const;
std::size_t numPeers();
Status update();
// void setNumPeersCallback(numPeersCallback cb);
// void setTempoCallback(tempoCallback cb);
private:
ableton::Link* link_;
double quantum_;
bool isNumPeersChanged_;
int numPeers_;
bool isTempoChanged_;
double tempo_;
// numPeersCallback npc;
// tempoCallback tc;
};
#endif /* MyAbletonLink_h */