2023-10-03 06:53:25 -04:00
|
|
|
const electron = require("electron");
|
|
|
|
|
|
|
|
let volumeMeterLeft;
|
|
|
|
let volumeMeterRight;
|
|
|
|
|
|
|
|
function sendControl(name, value = 0x00) {
|
|
|
|
electron.ipcRenderer.invoke("control", name, value);
|
|
|
|
}
|
|
|
|
|
|
|
|
electron.contextBridge.exposeInMainWorld("controller", {
|
|
|
|
"load": function (deckIndex) {
|
|
|
|
sendControl("deck" + String(deckIndex) + ".load");
|
|
|
|
},
|
|
|
|
"play_pause": function (deckIndex) {
|
|
|
|
sendControl("deck" + String(deckIndex) + ".play_pause");
|
|
|
|
},
|
2023-10-15 19:48:02 -04:00
|
|
|
"sync": function (deckIndex) {
|
|
|
|
sendControl("deck" + String(deckIndex) + ".sync");
|
|
|
|
},
|
2023-10-03 06:53:25 -04:00
|
|
|
"volume": function (deckIndex, value) {
|
|
|
|
sendControl("deck" + String(deckIndex) + ".volume", value);
|
|
|
|
},
|
2023-10-15 19:48:02 -04:00
|
|
|
"eq": function (deckIndex, freq, value) {
|
|
|
|
sendControl("deck" + String(deckIndex) + ".eq_" + freq, value);
|
|
|
|
},
|
2023-10-03 06:53:25 -04:00
|
|
|
"speed": function (deckIndex, value) {
|
|
|
|
sendControl("deck" + String(deckIndex) + ".speed", value);
|
|
|
|
},
|
2023-10-15 19:48:02 -04:00
|
|
|
"pad": function (deckIndex, padIndex) {
|
|
|
|
sendControl("deck" + String(deckIndex) + ".pad" + String(padIndex));
|
|
|
|
},
|
2023-10-03 06:53:25 -04:00
|
|
|
"crossfade": function (value) {
|
|
|
|
sendControl("master.crossfade", value);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
electron.ipcRenderer.on("signal", function (event, name, value = 0x00) {
|
|
|
|
switch (name) {
|
|
|
|
case "master.volume.left":
|
|
|
|
volumeMeterLeft.style.height = String(Math.round((value / 80) * 100)) + "%";
|
|
|
|
break;
|
|
|
|
case "master.volume.right":
|
|
|
|
volumeMeterRight.style.height = String(Math.round((value / 80) * 100)) + "%";
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
electron.ipcRenderer.invoke("load-driver", "linux-rawmidi");
|
|
|
|
electron.ipcRenderer.invoke("load-mappings", "numark-mixtrackplatinum");
|
|
|
|
|
|
|
|
(async function () {
|
|
|
|
var devices = await electron.ipcRenderer.invoke("list-devices");
|
|
|
|
|
|
|
|
if (devices.length > 0) {
|
|
|
|
electron.ipcRenderer.invoke("open-device", devices[0]);
|
|
|
|
}
|
|
|
|
})();
|
|
|
|
|
|
|
|
window.onload = function (event) {
|
|
|
|
volumeMeterLeft = document.querySelector("#volume-meter-left");
|
|
|
|
volumeMeterRight = document.querySelector("#volume-meter-right");
|
|
|
|
};
|