Skip to content

Commit

Permalink
feat: fairlight audio routing
Browse files Browse the repository at this point in the history
  • Loading branch information
Julusian committed Aug 8, 2023
1 parent 04e44e8 commit a2ad66f
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 6 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
"@sofie-automation/code-standard-preset": "^0.3.0",
"@types/jest": "^26.0.23",
"@types/node": "^12.20.13",
"atem-connection": "~2.4",
"atem-connection": "~2.5",
"jest": "^26.6.3",
"open-cli": "^6",
"rimraf": "^3.0.2",
Expand All @@ -77,7 +77,7 @@
"source"
],
"peerDependencies": {
"atem-connection": "~2.4"
"atem-connection": "~2.5"
},
"dependencies": {
"deepmerge": "^4.2.2",
Expand Down
46 changes: 46 additions & 0 deletions src/resolvers/fairlight-audio.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { Commands as AtemCommands, Commands, Fairlight } from 'atem-connection'
import { State as StateObject } from '..'
import { getAllKeysNumber, diffObject, fillDefaults } from '../util'
import { PartialDeep } from 'type-fest'

export function resolveFairlightAudioState(
oldState: PartialDeep<StateObject>,
newState: PartialDeep<StateObject>
): Array<Commands.ISerializableCommand> {
const commands: Array<AtemCommands.ISerializableCommand> = []
if (!newState.fairlight) return commands

if (newState.fairlight.audioRouting || oldState.fairlight?.audioRouting) {
commands.push(
...resolveFairlightAudioRoutingState(newState.fairlight.audioRouting, oldState.fairlight?.audioRouting)
)
}

return commands
}

export function resolveFairlightAudioRoutingState(
oldState: PartialDeep<Fairlight.FairlightAudioRouting> | undefined,
newState: PartialDeep<Fairlight.FairlightAudioRouting> | undefined
): Array<AtemCommands.ISerializableCommand> {
const commands: Array<AtemCommands.ISerializableCommand> = []

for (const outputId of getAllKeysNumber(oldState?.outputs, newState?.outputs)) {
const oldProperties = fillDefaults<Pick<Fairlight.FairlightAudioRoutingOutput, 'sourceId'>>(
{ sourceId: 0 },
oldState?.outputs?.[outputId]
)
const newProperties = fillDefaults<Pick<Fairlight.FairlightAudioRoutingOutput, 'sourceId'>>(
{ sourceId: 0 },
newState?.outputs?.[outputId]
)

const props = diffObject<Fairlight.FairlightAudioRoutingOutput>(oldProperties, newProperties)
const command = new AtemCommands.AudioRoutingOutputCommand(outputId)
if (command.updateProps(props)) {
commands.push(command)
}
}

return commands
}
2 changes: 2 additions & 0 deletions src/resolvers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { resolveMacroPlayerState } from './macro'
import { getAllKeysNumber } from '../util'
import { resolveMediaPlayerState } from './media'
import { PartialDeep } from 'type-fest'
import { resolveFairlightAudioState } from './fairlight-audio'

export function videoState(
oldState: PartialDeep<StateObject>,
Expand All @@ -22,6 +23,7 @@ export function videoState(
commands.push(...resolveDownstreamKeyerState(oldState, newState))
commands.push(...resolveSuperSourceState(oldState, newState, version))
commands.push(...resolveAudioState(oldState, newState))
commands.push(...resolveFairlightAudioState(oldState, newState))
commands.push(...resolveMediaPlayerState(oldState, newState))

// resolve auxilliaries:
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -972,10 +972,10 @@ at-least-node@^1.0.0:
resolved "https://registry.yarnpkg.com/at-least-node/-/at-least-node-1.0.0.tgz#602cd4b46e844ad4effc92a8011a3c46e0238dc2"
integrity sha512-+q/t7Ekv1EDY2l6Gda6LLiX14rU9TV20Wa3ofeQmwPFZbOMo9DXrLbOjFaaclkXKWidIaopwAObQDqwWtGUjqg==

atem-connection@~2.4:
version "2.4.0"
resolved "https://registry.yarnpkg.com/atem-connection/-/atem-connection-2.4.0.tgz#bcaf5713e6a3f64be45583bf98b0c294255b7f86"
integrity sha512-/D+fWWRrCcxzfCbSdUMT00nCR/S8xCwFTSE6oqFkFSb0mtxgCORs8WKMF0KZddPPuUU2S/4ZfR+Oh53Hm/d/jQ==
atem-connection@~2.5:
version "2.5.0"
resolved "https://registry.yarnpkg.com/atem-connection/-/atem-connection-2.5.0.tgz#dceb616595af37d0b3c118d0a9e6f613f1a2d419"
integrity sha512-JZI0B9jfw91ALSx4hOQH8Mk5TGQuJcK1/tdHQDIvoPW+z7qOds2JPlxNHkk5Thg5pLVKBgMHxIXDWfQ5vHPw8w==
dependencies:
big-integer "^1.6.51"
eventemitter3 "^4.0.4"
Expand Down

0 comments on commit a2ad66f

Please sign in to comment.