forked from polarity/HAKEN-MPE
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhaken.control.js
51 lines (40 loc) · 1.39 KB
/
haken.control.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
loadAPI(1)
host.defineController('Haken', 'Haken Board', '1.0', '8a064e50-b330-11e6-9598-0800200c9a66')
host.defineMidiPorts(1, 1)
function init() {
host.getMidiInPort(0).setMidiCallback(onMidi)
noteInput = host.getMidiInPort(0).createNoteInput('',
'8?????',
'9?????',
'B?40??',
'B?4A??',
'C?????',
'D?????',
'E?????')
noteInput.setUseExpressiveMidi(true, 0, 48)
var bendRanges = ['12', '24', '36', '48', '60', '72', '84', '96']
bendRange = host.getPreferences().getEnumSetting('Bend Range', 'MIDI', bendRanges, '48')
bendRange.addValueObserver(function (range) {
var pb = parseInt(range)
noteInput.setUseExpressiveMidi(true, 0, pb)
sendPitchBendRangeRPN(1, pb)
})
// Set POLY ON mode with 8 MPE voices
sendChannelController(0, 127, 8)
// Set up pitch bend sensitivity to 48 semitones
sendPitchBendRangeRPN(1, 48)
sendPitchBendRangeRPN(2, 48)
device = host.createEditorCursorDevice()
}
function sendPitchBendRangeRPN(channel, range) {
sendChannelController(channel, 100, 0); // Registered Parameter Number (RPN) - LSB*
sendChannelController(channel, 101, 0); // Registered Parameter Number (RPN) - MSB*
sendChannelController(channel, 36, 0)
sendChannelController(channel, 6, range)
}
function onMidi(status, data1, data2) {
// printMidi(status, data1, data2)
noteInput.sendRawMidiEvent(status, data1, data2)
}
function exit() {
}