-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathSamsonGraphiteMF8.qml
55 lines (46 loc) · 1.62 KB
/
SamsonGraphiteMF8.qml
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
import QtQuick 2.3
import radiance 1.0
QtObject {
property variant target;
property variant lpfTimer: Timer {
interval: 50; running: true; repeat: true
onTriggered: mc.scrollAccumulator *= 0.9;
}
property variant mc: MidiController {
id: controller
deviceName: "SAMSON Graphite MF8"
property real scrollAccumulator;
onConnectedChanged: {
console.log(deviceName + " " + (connected ? "connected" : "disconnected"));
}
onNoteOn: {
console.log("on ", channel, note, velocity);
}
onNoteOff: {
console.log("off", channel, note, velocity);
}
onControlChange: {
console.log("cc ", channel, control, value, 123);
if (control == 49) { // "A" jogwheel
var N = 4;
var v = value;
if (v > 64) {
v = 64 - v;
}
v /= Math.sqrt(Math.abs(v));
scrollAccumulator += v;
if (scrollAccumulator > N / 2) {
target.Controls.changeControlRel(0, Controls.Scroll, 1);
scrollAccumulator -= N;
} else if (scrollAccumulator <= -N / 2) {
target.Controls.changeControlRel(0, Controls.Scroll, -1);
scrollAccumulator += N;
}
} else if (control == 60) { // "B" jogwheel
var v = value;
if (v > 64) v = 64 - v;
target.Controls.changeControlRel(0, Controls.PrimaryParameter, v / 127);
}
}
}
}