Skip to content

Commit cda8135

Browse files
committed
added mute state variables
1 parent 1b65736 commit cda8135

File tree

1 file changed

+98
-1
lines changed

1 file changed

+98
-1
lines changed

src/variables.ts

Lines changed: 98 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ export function UpdateVariableDefinitions(self: WingInstance): void {
2121
variableId: `ch${ch}_gain`,
2222
name: `Channel ${ch} Gain`,
2323
})
24+
variables.push({
25+
variableId: `ch${ch}_mute`,
26+
name: `Channel ${ch} Mute`,
27+
})
2428
variables.push({
2529
variableId: `ch${ch}_level`,
2630
name: `Channel ${ch} Level`,
@@ -30,6 +34,10 @@ export function UpdateVariableDefinitions(self: WingInstance): void {
3034
name: `Channel ${ch} Pan`,
3135
})
3236
for (let bus = 1; bus <= model.busses; bus++) {
37+
variables.push({
38+
variableId: `ch${ch}_bus${bus}_mute`,
39+
name: `Channel ${ch} to Bus ${bus} Mute`,
40+
})
3341
variables.push({
3442
variableId: `ch${ch}_bus${bus}_level`,
3543
name: `Channel ${ch} to Bus ${bus} Level`,
@@ -40,6 +48,10 @@ export function UpdateVariableDefinitions(self: WingInstance): void {
4048
})
4149
}
4250
for (let mtx = 1; mtx <= model.matrices; mtx++) {
51+
variables.push({
52+
variableId: `ch${ch}_mtx${mtx}_mute`,
53+
name: `Channel ${ch} to Matrix ${mtx} Mute`,
54+
})
4355
variables.push({
4456
variableId: `ch${ch}_mtx${mtx}_level`,
4557
name: `Channel ${ch} to Matrix ${mtx} Level`,
@@ -56,6 +68,10 @@ export function UpdateVariableDefinitions(self: WingInstance): void {
5668
variableId: `aux${aux}_gain`,
5769
name: `Aux ${aux} Gain`,
5870
})
71+
variables.push({
72+
variableId: `aux${aux}_mute`,
73+
name: `Aux ${aux} Mute`,
74+
})
5975
variables.push({
6076
variableId: `aux${aux}_level`,
6177
name: `Aux ${aux} Level`,
@@ -65,6 +81,10 @@ export function UpdateVariableDefinitions(self: WingInstance): void {
6581
name: `Aux ${aux} Pan`,
6682
})
6783
for (let bus = 1; bus <= model.busses; bus++) {
84+
variables.push({
85+
variableId: `aux${aux}_bus${bus}_mute`,
86+
name: `Aux ${aux} to Bus ${bus} Mutes`,
87+
})
6888
variables.push({
6989
variableId: `aux${aux}_bus${bus}_level`,
7090
name: `Aux ${aux} to Bus ${bus} Level`,
@@ -74,13 +94,23 @@ export function UpdateVariableDefinitions(self: WingInstance): void {
7494
name: `Aux ${aux} to Bus ${bus} Pan`,
7595
})
7696
}
97+
for (let mtx = 1; mtx <= model.matrices; mtx++) {
98+
variables.push({
99+
variableId: `aux${aux}_mtx${mtx}_mute`,
100+
name: `Aux ${aux} to Matrix ${mtx} Mute`,
101+
})
102+
}
77103
}
78104

79105
for (let bus = 1; bus <= model.busses; bus++) {
80106
variables.push({
81107
variableId: `bus${bus}_name`,
82108
name: `Bus ${bus} Name`,
83109
})
110+
variables.push({
111+
variableId: `bus${bus}_mute`,
112+
name: `Bus ${bus} Mute`,
113+
})
84114
variables.push({
85115
variableId: `bus${bus}_level`,
86116
name: `Bus ${bus} Level`,
@@ -93,6 +123,10 @@ export function UpdateVariableDefinitions(self: WingInstance): void {
93123
if (bus == send) {
94124
continue
95125
}
126+
variables.push({
127+
variableId: `bus${bus}_bus${send}_mute`,
128+
name: `Bus ${bus} to Bus ${send} Mute`,
129+
})
96130
variables.push({
97131
variableId: `bus${bus}_bus${send}_level`,
98132
name: `Bus ${bus} to Bus ${send} Level`,
@@ -102,13 +136,23 @@ export function UpdateVariableDefinitions(self: WingInstance): void {
102136
name: `Bus ${bus} to Bus ${send} Pan`,
103137
})
104138
}
139+
for (let mtx = 1; mtx <= model.matrices; mtx++) {
140+
variables.push({
141+
variableId: `bus${bus}_mtx${mtx}_mute`,
142+
name: `Bus ${bus} to Matrix ${mtx} Mute`,
143+
})
144+
}
105145
}
106146

107147
for (let mtx = 1; mtx <= model.matrices; mtx++) {
108148
variables.push({
109149
variableId: `mtx${mtx}_name`,
110150
name: `Matrix ${mtx} Name`,
111151
})
152+
variables.push({
153+
variableId: `mtx${mtx}_mute`,
154+
name: `Matrix ${mtx} Mute`,
155+
})
112156
variables.push({
113157
variableId: `mtx${mtx}_level`,
114158
name: `Matrix ${mtx} Level`,
@@ -124,6 +168,10 @@ export function UpdateVariableDefinitions(self: WingInstance): void {
124168
variableId: `main${main}_name`,
125169
name: `Main ${main} Name`,
126170
})
171+
variables.push({
172+
variableId: `main${main}_mute`,
173+
name: `Main ${main} Mute`,
174+
})
127175
variables.push({
128176
variableId: `main${main}_level`,
129177
name: `Main ${main} Level`,
@@ -139,6 +187,10 @@ export function UpdateVariableDefinitions(self: WingInstance): void {
139187
variableId: `dca${dca}_name`,
140188
name: `DCA ${dca} Name`,
141189
})
190+
variables.push({
191+
variableId: `dca${dca}_mute`,
192+
name: `DCA ${dca} Mute`,
193+
})
142194
variables.push({
143195
variableId: `dca${dca}_level`,
144196
name: `DCA ${dca} Level`,
@@ -148,7 +200,11 @@ export function UpdateVariableDefinitions(self: WingInstance): void {
148200
for (let mgrp = 1; mgrp <= model.mutegroups; mgrp++) {
149201
variables.push({
150202
variableId: `mgrp${mgrp}_name`,
151-
name: `Mute ${mgrp} Name`,
203+
name: `Mutegroup ${mgrp} Name`,
204+
})
205+
variables.push({
206+
variableId: `mgrp${mgrp}_mute`,
207+
name: `Mutegroup ${mgrp} Mute`,
152208
})
153209
}
154210

@@ -217,6 +273,7 @@ export function UpdateVariables(self: WingInstance, msgs: OscMessage[]): void {
217273
// console.log('Updating variable:', path, args)
218274

219275
UpdateNameVariables(self, path, args[0]?.value as string)
276+
UpdateMuteVariables(self, path, args[0]?.value as number)
220277
UpdateFaderVariables(self, path, args[0]?.value as number)
221278
UpdatePanoramaVariables(self, path, args[0]?.value as number)
222279
UpdateUsbVariables(self, path, args[0])
@@ -238,6 +295,46 @@ function UpdateNameVariables(self: WingInstance, path: string, value: string): v
238295
self.setVariableValues({ [`${base}${num}_name`]: value })
239296
}
240297

298+
function UpdateMuteVariables(self: WingInstance, path: string, value: number): void {
299+
const match = path.match(
300+
/^\/(ch|aux|bus|mtx|main|dca|mgrp)\/(\d+)(?:\/(send|main)\/(?:(MX)(\d+)|(\d+))\/(mute|on)|\/(mute))$/,
301+
)
302+
303+
if (!match) return
304+
305+
const source = match[1]
306+
const srcnum = parseInt(match[2])
307+
const section = match[3] ?? null
308+
let dest: string | null = null
309+
let destnum: number | null = null
310+
if (match[4] === 'MX') {
311+
dest = 'MX'
312+
destnum = parseInt(match[5])
313+
} else if (match[6]) {
314+
dest = section
315+
destnum = parseInt(match[6])
316+
}
317+
const action = match[7] ?? match[8]
318+
319+
// Invert to get mute
320+
if (action === 'on') value = Number(!value)
321+
322+
if (dest == null) {
323+
const varName = `${source}${srcnum}_mute`
324+
self.setVariableValues({ [varName]: value })
325+
console.log(varName)
326+
} else {
327+
if (dest === 'send') {
328+
dest = 'bus'
329+
} else if (dest === 'MX') {
330+
dest = 'mtx'
331+
}
332+
const varName = `${source}${srcnum}_${dest}${destnum}_mute`
333+
self.setVariableValues({ [varName]: value })
334+
console.log(varName)
335+
}
336+
}
337+
241338
function UpdateFaderVariables(self: WingInstance, path: string, value: number): void {
242339
// const match = path.match(/^\/(\w+)\/(\w+)(?:\/(\w+)\/(\w+))?/);
243340
const match = path.match(/^\/(\w+)\/(\w+)(?:\/(\w+)\/(\w+))?\/(fdr|lvl|\$fdr|\$lvl)$/)

0 commit comments

Comments
 (0)