-
-
Notifications
You must be signed in to change notification settings - Fork 32
/
choices.ts
316 lines (293 loc) · 9.2 KB
/
choices.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
import { AtemState, Enums } from 'atem-connection'
import { DropdownChoice } from '../../../instance_skel_types'
import { ModelSpec } from './models'
import { iterateTimes, literal, assertUnreachable } from './util'
export const CHOICES_SSRCBOXES: DropdownChoice[] = [
{ id: 0, label: 'Box 1' },
{ id: 1, label: 'Box 2' },
{ id: 2, label: 'Box 3' },
{ id: 3, label: 'Box 4' }
]
export const CHOICES_ON_OFF_TOGGLE: DropdownChoice[] = [
{ id: 'true', label: 'On' },
{ id: 'false', label: 'Off' },
{ id: 'toggle', label: 'Toggle' }
]
export const CHOICES_KEYTRANS: DropdownChoice[] = [
{ id: 'true', label: 'On Air' },
{ id: 'false', label: 'Off' },
{ id: 'toggle', label: 'Toggle' }
]
export const CHOICES_CLASSIC_AUDIO_MIX_OPTION: DropdownChoice[] = [
{
id: Enums.AudioMixOption.On,
label: 'On'
},
{
id: Enums.AudioMixOption.Off,
label: 'Off'
},
{
id: Enums.AudioMixOption.AudioFollowVideo,
label: 'AFV'
}
]
export const CHOICES_FAIRLIGHT_AUDIO_MIX_OPTION: DropdownChoice[] = [
{
id: Enums.FairlightAudioMixOption.On,
label: 'On'
},
{
id: Enums.FairlightAudioMixOption.Off,
label: 'Off'
},
{
id: Enums.FairlightAudioMixOption.AudioFollowVideo,
label: 'AFV'
}
]
export function GetTransitionStyleChoices(skipSting?: boolean): DropdownChoice[] {
const options = [
{ id: Enums.TransitionStyle.MIX, label: 'Mix' },
{ id: Enums.TransitionStyle.DIP, label: 'Dip' },
{ id: Enums.TransitionStyle.WIPE, label: 'Wipe' },
{ id: Enums.TransitionStyle.DVE, label: 'DVE' }
]
if (!skipSting) {
options.push({ id: Enums.TransitionStyle.STING, label: 'Sting' })
}
return options
}
export function GetMEIdChoices(model: ModelSpec): DropdownChoice[] {
return iterateTimes(model.MEs, i => ({
id: i,
label: `M/E ${i + 1}`
}))
}
export function GetAuxIdChoices(model: ModelSpec): DropdownChoice[] {
return iterateTimes(model.auxes, i => ({
id: i,
label: `${i + 1}`
}))
}
export function GetUSKIdChoices(model: ModelSpec): DropdownChoice[] {
return iterateTimes(model.USKs, i => ({
id: i,
label: `${i + 1}`
}))
}
export function GetDSKIdChoices(model: ModelSpec): DropdownChoice[] {
return iterateTimes(model.DSKs, i => ({
id: i,
label: `${i + 1}`
}))
}
export function GetMultiviewerIdChoices(model: ModelSpec): DropdownChoice[] {
return iterateTimes(model.MVs, i => ({
id: i,
label: `MV ${i + 1}`
}))
}
export function GetSuperSourceIdChoices(model: ModelSpec): DropdownChoice[] {
return iterateTimes(model.SSrc, i => ({
id: i,
label: `Super Source ${i + 1}`
}))
}
export function GetMacroChoices(model: ModelSpec, state: AtemState): DropdownChoice[] {
return iterateTimes(model.macros, i => {
const macro = state.macro.macroProperties[i]
return {
id: i + 1,
label: (macro?.isUsed ? `${macro.name} (#${i + 1})` : undefined) || `Macro ${i + 1}`
}
})
}
export function GetMediaPlayerChoices(model: ModelSpec): DropdownChoice[] {
return iterateTimes(model.media.players, i => {
return {
id: i,
label: `Media Player ${i + 1}`
}
})
}
export interface MiniSourceInfo {
id: number
longName: string
}
export interface SourceInfo extends MiniSourceInfo {
shortName: string
}
export function GetSourcesListForType(
model: ModelSpec,
state: AtemState,
subset?: 'me' | 'aux' | 'mv' | 'key' | 'ssrc-box' | 'ssrc-art'
): SourceInfo[] {
const getSource = (id: number, defShort: string, defLong: string): SourceInfo => {
const input = state.inputs[id]
const shortName = input?.shortName || defShort
const longName = input?.longName || defLong
return literal<SourceInfo>({
id,
shortName,
longName
})
}
const sources: SourceInfo[] = []
for (const input of model.inputs) {
switch (subset) {
case undefined:
break
case 'me':
if (input.meAvailability === Enums.MeAvailability.None) continue
break
case 'aux':
if ((input.sourceAvailability & Enums.SourceAvailability.Auxiliary) === 0) continue
break
case 'mv':
if ((input.sourceAvailability & Enums.SourceAvailability.Multiviewer) === 0) continue
break
case 'key':
if ((input.sourceAvailability & Enums.SourceAvailability.KeySource) === 0) continue
break
case 'ssrc-box':
if ((input.sourceAvailability & Enums.SourceAvailability.SuperSourceBox) === 0) continue
break
case 'ssrc-art':
if ((input.sourceAvailability & Enums.SourceAvailability.SuperSourceArt) === 0) continue
break
default:
assertUnreachable(subset)
break
}
switch (input.portType) {
case Enums.InternalPortType.External:
sources.push(getSource(input.id, `In ${input.id}`, `Input ${input.id}`))
break
case Enums.InternalPortType.ColorBars:
sources.push(getSource(input.id, 'Bars', 'Bars'))
break
case Enums.InternalPortType.ColorGenerator: {
const colId = input.id - 2000
sources.push(getSource(input.id, `Col${colId}`, `Color ${colId}`))
break
}
case Enums.InternalPortType.MediaPlayerFill: {
const mpId = (input.id - 3000) / 10
sources.push(getSource(input.id, `MP ${mpId}`, `Media Player ${mpId}`))
break
}
case Enums.InternalPortType.MediaPlayerKey: {
const mpId = (input.id - 3000 - 1) / 10
sources.push(getSource(input.id, `MP${mpId}K`, `Media Player ${mpId} Key`))
break
}
case Enums.InternalPortType.SuperSource: {
const ssrcId = input.id - 6000 + 1
sources.push(getSource(6000, `SSc${ssrcId}`, `Super Source ${ssrcId}`))
break
}
case Enums.InternalPortType.ExternalDirect: {
const inputId = input.id - 11000
sources.push(getSource(input.id, `In${inputId}D`, `Input ${inputId} - Direct`))
break
}
case Enums.InternalPortType.MEOutput: {
if (input.id < 8000) {
const clnId = input.id - 7000
sources.push(getSource(input.id, `Cln${clnId}`, `Clean Feed ${clnId}`))
} else if (input.id % 2 === 1) {
const meId = (input.id - 10000 - 1) / 10
sources.push(getSource(input.id, `M${meId}PV`, `ME ${meId} Preview`))
} else {
const meId = (input.id - 10000) / 10
sources.push(getSource(input.id, `M${meId}PG`, `ME ${meId} Program`))
}
break
}
case Enums.InternalPortType.Auxiliary: {
const auxId = input.id - 8000
sources.push(getSource(input.id, `Aux${auxId}`, `Auxiliary ${auxId}`))
break
}
case Enums.InternalPortType.Mask: {
// TODO
// const maskId = input.id - 0
// sources.push(getSource(input.id, `MK${maskId}`, `Key Mask ${maskId}`))
break
}
case Enums.InternalPortType.MultiViewer: {
const mvId = input.id - 9000
sources.push(getSource(input.id, `MV ${mvId}`, `MultiView ${mvId}`))
break
}
case Enums.InternalPortType.Black:
sources.push(getSource(input.id, 'Blk', 'Black'))
break
default:
assertUnreachable(input.portType)
break
}
}
sources.sort((a, b) => a.id - b.id)
return sources
}
export function GetAudioInputsList(model: ModelSpec, state: AtemState): MiniSourceInfo[] {
const getSource = (id: number, videoId: number | undefined, defLong: string): MiniSourceInfo => {
const input = videoId !== undefined ? state.inputs[videoId] : undefined
const longName = input?.longName || defLong
return literal<MiniSourceInfo>({
id,
longName
})
}
const sources: MiniSourceInfo[] = []
for (const input of model.classicAudio?.inputs ?? model.fairlightAudio?.inputs ?? []) {
switch (input.portType) {
case Enums.ExternalPortType.Unknown:
case Enums.ExternalPortType.Component:
case Enums.ExternalPortType.Composite:
case Enums.ExternalPortType.SVideo:
// No audio on these
break
case Enums.ExternalPortType.SDI:
case Enums.ExternalPortType.HDMI:
sources.push(getSource(input.id, input.id, `Input ${input.id}`))
break
case Enums.ExternalPortType.XLR:
sources.push(getSource(input.id, undefined, `XLR`))
break
case Enums.ExternalPortType.AESEBU:
sources.push(getSource(input.id, undefined, `AES/EBU`))
break
case Enums.ExternalPortType.RCA:
sources.push(getSource(input.id, undefined, `RCA`))
break
case Enums.ExternalPortType.Internal: {
const mpId = input.id - 2000
sources.push(getSource(input.id, 3000 + mpId * 10, `Media Player ${mpId}`))
break
}
case Enums.ExternalPortType.TSJack: {
const micId = input.id - 1300
sources.push(getSource(input.id, undefined, `Mic ${micId}`))
break
}
case Enums.ExternalPortType.MADI:
break
case Enums.ExternalPortType.TRSJack:
break
default:
assertUnreachable(input.portType)
break
}
}
sources.sort((a, b) => a.id - b.id)
return sources
}
export function SourcesToChoices(sources: MiniSourceInfo[]): DropdownChoice[] {
return sources.map(s => ({
id: s.id,
label: s.longName
}))
}