mirror of
https://github.com/stagehacks/Cue-View.git
synced 2026-08-15 18:53:38 +00:00
lint all the things
This commit is contained in:
+52
-49
@@ -6,24 +6,25 @@ exports.searchOptions = {
|
||||
searchBuffer: Buffer.from([0x2f, 0x78, 0x69, 0x6e, 0x66, 0x6f]),
|
||||
devicePort: 10023,
|
||||
listenPort: 0,
|
||||
validateResponse: function (msg, info) {
|
||||
return msg.toString().indexOf('/xinfo') == 0;
|
||||
validateResponse (msg, info) {
|
||||
return msg.toString().indexOf('/xinfo') === 0;
|
||||
},
|
||||
};
|
||||
exports.defaultPort = 10023;
|
||||
|
||||
exports.ready = function (device) {
|
||||
device.data.channelFaders = new Array(32).fill(0);
|
||||
device.data.channelFadersDB = new Array(32).fill(0);
|
||||
device.data.channelMutes = new Array(32).fill(0);
|
||||
device.data.channelNames = new Array(32).fill('end');
|
||||
device.data.channelColors = new Array(32);
|
||||
exports.ready = function ready(device) {
|
||||
const d = device;
|
||||
d.data.channelFaders = new Array(32).fill(0);
|
||||
d.data.channelFadersDB = new Array(32).fill(0);
|
||||
d.data.channelMutes = new Array(32).fill(0);
|
||||
d.data.channelNames = new Array(32).fill('end');
|
||||
d.data.channelColors = new Array(32);
|
||||
|
||||
device.data.stereoFader = 0;
|
||||
device.data.stereoFaderDB = 0;
|
||||
device.data.stereoMute = 0;
|
||||
d.data.stereoFader = 0;
|
||||
d.data.stereoFaderDB = 0;
|
||||
d.data.stereoMute = 0;
|
||||
|
||||
device.send(Buffer.from('/xinfo'));
|
||||
d.send(Buffer.from('/xinfo'));
|
||||
|
||||
// device.send(Buffer.from("\x2f\x62\x61\x74\x63\x68\x73\x75\x62\x73\x63\x72\x69\x62\x65\x00\x2c\x73\x73\x69\x69\x69\x00\x00\x6d\x65\x74\x65\x72\x73\x2f\x30\x00\x00\x00\x00\x2f\x6d\x65\x74\x65\x72\x73\x2f\x30\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01"));
|
||||
// device.send(Buffer.from("/batchsubscribe\x00,ssiii\x00\x00meters/0\x00\x00\x00\x00/meters/0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01"));
|
||||
@@ -40,31 +41,33 @@ function parseAddress(msg) {
|
||||
function convertToDBTheBehringerWay(f) {
|
||||
if (f >= 0.5) {
|
||||
return f * 40 - 30;
|
||||
} else if (f >= 0.25) {
|
||||
return f * 80 - 50;
|
||||
} else if (f >= 0.0625) {
|
||||
return f * 160 - 70;
|
||||
} else {
|
||||
return f * 480 - 90;
|
||||
}
|
||||
if (f >= 0.25) {
|
||||
return f * 80 - 50;
|
||||
}
|
||||
if (f >= 0.0625) {
|
||||
return f * 160 - 70;
|
||||
}
|
||||
return f * 480 - 90;
|
||||
}
|
||||
|
||||
exports.data = function (device, buf) {
|
||||
exports.data = function data(device, buf) {
|
||||
this.deviceInfoUpdate(device, 'status', 'ok');
|
||||
const msg = buf.toString().split('\u0000\u0000');
|
||||
const d = device;
|
||||
|
||||
if (msg[0] == '/xinfo') {
|
||||
if (msg[0] === '/xinfo') {
|
||||
this.deviceInfoUpdate(device, 'defaultName', msg[4]);
|
||||
device.data.name = msg[4];
|
||||
device.data.ip = msg[2];
|
||||
device.data.firmware = msg[7];
|
||||
device.data.model = msg[5];
|
||||
d.data.name = msg[4];
|
||||
d.data.ip = msg[2];
|
||||
d.data.firmware = msg[7];
|
||||
d.data.model = msg[5];
|
||||
|
||||
device.send(Buffer.from('/lr/mix/fader\u0000\u0000\u0000\u0000'));
|
||||
device.send(Buffer.from('/lr/mix/on\u0000\u0000\u0000\u0000'));
|
||||
d.send(Buffer.from('/lr/mix/fader\u0000\u0000\u0000\u0000'));
|
||||
d.send(Buffer.from('/lr/mix/on\u0000\u0000\u0000\u0000'));
|
||||
|
||||
for (let i = 0; i <= 32; i++) {
|
||||
device.send(
|
||||
d.send(
|
||||
Buffer.from(
|
||||
`/ch/${i
|
||||
.toString()
|
||||
@@ -72,59 +75,59 @@ exports.data = function (device, buf) {
|
||||
)
|
||||
);
|
||||
}
|
||||
device.draw();
|
||||
} else if (msg[0] == '/meters/0') {
|
||||
d.draw();
|
||||
} else if (msg[0] === '/meters/0') {
|
||||
// console.log(msg)
|
||||
} else if (msg[0].indexOf('/mix/fader') >= 0) {
|
||||
const addr = parseAddress(msg[0]);
|
||||
const channel = Number(addr[1]);
|
||||
|
||||
if (addr[0] == 'ch') {
|
||||
device.data.channelFaders[channel - 1] = buf.readFloatBE(24);
|
||||
device.data.channelFadersDB[channel - 1] = convertToDBTheBehringerWay(
|
||||
if (addr[0] === 'ch') {
|
||||
d.data.channelFaders[channel - 1] = buf.readFloatBE(24);
|
||||
d.data.channelFadersDB[channel - 1] = convertToDBTheBehringerWay(
|
||||
buf.readFloatBE(24)
|
||||
);
|
||||
} else if (addr[0] == 'lr') {
|
||||
device.data.stereoFader = buf.readFloatBE(20);
|
||||
device.data.stereoFaderDB = convertToDBTheBehringerWay(
|
||||
} else if (addr[0] === 'lr') {
|
||||
d.data.stereoFader = buf.readFloatBE(20);
|
||||
d.data.stereoFaderDB = convertToDBTheBehringerWay(
|
||||
buf.readFloatBE(20)
|
||||
);
|
||||
}
|
||||
|
||||
device.draw();
|
||||
d.draw();
|
||||
} else if (msg[0].indexOf('/mix/on') >= 0) {
|
||||
const addr = parseAddress(msg[0]);
|
||||
const channel = Number(addr[1]);
|
||||
|
||||
if (addr[0] == 'ch') {
|
||||
device.data.channelMutes[channel - 1] = buf[23];
|
||||
} else if (addr[0] == 'lr') {
|
||||
device.data.stereoMute = buf[19];
|
||||
if (addr[0] === 'ch') {
|
||||
d.data.channelMutes[channel - 1] = buf[23];
|
||||
} else if (addr[0] === 'lr') {
|
||||
d.data.stereoMute = buf[19];
|
||||
}
|
||||
device.draw();
|
||||
device.send(
|
||||
d.draw();
|
||||
d.send(
|
||||
Buffer.from(`/ch/${addr[1]}/mix/fader\u0000\u0000\u0000\u0000`)
|
||||
);
|
||||
} else if (msg[0].indexOf('/config/name') > 0) {
|
||||
const addr = parseAddress(msg[0]);
|
||||
const channel = Number(addr[1]);
|
||||
device.data.channelNames[channel - 1] = msg[2];
|
||||
device.draw();
|
||||
device.send(
|
||||
d.data.channelNames[channel - 1] = msg[2];
|
||||
d.draw();
|
||||
d.send(
|
||||
Buffer.from(`/ch/${addr[1]}/config/color\u0000\u0000\u0000\u0000`)
|
||||
);
|
||||
} else if (msg[0].indexOf('/config/color') > 0) {
|
||||
const addr = parseAddress(msg[0]);
|
||||
const channel = Number(addr[1]);
|
||||
device.data.channelColors[channel - 1] = buf.readInt8(27);
|
||||
device.draw();
|
||||
device.send(Buffer.from(`/ch/${addr[1]}/mix/on\u0000\u0000\u0000\u0000`));
|
||||
d.data.channelColors[channel - 1] = buf.readInt8(27);
|
||||
d.draw();
|
||||
d.send(Buffer.from(`/ch/${addr[1]}/mix/on\u0000\u0000\u0000\u0000`));
|
||||
} else {
|
||||
// console.log(msg)
|
||||
}
|
||||
// console.log(msg)
|
||||
};
|
||||
|
||||
exports.heartbeat = function (device) {
|
||||
exports.heartbeat = function heartbeat(device) {
|
||||
device.send(Buffer.from('/xremote'));
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user