Skip to content

Commit

Permalink
Merge pull request #77 from istnv/feat/use_variables
Browse files Browse the repository at this point in the history
Allow variables for Snapshot and level Adjustment
  • Loading branch information
istnv authored Jul 3, 2023
2 parents 231e35b + 15859ec commit a16dc7f
Show file tree
Hide file tree
Showing 11 changed files with 477 additions and 763 deletions.
31 changes: 17 additions & 14 deletions actions.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import { Regex } from '@companion-module/base'
import { Regex, InstanceStatus } from '@companion-module/base'
import { pad0 } from './helpers.js'

export function buildStaticActions(self) {
const sendOSCCmd = async(cmd, arg) => (
await self.sendOSC(cmd, arg)
)
const sendOSCCmd = async (cmd, arg) => await self.sendOSC(cmd, arg)

let actions = {
label: {
Expand Down Expand Up @@ -158,15 +156,21 @@ export function buildStaticActions(self) {
type: 'textinput',
label: 'Snapshot Number 1-64',
id: 'snap',
default: 1,
min: 1,
max: 64,
regex: Regex.NUMBER,
default: '1',
useVariables: true,
},
],
callback: async (action, context) => {
const opt = action.options
await sendOSCCmd('/-snap/load', { type: 'i', value: parseInt(opt.snap) })
const snap = parseInt(await context.parseVariablesInString(action.options.snap))
if (snap < 1 || snap > 64) {
const err = [action.controlId, action.actionId, 'Invalid Snapshot #'].join(' → ')
self.updateStatus(InstanceStatus.BadConfig, err)
self.paramError = true
} else {
self.updateStatus(InstanceStatus.Ok)
self.paramError = false
await sendOSCCmd('/-snap/load', { type: 'i', value: snap })
}
},
},

Expand All @@ -183,7 +187,7 @@ export function buildStaticActions(self) {
name: 'Load Prior Console Snapshot',
options: [],
callback: async (action, context) => {
const snap = Math.max(--self.currentSnapshot,1)
const snap = Math.max(--self.currentSnapshot, 1)
await sendOSCCmd('/-snap/load', { type: 'i', value: snap })
},
},
Expand All @@ -192,8 +196,8 @@ export function buildStaticActions(self) {
name: 'Save Current Console Snapshot',
options: [],
callback: async (action, context) => {
const snap = Math.min(--self.currentSnapshot,1)
await sendOSCCmd('/-snap/save', { type: 'i', value: snap } )
const snap = Math.min(--self.currentSnapshot, 1)
await sendOSCCmd('/-snap/save', { type: 'i', value: snap })
},
},

Expand All @@ -211,7 +215,6 @@ export function buildStaticActions(self) {
const opt = action.options
await sendOSCCmd('/-stat/tape/state', { type: 'i', value: parseInt(opt.tFunc) })
},

},
}
Object.assign(self.actionDefs, actions)
Expand Down
26 changes: 26 additions & 0 deletions buildHADefs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { pad0 } from './helpers.js'

export function buildHADefs(self) {
let haActions = {}
let haVariables = {}

for (let s = 1; s <= 24; s++) {
let c = pad0(s)
let baseID = `/headamp/${c}/`
let baseFID = 'ha' + c
let theID = baseID + 'gain'
self.fbToStat[fID] = theID
self.xStat[theID] = {
name: 'ha' + c + '_gain',
valid: false,
fbID: fID,
polled: 0,
}
haVariables.push({
name: 'Head Amp ' + c ,
variableId: fID,
})
self.snapshot[s] = theID
}
self.variableDefs.push(...snapVars)
}
96 changes: 47 additions & 49 deletions buildSoloDefs.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { combineRgb, InstanceStatus } from '@companion-module/base'
import { pad0, unSlash, setToggle } from './helpers.js'
import { pad0, unSlash, setToggle, fadeTo } from './helpers.js'
import { ICON_SOLO } from './icons.js'
import { defSolo } from './defSolo.js'

Expand Down Expand Up @@ -80,12 +80,12 @@ export function buildSoloDefs(self) {
soloActions[soloID].callback = async (action, context) => {
const opt = action.options
let nVal = opt.num ? opt.num : 1
let cmd = '/-stat/solosw/' + pad0(self.soloOffset[action.actionId] + nVal)
let strip = '/-stat/solosw/' + pad0(self.soloOffset[action.actionId] + nVal)
let arg = {
type: 'i',
value: setToggle(self.xStat[cmd].isOn, opt.solo),
value: setToggle(self.xStat[strip].isOn, opt.solo),
}
await self.sendOSC(cmd, arg)
await self.sendOSC(strip, arg)
}
// solo feedback defs
const fbDescription = 'Solo ' + ch.description + ' status'
Expand Down Expand Up @@ -152,56 +152,54 @@ export function buildSoloDefs(self) {
soloFbToStat[actID] = c
if (ch.isFader) {
let fbDescription = 'Solo ' + ch.description
soloActions[actID] = {
name: fbDescription + ' Set',
options: [
{
type: 'dropdown',
label: 'Fader Level',
id: 'fad',
default: '0.0',
choices: self.FADER_VALUES,
},
],
callback: async (action, context) => {
const opt = action.options
let cmd = '/config/solo/level'
let fVal = fadeTo(action.actionId, cmd, opt, self)
if (fVal >= 0) {
let arg = {
type: 'f',
value: fVal,
}
await self.sendOSC(cmd, arg)
}
},
}
soloActions[actID + '_a'] = {
name: fbDescription + ' Adjust',
options: [
{
type: 'number',
tooltip: 'Move fader +/- percent.\nFader Percent:\n0 = -oo, 75 = 0db, 100 = +10db',
label: 'Adjust',
id: 'ticks',
min: -100,
max: 100,
default: 1,
},
],
callback: async (action, context) => {
for (let sfx in ['', '_a']) {
const aId = actID + sfx
soloActions[aId] = {
name: fbDescription + ('' == sfx ? ' Set' : ' Adjust'),
options: [],
}
switch (sfx) {
case '':
soloActions[aId].options.push({
type: 'dropdown',
label: 'Level',
id: 'fad',
default: '0.0',
choices: self.FADER_VALUES,
})
break
case '_a':
soloActions[aId].options.push({
type: 'number',
tooltip: 'Move fader +/- percent.\nFader Percent:\n0 = -oo, 75 = 0db, 100 = +10db',
label: 'Adjust',
id: 'ticks',
min: -100,
max: 100,
default: 1,
})
}
soloActions[aId].options.push({
type: 'checkbox',
tooltip: 'This prevents the fader level from going above 0db (75%)',
label: 'Limit fader to 0.0dB',
id: 'faderLim',
default: 0,
})
soloActions[aId].callback = async (action, context) => {
const opt = action.options
let cmd = '/config/solo/level'
let fVal = fadeTo(action.actionId, cmd, opt, self)
let strip = '/config/solo/level'
let fVal = fadeTo(action.actionId, strip, opt, self)
if (fVal >= 0) {
let arg = {
type: 'f',
value: fVal,
}
await self.sendOSC(cmd, arg)
await self.sendOSC(strip, arg)
}
},
}
}

stat[c].fader = 0
stat[c].fSteps = 161
soloVariables.push({
Expand All @@ -221,9 +219,9 @@ export function buildSoloDefs(self) {
name: 'Solo ' + ch.description,
options: [],
callback: async (action, context) => {
let cmd = `${c}`
let arg = { type: 'i', value: setToggle(self.xStat[cmd].isOn, action.options.set) }
await self.sendOSC(cmd, arg)
let strip = `${c}`
let arg = { type: 'i', value: setToggle(self.xStat[strip].isOn, action.options.set) }
await self.sendOSC(strip, arg)
},
}
soloActions[actID].options.push({
Expand Down
Loading

0 comments on commit a16dc7f

Please sign in to comment.