-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathTouchstrip.js
44 lines (36 loc) · 1.22 KB
/
Touchstrip.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
/**
*
*/
function Slider(midivalue, channel) {
this.midivalue = midivalue;
this.channel = channel === undefined ? 0 : channel;
this.messageCallback = undefined;
this.midistatus = MIDI.CC << 4 | this.channel;
this.lastValue = -1;
this.sendValue = function(value, queued) {
if(this.lastValue != value) {
if(queued) {
queueMidi(this.midistatus, this.midivalue, value);
} else {
host.getMidiOutPort(0).sendMidi(this.midistatus, this.midivalue, value);
}
this.lastValue = value;
}
};
this.reset = function() {
host.getMidiOutPort(0).sendMidi(this.midistatus, this.midivalue, 0);
};
this.resendLast = function() {
if(this.lastValue >= 0) {
queueMidi(this.midistatus, this.midivalue, this.lastValue);
}
};
this.doCallback = function(value) {
if(this.messageCallback !== undefined && typeof this.messageCallback === 'function') {
this.messageCallback(value, this.midivalue);
}
};
this.setCallback = function(callback) {
this.messageCallback = callback;
};
}