Skip to content

Commit 1542e31

Browse files
committed
added presets on a per-channel basis
1 parent 1b65736 commit 1542e31

File tree

2 files changed

+52
-16
lines changed

2 files changed

+52
-16
lines changed

src/presets.ts

Lines changed: 50 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,45 @@ import { CommonActions } from './actions/common.js'
55
import { FeedbackId } from './feedbacks.js'
66

77
export function GetPresets(_instance: InstanceBaseExt<WingConfig>): CompanionPresetDefinitions {
8+
const model = _instance.model
9+
810
const presets: {
911
[id: string]: CompanionButtonPresetDefinition | undefined
1012
} = {}
1113

12-
presets['mute-button'] = {
14+
for (let i = 1; i <= model.channels; i++) {
15+
presets[`ch${i}-mute-button`] = getMutePreset('ch', i)
16+
presets[`ch${i}-solo-button`] = getSoloPreset('ch', i)
17+
}
18+
19+
for (let i = 1; i <= model.auxes; i++) {
20+
presets[`aux${i}-mute-button`] = getMutePreset('aux', i)
21+
presets[`aux${i}-solo-button`] = getSoloPreset('aux', i)
22+
}
23+
24+
for (let i = 1; i <= model.busses; i++) {
25+
presets[`bus${i}-mute-button`] = getMutePreset('bus', i)
26+
}
27+
28+
for (let i = 1; i <= model.matrices; i++) {
29+
presets[`mtx${i}-mute-button`] = getMutePreset('mtx', i)
30+
}
31+
32+
for (let i = 1; i <= model.mains; i++) {
33+
presets[`main${i}-mute-button`] = getMutePreset('main', i)
34+
}
35+
36+
return presets
37+
}
38+
39+
function getMutePreset(base: string, val: number): CompanionButtonPresetDefinition {
40+
const path = `/${base}/${val}`
41+
return {
1342
name: 'Mute Button',
14-
category: 'Channel',
43+
category: 'Mute',
1544
type: 'button',
1645
style: {
17-
text: 'Mute\\n$(wing:ch1_name)',
46+
text: `Mute\\n$(wing:${base}${val}_name)`,
1847
size: 'auto',
1948
color: combineRgb(255, 255, 255),
2049
bgcolor: combineRgb(0, 0, 0),
@@ -27,7 +56,7 @@ export function GetPresets(_instance: InstanceBaseExt<WingConfig>): CompanionPre
2756
down: [
2857
{
2958
actionId: CommonActions.SetMute,
30-
options: { sel: '/ch/1', mute: 2 },
59+
options: { sel: path, mute: 2 },
3160
},
3261
],
3362
up: [],
@@ -36,21 +65,24 @@ export function GetPresets(_instance: InstanceBaseExt<WingConfig>): CompanionPre
3665
feedbacks: [
3766
{
3867
feedbackId: FeedbackId.Mute,
39-
options: { sel: '/ch/1', mute: 1 },
68+
options: { sel: path, mute: 1 },
4069
style: {
4170
color: combineRgb(255, 255, 255),
4271
bgcolor: combineRgb(255, 0, 0),
4372
},
4473
},
4574
],
4675
}
76+
}
4777

48-
presets['solo-button'] = {
78+
function getSoloPreset(base: string, val: number): CompanionButtonPresetDefinition {
79+
const path = `/${base}/${val}`
80+
return {
4981
name: 'Solo Button',
50-
category: 'Channel',
82+
category: 'Solo',
5183
type: 'button',
5284
style: {
53-
text: 'Solo CH1',
85+
text: `Solo\\n$(wing:${base}${val}_name)`,
5486
size: 'auto',
5587
color: combineRgb(255, 255, 255),
5688
bgcolor: combineRgb(0, 0, 0),
@@ -61,10 +93,14 @@ export function GetPresets(_instance: InstanceBaseExt<WingConfig>): CompanionPre
6193
steps: [
6294
{
6395
down: [
96+
{
97+
actionId: CommonActions.StoreFader,
98+
options: { sel: path },
99+
},
64100
{
65101
actionId: CommonActions.DeltaFader,
66102
options: {
67-
sel: '/ch/1',
103+
sel: path,
68104
delta: 3,
69105
fadeDuration: 1000,
70106
fadeAlgorithm: 'quadratic',
@@ -73,31 +109,29 @@ export function GetPresets(_instance: InstanceBaseExt<WingConfig>): CompanionPre
73109
},
74110
{
75111
actionId: CommonActions.StorePanorama,
76-
options: { sel: '/ch/1' },
112+
options: { sel: path },
77113
},
78114
{
79115
actionId: CommonActions.SetPanorama,
80-
options: { sel: '/ch/1', pan: 0, fadeDuration: 1000, fadeAlgorithm: 'quadratic', fadeType: 'ease-in-out' },
116+
options: { sel: path, pan: 0, fadeDuration: 1000, fadeAlgorithm: 'quadratic', fadeType: 'ease-in-out' },
81117
},
82118
],
83119
up: [],
84120
},
85121
{
86122
down: [
87123
{
88-
actionId: CommonActions.UndoDeltaFader,
89-
options: { sel: '/ch/1', fadeDuration: 1000, fadeAlgorithm: 'quadratic', fadeType: 'ease-in-out' },
124+
actionId: CommonActions.RestoreFader,
125+
options: { sel: path, fadeDuration: 1000, fadeAlgorithm: 'quadratic', fadeType: 'ease-in-out' },
90126
},
91127
{
92128
actionId: CommonActions.RestorePanorama,
93-
options: { sel: '/ch/1', fadeDuration: 1000, fadeAlgorithm: 'quadratic', fadeType: 'ease-in-out' },
129+
options: { sel: path, fadeDuration: 1000, fadeAlgorithm: 'quadratic', fadeType: 'ease-in-out' },
94130
},
95131
],
96132
up: [],
97133
},
98134
],
99135
feedbacks: [],
100136
}
101-
102-
return presets
103137
}

src/types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@ import { InstanceBase } from '@companion-module/base'
22
import osc from 'osc'
33
import { WingTransitions } from './transitions.js'
44
import { WingState } from './state/state.js'
5+
import { ModelSpec } from './models/types.js'
56

67
export interface InstanceBaseExt<TConfig> extends InstanceBase<TConfig> {
78
config: TConfig
89
osc: osc.UDPPort
910
transitions: WingTransitions
1011
state: WingState
12+
model: ModelSpec
1113
sendCommand: (cmd: string, argument?: number | string, preferFloat?: boolean) => void
1214
ensureLoaded: (path: string, arg?: string | number) => void
1315
}

0 commit comments

Comments
 (0)