Skip to content

Commit

Permalink
feat: adding support for multiple mixers in all product specific mixe…
Browse files Browse the repository at this point in the history
…rConnections
  • Loading branch information
olzzon authored and olzzon committed Oct 5, 2020
1 parent b33ea95 commit 95209b5
Show file tree
Hide file tree
Showing 10 changed files with 622 additions and 448 deletions.
27 changes: 18 additions & 9 deletions server/utils/MixerConnection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,39 +54,48 @@ export class MixerGenericConnection {
this.mixerConnection.push({})
if (this.mixerProtocol[index].protocol === 'OSC') {
this.mixerConnection[index] = new OscMixerConnection(
this.mixerProtocol[index] as IMixerProtocol
this.mixerProtocol[index] as IMixerProtocol,
index
)
} else if (this.mixerProtocol[index].protocol === 'QLCL') {
this.mixerConnection[index] = new QlClMixerConnection(
this.mixerProtocol[index] as IMixerProtocol
this.mixerProtocol[index] as IMixerProtocol,
index
)
} else if (this.mixerProtocol[index].protocol === 'MIDI') {
this.mixerConnection[index] = new MidiMixerConnection(
this.mixerProtocol[index] as IMixerProtocol
this.mixerProtocol[index] as IMixerProtocol,
index
)
} else if (this.mixerProtocol[index].protocol === 'CasparCG') {
this.mixerConnection[index] = new CasparCGConnection(
this.mixerProtocol[index] as ICasparCGMixerGeometry
this.mixerProtocol[index] as ICasparCGMixerGeometry,
index
)
} else if (this.mixerProtocol[index].protocol === 'EMBER') {
this.mixerConnection[index] = new EmberMixerConnection(
this.mixerProtocol[index] as IMixerProtocol
this.mixerProtocol[index] as IMixerProtocol,
index
)
} else if (this.mixerProtocol[index].protocol === 'LAWORUBY') {
this.mixerConnection[index] = new LawoRubyMixerConnection(
this.mixerProtocol[index] as IMixerProtocol
this.mixerProtocol[index] as IMixerProtocol,
index
)
} else if (this.mixerProtocol[index].protocol === 'STUDER') {
this.mixerConnection[index] = new StuderMixerConnection(
this.mixerProtocol[index] as IMixerProtocol
this.mixerProtocol[index] as IMixerProtocol,
index
)
} else if (this.mixerProtocol[index].protocol === 'VISTA') {
this.mixerConnection[index] = new StuderVistaMixerConnection(
this.mixerProtocol[index] as IMixerProtocol
this.mixerProtocol[index] as IMixerProtocol,
index
)
} else if (this.mixerProtocol[index].protocol === 'SSL') {
this.mixerConnection[index] = new SSLMixerConnection(
this.mixerProtocol[index] as IMixerProtocol
this.mixerProtocol[index] as IMixerProtocol,
index
)
}
})
Expand Down
39 changes: 24 additions & 15 deletions server/utils/mixerConnections/CasparCGConnection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,24 @@ const OSC_PATH_PRODUCER_CHANNEL_LAYOUT = /\/channel\/(\d+)\/stage\/layer\/(\d+)\

export class CasparCGConnection {
mixerProtocol: ICasparCGMixerGeometry
mixerIndex: number
connection: CasparCG
oscClient: any
oscCommandMap: { [key: string]: CommandChannelMap } = {}

constructor(mixerProtocol: ICasparCGMixerGeometry) {
constructor(mixerProtocol: ICasparCGMixerGeometry, mixerIndex: number) {
this.mixerProtocol = mixerProtocol
this.mixerIndex = mixerIndex
this.injectCasparCGSetting()

this.connection = new CasparCG({
autoReconnect: true,
autoReconnectAttempts: 20,
autoReconnectInterval: 3000,
host: state.settings[0].mixers[0].deviceIp,
port: parseInt(state.settings[0].mixers[0].devicePort + ''),
host: state.settings[0].mixers[this.mixerIndex].deviceIp,
port: parseInt(
state.settings[0].mixers[this.mixerIndex].devicePort + ''
),
})
logger.info('Trying to connect to CasparCG...')
this.connection.onConnected = () => {
Expand Down Expand Up @@ -96,11 +100,14 @@ export class CasparCGConnection {
setupMixerConnection() {
if (!this.oscClient) {
const remotePort =
parseInt(state.settings[0].mixers[0].devicePort + '') + 1000
parseInt(
state.settings[0].mixers[this.mixerIndex].devicePort + ''
) + 1000
this.oscClient = new osc.UDPPort({
localAddress: state.settings[0].localIp,
localPort: remotePort,
remoteAddress: state.settings[0].mixers[0].deviceIp,
remoteAddress:
state.settings[0].mixers[this.mixerIndex].deviceIp,
remotePort,
})
.on('ready', () => {
Expand Down Expand Up @@ -192,7 +199,7 @@ export class CasparCGConnection {
this.oscClient.open()
logger.info(
'Listening for status on CasparCG: ' +
state.settings[0].mixers[0].deviceIp +
state.settings[0].mixers[this.mixerIndex].deviceIp +
':' +
remotePort
)
Expand Down Expand Up @@ -346,15 +353,17 @@ export class CasparCGConnection {
updateChannelSetting(channelIndex: number, setting: string, value: string) {
if (
this.mixerProtocol.sourceOptions &&
state.channels[0].chConnection[0].channel[channelIndex].private
state.channels[0].chConnection[this.mixerIndex].channel[
channelIndex
].private
) {
const pair = this.mixerProtocol.sourceOptions.sources[channelIndex]
const producer = state.channels[0].chConnection[0].channel[
channelIndex
].private!['producer']
const producer = state.channels[0].chConnection[this.mixerIndex]
.channel[channelIndex].private!['producer']
let filePath = String(
state.channels[0].chConnection[0].channel[channelIndex]
.private!['file_path']
state.channels[0].chConnection[this.mixerIndex].channel[
channelIndex
].private!['file_path']
)
filePath = filePath.replace(/\.[\w\d]+$/, '')
this.controlChannelSetting(
Expand Down Expand Up @@ -420,7 +429,7 @@ export class CasparCGConnection {
this.setAllLayers(pairs, this.mixerProtocol.fader.min)
} else {
// There are no other SOLO channels, restore PFL to match PGM
state.channels[0].chConnection[0].channel.forEach(
state.channels[0].chConnection[this.mixerIndex].channel.forEach(
(i, index) => {
if (
index >
Expand All @@ -435,8 +444,8 @@ export class CasparCGConnection {
.PFL_AUX_FADER_LEVEL[index]
this.setAllLayers(
pairs,
state.channels[0].chConnection[0].channel[index]
.outputLevel
state.channels[0].chConnection[this.mixerIndex]
.channel[index].outputLevel
)
}
)
Expand Down
79 changes: 47 additions & 32 deletions server/utils/mixerConnections/EmberMixerConnection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,23 @@ import { logger } from '../logger'

export class EmberMixerConnection {
mixerProtocol: IMixerProtocol
mixerIndex: number
emberConnection: EmberClient
deviceRoot: any
emberNodeObject: Array<any>

constructor(mixerProtocol: IMixerProtocol) {
constructor(mixerProtocol: IMixerProtocol, mixerIndex: number) {
this.sendOutMessage = this.sendOutMessage.bind(this)
this.pingMixerCommand = this.pingMixerCommand.bind(this)

this.emberNodeObject = new Array(200)
this.mixerProtocol = mixerProtocol
this.mixerIndex = mixerIndex

logger.info('Setting up Ember connection')
this.emberConnection = new EmberClient(
state.settings[0].mixers[0].deviceIp,
state.settings[0].mixers[0].devicePort
state.settings[0].mixers[this.mixerIndex].deviceIp,
state.settings[0].mixers[this.mixerIndex].devicePort
)

this.emberConnection.on('error', (error: any) => {
Expand Down Expand Up @@ -70,18 +72,18 @@ export class EmberMixerConnection {
)

let ch: number = 1
state.settings[0].mixers[0].numberOfChannelsInType.forEach(
(numberOfChannels, typeIndex) => {
for (
let channelTypeIndex = 0;
channelTypeIndex < numberOfChannels;
channelTypeIndex++
) {
this.subscribeFaderLevel(ch, typeIndex, channelTypeIndex)
ch++
}
state.settings[0].mixers[
this.mixerIndex
].numberOfChannelsInType.forEach((numberOfChannels, typeIndex) => {
for (
let channelTypeIndex = 0;
channelTypeIndex < numberOfChannels;
channelTypeIndex++
) {
this.subscribeFaderLevel(ch, typeIndex, channelTypeIndex)
ch++
}
)
})
/*
.CHANNEL_VU)){
store.dispatch({
Expand Down Expand Up @@ -118,10 +120,10 @@ export class EmberMixerConnection {
this.emberConnection.subscribe(node, () => {
logger.verbose('Receiving Level from Ch ' + String(ch))
if (
!state.channels[0].chConnection[0].channel[ch - 1]
.fadeActive &&
!state.channels[0].chConnection[0].channel[ch - 1]
.fadeActive &&
!state.channels[0].chConnection[this.mixerIndex]
.channel[ch - 1].fadeActive &&
!state.channels[0].chConnection[this.mixerIndex]
.channel[ch - 1].fadeActive &&
(node.contents as Model.Parameter).value >
this.mixerProtocol.channelTypes[typeIndex].fromMixer
.CHANNEL_OUT_GAIN[0].min
Expand Down Expand Up @@ -241,26 +243,33 @@ export class EmberMixerConnection {

updateOutLevel(channelIndex: number) {
let channelType =
state.channels[0].chConnection[0].channel[channelIndex].channelType
state.channels[0].chConnection[this.mixerIndex].channel[
channelIndex
].channelType
let channelTypeIndex =
state.channels[0].chConnection[0].channel[channelIndex]
.channelTypeIndex
state.channels[0].chConnection[this.mixerIndex].channel[
channelIndex
].channelTypeIndex
let protocol = this.mixerProtocol.channelTypes[channelType].toMixer
.CHANNEL_OUT_GAIN[0]
let level =
(state.channels[0].chConnection[0].channel[channelIndex]
.outputLevel -
(state.channels[0].chConnection[this.mixerIndex].channel[
channelIndex
].outputLevel -
protocol.min) *
(protocol.max - protocol.min)
this.sendOutLevelMessage(channelTypeIndex + 1, level)
}

updateFadeIOLevel(channelIndex: number, outputLevel: number) {
let channelType =
state.channels[0].chConnection[0].channel[channelIndex].channelType
state.channels[0].chConnection[this.mixerIndex].channel[
channelIndex
].channelType
let channelTypeIndex =
state.channels[0].chConnection[0].channel[channelIndex]
.channelTypeIndex
state.channels[0].chConnection[this.mixerIndex].channel[
channelIndex
].channelTypeIndex
let protocol = this.mixerProtocol.channelTypes[channelType].toMixer
.CHANNEL_OUT_GAIN[0]
let level = (outputLevel - protocol.min) * (protocol.max - protocol.min)
Expand All @@ -270,10 +279,13 @@ export class EmberMixerConnection {

updatePflState(channelIndex: number) {
let channelType =
state.channels[0].chConnection[0].channel[channelIndex].channelType
state.channels[0].chConnection[this.mixerIndex].channel[
channelIndex
].channelType
let channelTypeIndex =
state.channels[0].chConnection[0].channel[channelIndex]
.channelTypeIndex
state.channels[0].chConnection[this.mixerIndex].channel[
channelIndex
].channelTypeIndex

if (state.faders[0].fader[channelIndex].pflOn === true) {
this.sendOutMessage(
Expand Down Expand Up @@ -340,10 +352,13 @@ export class EmberMixerConnection {

updateChannelName(channelIndex: number) {
let channelType =
state.channels[0].chConnection[0].channel[channelIndex].channelType
state.channels[0].chConnection[this.mixerIndex].channel[
channelIndex
].channelType
let channelTypeIndex =
state.channels[0].chConnection[0].channel[channelIndex]
.channelTypeIndex
state.channels[0].chConnection[this.mixerIndex].channel[
channelIndex
].channelTypeIndex
let channelName = state.faders[0].fader[channelIndex].label
this.sendOutMessage(
this.mixerProtocol.channelTypes[channelType].toMixer.CHANNEL_NAME[0]
Expand Down
Loading

0 comments on commit 95209b5

Please sign in to comment.