Skip to content

Commit

Permalink
Merge pull request #29 from istnv/wing-optimize
Browse files Browse the repository at this point in the history
Updates - Fix for #28 - Expand docs, version bump
Some optimizing from WING module
  • Loading branch information
McHauge authored Mar 7, 2021
2 parents d231ef8 + e890584 commit 109fd54
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 13 deletions.
26 changes: 17 additions & 9 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ function instance(system, id, config) {
self.fLevels[161] = [];
self.blinkingFB = {};
self.crossFades = {};
self.PollCount = 9;
self.PollTimeout = 400;
self.needStats = true;

self.setConstants();
Expand Down Expand Up @@ -690,7 +692,7 @@ instance.prototype.init_strips = function () {
}

// add new channel type to dropdown choices
if (fadeID in fadeActions) {
if (fadeActions[fadeID] !== undefined) {
fadeActions[fadeID].options[0].choices.push({
id: chID + '/',
label: stripDef[i].description + " " + stripDef[i].min + "-" + stripDef[i].max
Expand Down Expand Up @@ -929,7 +931,7 @@ instance.prototype.init_strips = function () {
// add channel type to send actions
if (stripDef[i].hasLevel) {
sendID = 'send';
if (sendID in sendActions) {
if (sendActions[sendID] !== undefined) {
sendActions[sendID].options[0].choices.push({
id: chID + '/',
label: sendLabel(stripDef[i].description, stripDef[i].min, stripDef[i].max)
Expand Down Expand Up @@ -1422,7 +1424,7 @@ instance.prototype.pollStats = function () {
var stillNeed = false;
var counter = 0;
var timeNow = Date.now();
var timeOut = timeNow - 100;
var timeOut = timeNow - self.PollTimeout;
var id;

for (id in self.xStat) {
Expand All @@ -1433,7 +1435,7 @@ instance.prototype.pollStats = function () {
self.debug("sending " + id);
self.xStat[id].polled = timeNow;
counter++;
if (counter > 5) {
if (counter > self.PollCount) {
break;
}
}
Expand All @@ -1442,6 +1444,9 @@ instance.prototype.pollStats = function () {

if (!stillNeed) {
self.status(self.STATUS_OK,"Mixer Status loaded");
var c = Object.keys(self.xStat).length;
var d = (timeNow - self.timeStart) / 1000;
self.log('info', 'Sync complete (' + c + '@' + (c / d).toFixed(1) + ')');
}
self.needStats = stillNeed;
};
Expand All @@ -1453,6 +1458,7 @@ instance.prototype.firstPoll = function () {
self.sendOSC('/xinfo',[]);
self.sendOSC('/-snap/name',[]);
self.sendOSC('/-snap/index',[]);
self.timeStart = Date.now();
self.pollStats();
self.pulse();
};
Expand Down Expand Up @@ -1503,7 +1509,7 @@ instance.prototype.init_osc = function() {
var leaf = node.split('/').pop();

// debug("received ", message, "from", info);
if (node in self.xStat) {
if (self.xStat[node] !== undefined) {
var v = args[0].value;
switch (leaf) {
case 'on':
Expand Down Expand Up @@ -1576,6 +1582,7 @@ instance.prototype.init_osc = function() {

self.oscPort.on('ready', function() {
self.status(self.STATUS_WARNING,"Loading status");
self.log('info', 'Sync started');
self.firstPoll();
self.heartbeat = setInterval( function () { self.pulse(); }, 9500);
self.blinker = setInterval( function() { self.blink(); }, 1000);
Expand Down Expand Up @@ -1983,12 +1990,13 @@ instance.prototype.action = function(action) {
// returns a 'new' float value
// or undefined for store or crossfade
function fadeTo(cmd, opt) {
var stat = self.xStat[cmd]
var node = cmd.split('/').pop();
var opTicks = parseInt(opt.ticks);
var steps = self.xStat[cmd].fSteps;
var steps = stat.fSteps;
var span = parseFloat(opt.duration);
var oldVal = self.xStat[cmd][node];
var oldIdx = self.xStat[cmd].idx;
var oldVal = stat[node];
var oldIdx = stat.idx;
var byVal = opTicks * steps / 100;
var newIdx = Math.min(steps-1,Math.max(0, oldIdx + Math.round(byVal)));
var slot = opt.store == 'me' ? cmd : opt.store;
Expand All @@ -2005,7 +2013,7 @@ instance.prototype.action = function(action) {
break;
case '_s': // store
if (slot) { // sanity check
self.tempStore[slot] = self.xStat[cmd][node];
self.tempStore[slot] = stat[node];
}
r = -1;
// the 'store' actions are internal to this module only
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
"legacy": [
"xair"
],
"version": "1.6.1",
"version": "1.6.2",
"api_version": "1.0.0",
"keywords": [
"Audio"
"Audio","Mixer","Console"
],
"manufacturer": "Behringer/Midas",
"product": "XR/MR",
"product": ["XR/MR", "XAir","XR12","XR16","X18","XR18"],
"shortname": "xair",
"description": "Module to control Midas MR and Behringer XR series mixers",
"main": "index.js",
Expand Down
2 changes: 1 addition & 1 deletion solodef.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"description": "Bus Master",
"actID": "bus",
"min": 1,
"max": 4,
"max": 6,
"offset": 39
},
{
Expand Down

0 comments on commit 109fd54

Please sign in to comment.