Skip to content

Commit 3e4ccf1

Browse files
authored
feat: fly key settings (#28)
1 parent 3576354 commit 3e4ccf1

File tree

4 files changed

+43
-5
lines changed

4 files changed

+43
-5
lines changed

src/defaults/video.ts

+7
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,13 @@ export function flyKeyframe(id: number): VideoState.USK.UpstreamKeyerFlyKeyframe
239239
}
240240
}
241241

242+
export const FlyKeyProperties: VideoState.USK.UpstreamKeyerFlySettings = {
243+
isASet: false,
244+
isBSet: false,
245+
isAtKeyFrame: Enums.IsAtKeyFrame.None,
246+
runToInfiniteIndex: Enums.FlyKeyDirection.CentreOfKey,
247+
}
248+
242249
export const SuperSourceBox: VideoState.SuperSource.SuperSourceBox = {
243250
enabled: false,
244251
source: defaultInput,

src/diff.ts

+2
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ export function DiffAllObject(): DeepComplete<SectionsToDiff> {
4848
mask: true,
4949

5050
flyKeyframes: 'all',
51+
flyProperties: true,
5152
dveSettings: true,
5253
chromaSettings: true,
5354
advancedChromaSettings: true,
@@ -162,6 +163,7 @@ export interface DiffUpstreamKeyer {
162163
mask?: boolean
163164

164165
flyKeyframes?: number[] | 'all'
166+
flyProperties?: boolean
165167
dveSettings?: boolean
166168
chromaSettings?: boolean
167169
advancedChromaSettings?: boolean

src/resolvers/upstreamKeyers/flyKey.ts

+28-4
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
import { Commands as AtemCommands, VideoState } from 'atem-connection'
1+
import { Commands as AtemCommands, Enums, VideoState } from 'atem-connection'
22
import { diffObject, fillDefaults, getAllKeysNumber } from '../../util'
33
import * as Defaults from '../../defaults'
44
import { PartialDeep } from 'type-fest'
55

6-
type FlyFrmaesState = [
6+
type FlyFramesState = [
77
VideoState.USK.UpstreamKeyerFlyKeyframe | undefined,
88
VideoState.USK.UpstreamKeyerFlyKeyframe | undefined
99
]
1010

1111
export function resolveFlyKeyerFramesState(
1212
mixEffectId: number,
1313
upstreamKeyerId: number,
14-
oldState: PartialDeep<FlyFrmaesState>,
15-
newState: PartialDeep<FlyFrmaesState>,
14+
oldState: PartialDeep<FlyFramesState>,
15+
newState: PartialDeep<FlyFramesState>,
1616
diffOptions: number[] | 'all'
1717
): Array<AtemCommands.ISerializableCommand> {
1818
const commands: Array<AtemCommands.ISerializableCommand> = []
@@ -32,3 +32,27 @@ export function resolveFlyKeyerFramesState(
3232

3333
return commands
3434
}
35+
36+
export function resolveFlyPropertiesState(
37+
mixEffectId: number,
38+
upstreamKeyerId: number,
39+
oldState: Partial<VideoState.USK.UpstreamKeyerFlySettings> | undefined,
40+
newState: PartialDeep<VideoState.USK.UpstreamKeyerFlySettings> | undefined
41+
): Array<AtemCommands.ISerializableCommand> {
42+
const commands: Array<AtemCommands.ISerializableCommand> = []
43+
44+
if (!oldState && !newState) return commands
45+
46+
const oldKeyProps = fillDefaults(Defaults.Video.FlyKeyProperties, oldState)
47+
const newKeyProps = fillDefaults(Defaults.Video.FlyKeyProperties, newState)
48+
49+
if (oldKeyProps.isAtKeyFrame !== newKeyProps.isAtKeyFrame) {
50+
const keyframe: Enums.FlyKeyKeyFrame = newKeyProps.isAtKeyFrame as number
51+
52+
commands.push(
53+
new AtemCommands.MixEffectKeyRunToCommand(mixEffectId, upstreamKeyerId, keyframe, newKeyProps.runToInfiniteIndex)
54+
)
55+
}
56+
57+
return commands
58+
}

src/resolvers/upstreamKeyers/index.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { resolvePatternKeyerState } from './patternKeyer'
66
import { getAllKeysNumber, diffObject, fillDefaults } from '../../util'
77
import { PartialDeep } from 'type-fest'
88
import * as Defaults from '../../defaults'
9-
import { resolveFlyKeyerFramesState } from './flyKey'
9+
import { resolveFlyKeyerFramesState, resolveFlyPropertiesState } from './flyKey'
1010
import { DiffUpstreamKeyer } from '../../diff'
1111

1212
export function resolveUpstreamKeyerState(
@@ -43,6 +43,11 @@ export function resolveUpstreamKeyerState(
4343
)
4444
)
4545
}
46+
if (thisDiffOptions.flyProperties) {
47+
commands.push(
48+
...resolveFlyPropertiesState(mixEffectId, upstreamKeyerId, oldKeyer.flyProperties, newKeyer.flyProperties)
49+
)
50+
}
4651

4752
if (thisDiffOptions.chromaSettings) {
4853
commands.push(

0 commit comments

Comments
 (0)