Skip to content

Commit

Permalink
Merge pull request #114 from istnv/bug/meters
Browse files Browse the repository at this point in the history
Finish implementation of meter bars
  • Loading branch information
istnv authored Nov 2, 2024
2 parents 2a92589 + f86becf commit 4abe6d8
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 21 deletions.
19 changes: 15 additions & 4 deletions buildMeterDefs.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,23 @@ export function buildMeterDefs(self) {
fbID += '_' + fb.options.num1
break
case 'rtn':
fbID += fb.options.num2
break
case 'fx':
fbID += fb.options.num2
fbID += 'send_' + fb.options.num2
break
case 'bus':
fbID += fb.options.num3
break
case 'aux':
fbID = 'rtn_aux'
break;
}

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

let stat = {}
Expand Down Expand Up @@ -90,13 +95,16 @@ export function buildMeterDefs(self) {
feedbackID =
muteFeedbackID =
variableID =
['bus1', 'bus2', 'bus3', 'bus4', 'bus5', 'bus6', 'fxsend1', 'fxsend2', 'fxsend3', 'fxsend4'][i - 26]
['bus1', 'bus2', 'bus3', 'bus4', 'bus5', 'bus6', 'fxsend_1', 'fxsend_2', 'fxsend_3', 'fxsend_4'][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]
if (channelID=='mon') {
muteFeedbackID = 'solo_mute'
}
channelID += i % 2 ? '_r' : '_l'
variableID = feedbackID += i % 2 ? '_r' : '_l'
n = ['Main out', 'Monitor out'][m]
Expand Down Expand Up @@ -138,14 +146,15 @@ export function buildMeterDefs(self) {
type: 'dropdown',
label: 'Type',
id: 'type',
default: 'ch',
default: 'lr',
choices: stripType,
},
{
// channel numbers
type: 'number',
label: 'Number',
id: 'num1',
default: 1,
min: 1,
max: 16,
isVisible: (options) => options.type == 'ch',
Expand All @@ -155,6 +164,7 @@ export function buildMeterDefs(self) {
type: 'number',
label: 'Number',
id: 'num2',
default: 1,
min: 1,
max: 4,
isVisible: (options) => ['rtn', 'fx'].includes(options.type),
Expand All @@ -164,6 +174,7 @@ export function buildMeterDefs(self) {
type: 'number',
label: 'Number',
id: 'num3',
default: 1,
min: 1,
max: 6,
isVisible: (options) => options.type == 'bus',
Expand Down
4 changes: 4 additions & 0 deletions buildStripDefs.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export function buildStripDefs(self) {
let procActions = {}
let trimActions = {}
let panActions = {}
let panFeedbacks = {}
// let fadeActions = {}
// let storeActions = {}
let levelActions = {}
Expand Down Expand Up @@ -511,6 +512,8 @@ export function buildStripDefs(self) {
}
}



for (const theStrip of defStrip) {
let stripID = theStrip.id
let chID = '/' + stripID
Expand Down Expand Up @@ -1083,6 +1086,7 @@ export function buildStripDefs(self) {
}
}
}

// apply channel strip configurations
Object.assign(self.xStat, stat)
Object.assign(self.fbToStat, fbToStat)
Expand Down
30 changes: 14 additions & 16 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ class BAirInstance extends InstanceBase {
async init(config) {
this.config = config

if (!this.config.model) {
this.config.model = 'X18'
}
if (!this.config.model) {
this.config.model = 'X18'
}

if (!this.config.channels) {
this.config.channels = parseInt(this.config.model.replace(/\D/g, ''))
Expand Down Expand Up @@ -169,7 +169,11 @@ class BAirInstance extends InstanceBase {
pulse() {
this.sendOSC('/xremote', [])
// subscribe for meter data
this.sendOSC('/meters', [{ type: 's', value: '/meters/1' }])
this.sendOSC('/-local/updrate', [{ type: 'i', value: 1 }])
this.sendOSC('/meters', [
{ type: 's', value: '/meters/1' },
{ type: 'i', value: 0 },
])
// any leftover status needed?
if (this.needStats) {
this.pollStats()
Expand Down Expand Up @@ -549,7 +553,7 @@ class BAirInstance extends InstanceBase {
if (this.oscPort) {
this.oscPort.close()
}
// no host or still default '0.0.0.0'
// no host or still default '0.0.0.0'
if (!this.config.host || this.config.host.split('.').reduce((acc, b) => acc + b, 0) == 0) {
this.updateStatus(InstanceStatus.ConnectionFailure, 'No host IP')
} else {
Expand Down Expand Up @@ -800,26 +804,20 @@ class BAirInstance extends InstanceBase {
let total = mv.total
const oldVal = mv.dbVal
mv.valid = true
mv.dbVal = newVal
if (mv.fbSubs.size > 0 && newVal != oldVal) {
this.checkFeedbacksById(...mv.fbSubs)
}
mv.count = ++mv.count % 10
total -= mv.samples[mv.count]
mv.samples[mv.count] = newVal
total += newVal
mv.total = total
let val = Math.round(total) / 10 // Math.round(total / 256.0 ) / 10
mv.dbVal = newVal
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}`)
// }
if (this.lastMeter && Date.now() - this.lastMeter > 50) {
variables[mv.vName] = Math.max(val, -60.0)
variables[mv.vName] = Math.max(Math.round(total) / 10, -60.0)
}
}
this.setVariableValues(variables)
this.checkFeedbacksById(feedbacks)
this.lastMeter = Date.now()
}

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "behringer-xair",
"version": "2.5.1",
"version": "2.5.2",
"type": "module",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit 4abe6d8

Please sign in to comment.