diff --git a/src/__tests__/tally.spec.ts b/src/__tests__/tally.spec.ts index e4288b98b..975cd14e0 100644 --- a/src/__tests__/tally.spec.ts +++ b/src/__tests__/tally.spec.ts @@ -29,6 +29,22 @@ function loadRawState(file: string): AtemState { videoState.mixEffects = videoState.ME } + loadedState.video.mixEffects.forEach(me => { + // Lazy fix up moving some state properties + if (me) { + const me1 = me as any + if (typeof me.transitionPosition === 'number') { + me.transitionPosition = { + inTransition: me1.inTransition, + handlePosition: me1.transitionPosition, + remainingFrames: me1.transitionFramesLeft + } + delete me1.transitionFramesLeft + delete me1.inTransition + } + } + }) + return loadedState } function loadTally(file: string): { program: number[]; preview: number[] } { diff --git a/src/commands/MixEffects/Transition/TransitionPositionCommand.ts b/src/commands/MixEffects/Transition/TransitionPositionCommand.ts index 3699159f7..b3e609b18 100644 --- a/src/commands/MixEffects/Transition/TransitionPositionCommand.ts +++ b/src/commands/MixEffects/Transition/TransitionPositionCommand.ts @@ -1,11 +1,8 @@ import { BasicWritableCommand, DeserializedCommand } from '../../CommandBase' import { AtemState, AtemStateUtil, InvalidIdError } from '../../../state' +import { TransitionPosition } from '../../../state/video' -export interface HandlePositionProps { - handlePosition: number // 0...10000 -} - -export class TransitionPositionCommand extends BasicWritableCommand { +export class TransitionPositionCommand extends BasicWritableCommand> { public static readonly rawName = 'CTPs' public readonly mixEffect: number @@ -24,17 +21,12 @@ export class TransitionPositionCommand extends BasicWritableCommand { +export class TransitionPositionUpdateCommand extends DeserializedCommand { public static readonly rawName = 'TrPs' public readonly mixEffect: number - constructor(mixEffect: number, properties: TransitionPositionProps) { + constructor(mixEffect: number, properties: TransitionPosition) { super(properties) this.mixEffect = mixEffect @@ -57,9 +49,7 @@ export class TransitionPositionUpdateCommand extends DeserializedCommand, mode: 'program' | 'preview', s const keyerMask = 1 << (usk.upstreamKeyerId + 1) const isPartOfTransition = meRef.transitionProperties.selection & keyerMask if (mode === 'program') { - if (meRef.inTransition) { + if (meRef.transitionPosition.inTransition) { return usk.onAir || isPartOfTransition } @@ -77,8 +77,9 @@ function _calcActiveMeInputs(inputs: Set, mode: 'program' | 'preview', s } // Compute what sources are currently participating in a transition. - const isTransitionInProgram = mode === 'program' && meRef.inTransition - const isTransitionInPreview = mode === 'preview' && meRef.transitionPreview && meRef.transitionPosition > 0 + const isTransitionInProgram = mode === 'program' && meRef.transitionPosition.inTransition + const isTransitionInPreview = + mode === 'preview' && meRef.transitionPreview && meRef.transitionPosition.handlePosition > 0 if (isTransitionInProgram || isTransitionInPreview) { if (meRef.transitionProperties.selection & 1) { // Includes background diff --git a/src/state/util.ts b/src/state/util.ts index c6c0f65a5..07527553a 100644 --- a/src/state/util.ts +++ b/src/state/util.ts @@ -99,10 +99,12 @@ export function getMixEffect(state: AtemState, index: number, dontCreate?: boole index, programInput: 0, previewInput: 0, - inTransition: false, transitionPreview: false, - transitionPosition: 0, - transitionFramesLeft: 0, + transitionPosition: { + inTransition: false, + handlePosition: 0, + remainingFrames: 0 + }, transitionProperties: { style: Enums.TransitionStyle.MIX, selection: 1, diff --git a/src/state/video/index.ts b/src/state/video/index.ts index 05f89b93e..29886bd5d 100644 --- a/src/state/video/index.ts +++ b/src/state/video/index.ts @@ -72,15 +72,19 @@ export interface TransitionSettings { wipe?: WipeTransitionSettings } +export interface TransitionPosition { + inTransition: boolean + handlePosition: number + remainingFrames: number +} + export interface MixEffect { readonly index: number programInput: number previewInput: number - inTransition: boolean transitionPreview: boolean - transitionPosition: number - transitionFramesLeft: number fadeToBlack?: FadeToBlackProperties + transitionPosition: TransitionPosition transitionProperties: TransitionProperties transitionSettings: TransitionSettings readonly upstreamKeyers: Array