Skip to content

Commit

Permalink
feat: fairlight talkback mute and solo
Browse files Browse the repository at this point in the history
  • Loading branch information
Julusian committed Apr 19, 2024
1 parent 9e469df commit 84fbd73
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 1 deletion.
9 changes: 9 additions & 0 deletions src/atem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import {
FairlightAudioExpanderState,
FairlightAudioRoutingSource,
FairlightAudioRoutingOutput,
FairlightAudioMonitorSolo,
} from './state/fairlight'
import { FairlightDynamicsResetProps } from './commands/Fairlight/common'
import { MultiViewerPropertiesState } from './state/settings'
Expand Down Expand Up @@ -936,6 +937,14 @@ export class Atem extends BasicAtem {
return this.sendCommand(command)
}

public async setFairlightAudioMixerMonitorSolo(
props: Partial<OmitReadonly<FairlightAudioMonitorSolo>>
): Promise<void> {
const command = new Commands.FairlightMixerMonitorSoloCommand()
command.updateProps(props)
return this.sendCommand(command)
}

public async setFairlightAudioMixerInputProps(
index: number,
props: Commands.FairlightMixerInputCommand['properties']
Expand Down
3 changes: 3 additions & 0 deletions src/commands/Fairlight/FairlightMixerMonitorCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export class FairlightMixerMonitorCommand extends WritableCommand<OmitReadonly<F
inputMasterGain: 1 << 1,
inputMasterMuted: 1 << 2,
inputTalkbackGain: 1 << 3,
inputTalkbackMuted: 1 << 4,
inputSidetoneGain: 1 << 7,
}

Expand All @@ -22,6 +23,7 @@ export class FairlightMixerMonitorCommand extends WritableCommand<OmitReadonly<F
buffer.writeInt32BE(this.properties.inputMasterGain || 0, 8)
buffer.writeUInt8(this.properties.inputMasterMuted ? 0 : 1, 12)
buffer.writeInt32BE(this.properties.inputTalkbackGain || 0, 16)
buffer.writeUInt8(this.properties.inputTalkbackMuted ? 0 : 1, 20)
buffer.writeInt32BE(this.properties.inputSidetoneGain || 0, 32)
return buffer
}
Expand All @@ -36,6 +38,7 @@ export class FairlightMixerMonitorUpdateCommand extends DeserializedCommand<Fair
inputMasterGain: rawCommand.readInt32BE(4),
inputMasterMuted: rawCommand.readUInt8(8) === 0,
inputTalkbackGain: rawCommand.readInt32BE(12),
inputTalkbackMuted: rawCommand.readUInt8(16) === 0,
inputSidetoneGain: rawCommand.readInt32BE(28),
}

Expand Down
48 changes: 48 additions & 0 deletions src/commands/Fairlight/FairlightMixerMonitorSoloCommand.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import { FairlightAudioMonitorSolo } from '../../state/fairlight'
import { AtemState, InvalidIdError } from '../../state'
import { DeserializedCommand, WritableCommand } from '../CommandBase'
import { OmitReadonly } from '../../lib/types'

export class FairlightMixerMonitorSoloCommand extends WritableCommand<OmitReadonly<FairlightAudioMonitorSolo>> {
public static MaskFlags = {
solo: 1 << 0,
index: 1 << 1,
source: 1 << 1, // Intentional duplicate
}

public static readonly rawName = 'CFMS'

public serialize(): Buffer {
const buffer = Buffer.alloc(24)
buffer.writeUInt8(this.flag, 0)

buffer.writeUInt8(this.properties.solo ? 1 : 0, 1)
buffer.writeUInt16BE(this.properties.index ?? 0, 8)
if (this.properties.source) buffer.writeBigInt64BE(BigInt(this.properties.source), 16)
return buffer
}
}

export class FairlightMixerMonitorSoloUpdateCommand extends DeserializedCommand<FairlightAudioMonitorSolo> {
public static readonly rawName = 'FAMS'

public static deserialize(rawCommand: Buffer): FairlightMixerMonitorSoloUpdateCommand {
const properties: FairlightAudioMonitorSolo = {
solo: rawCommand.readUint8(0) === 1,
index: rawCommand.readUInt16BE(8),
source: rawCommand.readBigInt64BE(16).toString(),
}

return new FairlightMixerMonitorSoloUpdateCommand(properties)
}

public applyToState(state: AtemState): string {
if (!state.fairlight) {
throw new InvalidIdError('Fairlight')
}

state.fairlight.solo = { ...this.properties }

return `fairlight.solo`
}
}
2 changes: 1 addition & 1 deletion src/commands/Fairlight/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export * from './FairlightMixerMasterLevelsCommand'
export * from './FairlightMixerMasterLimiterCommand'
export * from './FairlightMixerMasterPropertiesCommand'
export * from './FairlightMixerMonitorCommand'
// export * from './FairlightMixerMonitorSoloCommand'
export * from './FairlightMixerMonitorSoloCommand'
export * from './FairlightMixerResetPeakLevelsCommand'
export * from './FairlightMixerSendLevelsCommand'
export * from './FairlightMixerSourceCommand'
Expand Down
9 changes: 9 additions & 0 deletions src/state/fairlight.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,15 @@ export interface FairlightAudioMonitorChannel {
inputMasterGain: number
inputMasterMuted: boolean
inputTalkbackGain: number
inputTalkbackMuted: boolean
inputSidetoneGain: number
// inputSidetoneMuted: boolean
}

export interface FairlightAudioMonitorSolo {
solo: boolean
index: number
source: string
}

export interface FairlightAudioSource {
Expand Down Expand Up @@ -162,6 +170,7 @@ export interface AtemFairlightAudioState {
inputs: { [input: number]: FairlightAudioInput | undefined }
master?: FairlightAudioMasterChannel
monitor?: FairlightAudioMonitorChannel
solo?: FairlightAudioMonitorSolo

audioFollowVideoCrossfadeTransitionEnabled?: boolean

Expand Down

0 comments on commit 84fbd73

Please sign in to comment.