-
-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathindex.js
52 lines (46 loc) · 1.46 KB
/
index.js
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
// const nbind = require('nbind');
// const binding = nbind.init(__dirname);
// const lib = binding.lib;
const lib = require("bindings")("abletonlink");
lib.AbletonLink.prototype.startUpdate = function(interval_ms, callback) {
this.update();
if(callback) {
this.timer = setInterval(() => {
this.update();
callback(this.beat, this.phase, this.bpm, this.isPlayingWhenUpdate);
}, interval_ms);
callback(this.beat, this.phase, this.bpm, this.isPlayingWhenUpdate);
} else {
this.timer = setInterval(() => {
this.update();
}, interval_ms);
}
};
lib.AbletonLink.prototype.stopUpdate = function() {
if(this.timer) {
clearInterval(this.timer);
this.timer = null;
}
}
lib.AbletonLinkAudio.prototype.startUpdate = function(interval_ms, callback) {
this.update();
if(callback) {
this.timer = setInterval(() => {
this.update();
callback(this.beat, this.phase, this.bpm, this.isPlayingWhenUpdate);
}, interval_ms);
callback(this.beat, this.phase, this.bpm, this.isPlayingWhenUpdate);
} else {
this.timer = setInterval(() => {
this.update();
}, interval_ms);
}
};
lib.AbletonLinkAudio.prototype.stopUpdate = function() {
if(this.timer) {
clearInterval(this.timer);
this.timer = null;
}
}
lib.AbletonLink.Audio = lib.AbletonLinkAudio;
module.exports = lib.AbletonLink;