Skip to content

Commit

Permalink
Merge pull request #104 from istnv/bug/aux-feedback
Browse files Browse the repository at this point in the history
Fix aux-mute feedback
  • Loading branch information
istnv authored Sep 3, 2024
2 parents 743a7b3 + cca7848 commit cce8b1e
Show file tree
Hide file tree
Showing 8 changed files with 422 additions and 1,020 deletions.
4 changes: 2 additions & 2 deletions buildHADefs.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export function buildHADefs(self) {
name: 'Head Amp ' + c ,
variableId: fID,
})
self.snapshot[s] = theID

}
self.variableDefs.push(...snapVars)
self.variableDefs.push(...haVariables)
}
93 changes: 45 additions & 48 deletions buildMeterDefs.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,28 @@ import { pad0, unSlash } from './helpers.js'
import { graphics } from 'companion-module-utils'

export function buildMeterDefs(self) {
function getFbId(fb) {
const type = fb.options.type
let fbID = type
switch (type) {
case 'ch':
fbID += '_' + fb.options.num1
break
case 'rtn':
case 'fx':
fbID += fb.options.num2
break
case 'bus':
fbID += fb.options.num3
break
}

if (['aux', 'rtn', 'lr', 'mon'].includes(type)) {
fbID += `_${fb.options.pan}`
}
return fbID ? `m_${fbID}` : undefined
}

let stat = {}
let fbToMeter = {}
let feedbacks = {}
Expand Down Expand Up @@ -45,7 +67,7 @@ export function buildMeterDefs(self) {
let channelID = ''
let feedbackID = ''
let muteFeedbackID = ''
let meterFBID = ''
let meterFBID = ''
let variableID = ''
let n = ''

Expand All @@ -68,30 +90,10 @@ export function buildMeterDefs(self) {
feedbackID =
muteFeedbackID =
variableID =
[
'bus1',
'bus2',
'bus3',
'bus4',
'bus5',
'bus6',
'fxsend1',
'fxsend2',
'fxsend3',
'fxsend4',
][i - 26]
n = [
'Bus 1',
'Bus 2',
'Bus 3',
'Bus 4',
'Bus 5',
'Bus 6',
'FX Send 1',
'FX Send 2',
'FX Send 3',
'FX Send 4',
][i - 26]
['bus1', 'bus2', 'bus3', 'bus4', 'bus5', 'bus6', 'fxsend1', 'fxsend2', 'fxsend3', 'fxsend4'][i - 26]
n = ['Bus 1', 'Bus 2', 'Bus 3', 'Bus 4', 'Bus 5', 'Bus 6', 'FX Send 1', 'FX Send 2', 'FX Send 3', 'FX Send 4'][
i - 26
]
} else {
let m = parseInt((i - 36) / 2)
channelID = feedbackID = muteFeedbackID = ['lr', 'mon'][m]
Expand All @@ -104,15 +106,16 @@ export function buildMeterDefs(self) {
//feedbackID = feedbackID || `${channelID}`
// let muteFeedbackID = `m_${feedbackID}`
variableID = `m_${variableID}`
meterFBID = `m_${feedbackID}`
meterFBID = `m_${feedbackID}`

meter1[i] = meterFBID
stat[meterFBID] = {
vName: variableID,
valid: false,
fbID: feedbackID,
muteID: muteFeedbackID,
meterID: meterFBID,
meterID: meterFBID,
fbSubs: new Set(),
meter: i,
dbVal: 0,
total: 0,
Expand Down Expand Up @@ -185,37 +188,31 @@ export function buildMeterDefs(self) {
choices: self.BAR_LOCATION,
},
],
subscribe: async (feedback, context) => {
let fbID = getFbId(feedback)
if (fbID) {
self.mStat[fbID].fbSubs.add(feedback.id)
}
},
unsubscribe: async (feedback, context) => {
let fbID = getFbId(feedback)
if (fbID) {
self.mStat[fbID].fbSubs.delete(feedback.id)
}
},
callback: async (feedback) => {
let fbID = getFbId(feedback)
const loc = feedback.options.loc
const type = feedback.options.type

const top = loc == 'b' ? feedback.image.height - 6 : 3
const left = loc == 'r' ? feedback.image.width - 6 : 3
let dbVal = -1
let fbID = type
switch (type) {
case 'ch':
fbID += '_' + feedback.options.num1
break
case 'rtn':
case 'fx':
fbID += feedback.options.num2
break
case 'bus':
fbID += feedback.options.num3
break
}

if (['aux', 'rtn', 'lr', 'mon'].includes(type)) {
fbID += `_${feedback.options.pan}`
}

let muteID = ''
let newValue = 0

if (fbID) {
fbID = `m_${fbID}`
dbVal = self.mStat[fbID].valid ? self.mStat[fbID].dbVal : -128
newValue = (60 + Math.max(dbVal, -60)) *100 / 60
newValue = ((60 + Math.max(dbVal, -60)) * 100) / 60
// newValue = newValue * 100
// newValue = newValue / 60
// newValue = 100 + newValue
Expand Down
5 changes: 3 additions & 2 deletions buildStripDefs.js
Original file line number Diff line number Diff line change
Expand Up @@ -705,7 +705,8 @@ export function buildStripDefs(self) {

// mute feedback defs
let fbDescription = theStrip.description + ' ' + (theStrip.hasOn ? 'Mute' : '') + ' status'
muteFeedbacks[stripID] = {
feedbackID = unSlash(stripID)
muteFeedbacks[feedbackID] = {
type: 'boolean',
name: 'Indicate ' + fbDescription,
description: 'Indicate ' + fbDescription + ' on button',
Expand Down Expand Up @@ -754,7 +755,7 @@ export function buildStripDefs(self) {
},
}
if (d > 0) {
muteFeedbacks[stripID].options.push({
muteFeedbacks[feedbackID].options.push({
type: 'number',
label: theStrip.description + ' number',
id: 'theChannel',
Expand Down
86 changes: 85 additions & 1 deletion constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export function buildConstants(self) {
for (let i = 0; i < 1024; i++) {
self.fLevels[1024][i] = Math.min(
1.0,
Math.floor((Math.round(self.stepsToFader(i, 1024) * 1023.5) / 1023) * 10000) / 10000,
Math.floor((Math.round(self.stepsToFader(i, 1024) * 1023.5) / 1023) * 10000) / 10000
)
}

Expand Down Expand Up @@ -105,4 +105,88 @@ export function buildConstants(self) {
{ id: 'l', label: 'Left' },
{ id: 'r', label: 'Right' },
]

self.MIXER_MODEL = {
XR12: { desc: 'XAir 12 Rack', channels: 12 },
XR16: { desc: 'XAir 16 Rack', channels: 16 },
XR18: { desc: 'XAir 18 Rack', channels: 18 },
X18: { desc: 'XAir 18 Desk', channels: 18 },
}

self.HA_CONFIG = [
{
12: { name: '', has: false },
16: { name: '', has: false },
18: { name: '', has: false },
},
]

for (let c = 1; c < 25; c++) {
switch (c) {
case 1:
case 2:
case 3:
case 4:
self.HA_CONFIG[c] = {
12: { name: `XLR ${c}`, has: true },
16: { name: `XLR ${c}`, has: true },
18: { name: `XLR ${c}`, has: true },
trim: 145,
ph: true,
}
break
case 5:
case 6:
case 7:
case 8:
self.HA_CONFIG[c] = {
12: { name: '', has: false },
16: { name: `XLR ${c}`, has: true },
18: { name: `XLR ${c}`, has: true },
trim: 145,
ph: true,
}
break
case 9:
case 10:
case 11:
case 12:
case 13:
case 14:
case 15:
case 16:
self.HA_CONFIG[c] = {
12: { name: '', has: false },
16: { name: '', has: false },
18: { name: `XLR ${c}`, has: true },
trim: 145,
ph: true,
}
break
case 17:
self.HA_CONFIG[c] = {
12: { name: `1/4 ${c - 16}`, has: true },
16: { name: `1/4 ${c - 16}`, has: true },
18: { name: 'RCA', has: true },
trim: 65,
ph: false,
}
break
case 18:
case 19:
case 20:
case 21:
case 22:
case 23:
case 24:
self.HA_CONFIG[c] = {
12: { name: `1/4 ${c - 16}`, has: true },
16: { name: `1/4 ${c - 16}`, has: true },
18: { name: '', has: false },
trim: 65,
ph: false,
}
break
}
}
}
9 changes: 4 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -728,7 +728,6 @@ class BAirInstance extends InstanceBase {
// if (this.lastMeter && Date.now() - this.lastMeter < 50) {
// return
// }

let data = new DataView(buf.slice(4).buffer)

let variables = {}
Expand All @@ -748,19 +747,19 @@ class BAirInstance extends InstanceBase {
mv.total = total
let val = Math.round(total) / 10 // Math.round(total / 256.0 ) / 10
mv.dbVal = newVal
if (newVal != oldVal) {
feedbacks.push(mv.meterID)
if (mv.fbSubs.size > 0 && newVal != oldVal) {
feedbacks.push(...mv.fbSubs)
}
// newVal = Math.round((val / 256.0) * 10) / 10
// if (['v_ch15','v_ch16'].includes(mv.vName)) {
// console.log(`${mv.vName} = ${val}`)
// console.log(`${mv.vName} = ${val}`)
// }
if (this.lastMeter && Date.now() - this.lastMeter > 50) {
variables[mv.vName] = Math.max(val, -60.0)
}
}
this.setVariableValues(variables)
this.checkFeedbacks(feedbacks)
this.checkFeedbacksById(feedbacks)
this.lastMeter = Date.now()
}

Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "behringer-xair",
"version": "2.3.3",
"version": "2.3.4",
"type": "module",
"main": "index.js",
"scripts": {
Expand All @@ -12,11 +12,11 @@
"url": "git+https://github.com/bitfocus/companion-module-behringer-xair.git"
},
"dependencies": {
"@companion-module/base": "^1.8.0",
"@companion-module/base": "^1.10.0",
"companion-module-utils": "^0.5.0",
"osc": "^2.4.3"
},
"devDependencies": {
"@companion-module/tools": "^1.5.0"
"@companion-module/tools": "^2.0.0"
}
}
60 changes: 43 additions & 17 deletions upgrades.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,22 +32,22 @@ export const UpgradeScripts = [
},

CreateConvertToBooleanFeedbackUpgradeScript({
'solo_mute': true,
'solo_mono': true,
'solo_dim': true,
'rtn': true,
'lr': true,
'fxsend': true,
'dca': true,
'bus': true,
'ch': true,
'solosw_aux': true,
'solosw_bus': true,
'solosw_ch': true,
'solosw_dca': true,
'solosw_fxr': true,
'solosw_fxs': true,
'solosw_lr': true,
solo_mute: true,
solo_mono: true,
solo_dim: true,
rtn: true,
lr: true,
fxsend: true,
dca: true,
bus: true,
ch: true,
solosw_aux: true,
solosw_bus: true,
solosw_ch: true,
solosw_dca: true,
solosw_fxr: true,
solosw_fxs: true,
solosw_lr: true,
'rtn/aux': true,
'config/mute': true,
}),
Expand Down Expand Up @@ -101,6 +101,32 @@ export const UpgradeScripts = [
return result
},
CreateConvertToBooleanFeedbackUpgradeScript({
'snap_color': true,
snap_color: true,
}),

function (context, props) {
const result = {
updatedConfig: null,
updatedActions: [],
updatedFeedbacks: [],
}

for (let fb of props.feedbacks) {
let changed = false
if (fb.feedbackId == 'rtn/aux') {
fb.feedbackId = 'rtn_aux'
changed = true
}
if (fb.feedbackId == 'rtn_aux') {
if (fb.options.state == undefined) {
fb.options.state = '1'
changed = true
}
}
if (changed) {
result.updatedFeedbacks.push(fb)
}
}
return result
},
]
Loading

0 comments on commit cce8b1e

Please sign in to comment.