|
1 |
| -const midi = require("midi"); |
| 1 | +const midi = require('midi') |
2 | 2 |
|
3 | 3 | class Client {
|
4 | 4 | constructor(mixerPortName) {
|
5 |
| - this.connect(mixerPortName); |
| 5 | + this.connect(mixerPortName) |
6 | 6 | }
|
7 | 7 |
|
8 | 8 | connect(mixerPortName) {
|
9 |
| - this.output = new midi.Output(); |
| 9 | + this.output = new midi.Output() |
10 | 10 |
|
11 |
| - const portNames = []; |
12 |
| - for ( |
13 |
| - let portNumber = 0; |
14 |
| - portNumber < this.output.getPortCount(); |
15 |
| - portNumber++ |
16 |
| - ) { |
17 |
| - portNames.push(this.output.getPortName(portNumber)); |
| 11 | + const portNames = [] |
| 12 | + for (let portNumber = 0; portNumber < this.output.getPortCount(); portNumber++) { |
| 13 | + portNames.push(this.output.getPortName(portNumber)) |
18 | 14 | }
|
19 | 15 |
|
20 |
| - const portIndex = portNames.findIndex( |
21 |
| - portName => portName === mixerPortName |
22 |
| - ); |
| 16 | + const portIndex = portNames.findIndex(portName => portName === mixerPortName) |
23 | 17 | if (portIndex < 0) {
|
24 |
| - const formattedPortNameList = portNames |
25 |
| - .map(portName => `"${portName}"`) |
26 |
| - .join(", "); |
| 18 | + const formattedPortNameList = portNames.map(portName => `"${portName}"`).join(', ') |
27 | 19 | throw new Error(
|
28 | 20 | [
|
29 |
| - "\n", |
| 21 | + '\n', |
30 | 22 | ` Connecting to mixer failed: Could not any find port named "${mixerPortName}".`,
|
31 |
| - ` Available ports are: ${formattedPortNameList}\n` |
32 |
| - ].join("\n") |
33 |
| - ); |
| 23 | + ` Available ports are: ${formattedPortNameList}\n`, |
| 24 | + ].join('\n') |
| 25 | + ) |
34 | 26 | }
|
35 |
| - this.output.openPort(portIndex); |
| 27 | + this.output.openPort(portIndex) |
36 | 28 | }
|
37 | 29 |
|
38 | 30 | disconnect() {
|
39 |
| - this.output.closePort(); |
| 31 | + this.output.closePort() |
40 | 32 | }
|
41 | 33 |
|
42 | 34 | // percent value between 0 and 127
|
43 | 35 | setFaderPosition({ channel, percent }) {
|
44 |
| - percent = Math.max(0, percent); |
45 |
| - percent = Math.min(127, percent); |
46 |
| - this.setNrpnParameter({ channel, value: percent }); |
| 36 | + percent = Math.max(0, percent) |
| 37 | + percent = Math.min(127, percent) |
| 38 | + this.setNrpnParameter({ channel, value: percent }) |
47 | 39 | }
|
48 | 40 |
|
49 | 41 | setPaflSelect({ channel, active }) {
|
50 |
| - const value = active ? 1 : 0; |
51 |
| - this.setNrpnParameter({ channel, value }); |
| 42 | + const value = active ? 1 : 0 |
| 43 | + this.setNrpnParameter({ channel, value }) |
52 | 44 | }
|
53 | 45 |
|
54 | 46 | setMute({ channel, active }) {
|
55 |
| - const value = active ? 0x7f : 0x3f; |
56 |
| - const { output } = this; |
57 |
| - output.sendMessage([0x90, channel, value]); |
58 |
| - output.sendMessage([0x80, channel, 0x00]); |
| 47 | + const value = active ? 0x7f : 0x3f |
| 48 | + const { output } = this |
| 49 | + output.sendMessage([0x90, channel, value]) |
| 50 | + output.sendMessage([0x80, channel, 0x00]) |
59 | 51 | }
|
60 | 52 |
|
61 | 53 | setNrpnParameter({ channel, value, valueIndex = 0x07 }) {
|
62 |
| - const { output } = this; |
63 |
| - output.sendMessage([0xb0, 0x63, channel]); |
64 |
| - output.sendMessage([0xb0, 0x62, 0x17]); |
65 |
| - output.sendMessage([0xb0, 0x06, value]); |
66 |
| - output.sendMessage([0xb0, 0x26, valueIndex]); |
| 54 | + const { output } = this |
| 55 | + output.sendMessage([0xb0, 0x63, channel]) |
| 56 | + output.sendMessage([0xb0, 0x62, 0x17]) |
| 57 | + output.sendMessage([0xb0, 0x06, value]) |
| 58 | + output.sendMessage([0xb0, 0x26, valueIndex]) |
67 | 59 | }
|
68 | 60 | }
|
69 | 61 |
|
@@ -128,7 +120,7 @@ Client.channels = {
|
128 | 120 | mix_9_10: 0x66,
|
129 | 121 | main_lr: 0x67,
|
130 | 122 | matrix_1_2: 0x6c,
|
131 |
| - matrix_3_4: 0x6d |
132 |
| -}; |
| 123 | + matrix_3_4: 0x6d, |
| 124 | +} |
133 | 125 |
|
134 |
| -module.exports = Client; |
| 126 | +module.exports = Client |
0 commit comments