Skip to content

Commit

Permalink
feat: refactor - rename chConnection to chMixerConnection
Browse files Browse the repository at this point in the history
  • Loading branch information
olzzon committed Mar 16, 2021
1 parent 66e3d9c commit fc22e4e
Show file tree
Hide file tree
Showing 14 changed files with 278 additions and 271 deletions.
2 changes: 1 addition & 1 deletion server/MainThreadHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ export class MainThreadHandlers {
faderIndex: faderIndex,
state: state.faders[0].fader[faderIndex],
})
state.channels[0].chConnection.forEach((chConnection) => {
state.channels[0].chMixerConnection.forEach((chConnection) => {
chConnection.channel.forEach((channel: IChannel, index: number) => {
if (channel.assignedFader === faderIndex) {
socketServer.emit(SOCKET_SET_STORE_CHANNEL, {
Expand Down
14 changes: 7 additions & 7 deletions server/reducers/channelsReducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ import {
} from './channelActions'

export interface IChannels {
chConnection: IchConnection[]
chMixerConnection: IchMixerConnection[]
}

export interface IchConnection {
export interface IchMixerConnection {
channel: Array<IChannel>
}

Expand All @@ -37,7 +37,7 @@ const defaultChannelsReducerState = (
): IChannels[] => {
let defaultObj: IChannels[] = [
{
chConnection: [],
chMixerConnection: [],
},
]

Expand All @@ -47,11 +47,11 @@ const defaultChannelsReducerState = (
mixerIndex++
) {
let totalNumberOfChannels = 0
defaultObj[0].chConnection.push({ channel: [] })
defaultObj[0].chMixerConnection.push({ channel: [] })
numberOfChannels[mixerIndex].numberOfTypeInCh.forEach(
(channelTypeSize: any, typeIndex: number) => {
for (let index = 0; index < channelTypeSize; index++) {
defaultObj[0].chConnection[mixerIndex].channel[
defaultObj[0].chMixerConnection[mixerIndex].channel[
totalNumberOfChannels
] = {
channelType: typeIndex,
Expand All @@ -76,7 +76,7 @@ export const channels = (
): Array<IChannels> => {
let nextState = [
{
chConnection: [...state[0].chConnection],
chConnection: [...state[0].chMixerConnection],
},
]

Expand All @@ -90,7 +90,7 @@ export const channels = (
nextState = defaultChannelsReducerState(action.numberOfTypeChannels)

nextState[0].chConnection.forEach(
(chConnection: IchConnection, mixerIndex: number) => {
(chConnection: IchMixerConnection, mixerIndex: number) => {
chConnection.channel.forEach(
(channel: any, index: number) => {
if (
Expand Down
66 changes: 36 additions & 30 deletions server/utils/MixerConnection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { LawoRubyMixerConnection } from './mixerConnections/LawoRubyConnection'
import { StuderMixerConnection } from './mixerConnections/StuderMixerConnection'
import { StuderVistaMixerConnection } from './mixerConnections/StuderVistaMixerConnection'
import { CasparCGConnection } from './mixerConnections/CasparCGConnection'
import { IChannel, IchConnection } from '../reducers/channelsReducer'
import { IChannel, IchMixerConnection } from '../reducers/channelsReducer'
import {
storeFadeActive,
storeSetOutputLevel,
Expand Down Expand Up @@ -104,10 +104,10 @@ export class MixerGenericConnection {
initializeTimers = () => {
//Setup timers for fade in & out
this.mixerTimers = []
state.channels[0].chConnection.forEach(
(chConnection: IchConnection, mixerIndex: number) => {
state.channels[0].chMixerConnection.forEach(
(chConnection: IchMixerConnection, mixerIndex: number) => {
this.mixerTimers.push({ chTimer: [], fadeActiveTimer: [] })
state.channels[0].chConnection[mixerIndex].channel.forEach(
state.channels[0].chMixerConnection[mixerIndex].channel.forEach(
(channel) => {
this.mixerTimers[mixerIndex].chTimer.push(undefined)
this.mixerTimers[mixerIndex].fadeActiveTimer.push(
Expand Down Expand Up @@ -177,8 +177,8 @@ export class MixerGenericConnection {
}
}

state.channels[0].chConnection.forEach(
(chConnection: IchConnection, mixerIndex: number) => {
state.channels[0].chMixerConnection.forEach(
(chConnection: IchMixerConnection, mixerIndex: number) => {
chConnection.channel.forEach(
(channel: IChannel, channelIndex: number) => {
if (faderIndex === channel.assignedFader) {
Expand All @@ -199,8 +199,8 @@ export class MixerGenericConnection {

updateInputGain = (faderIndex: number) => {
let level = state.faders[0].fader[faderIndex].inputGain
state.channels[0].chConnection.forEach(
(chConnection: IchConnection, mixerIndex: number) => {
state.channels[0].chMixerConnection.forEach(
(chConnection: IchMixerConnection, mixerIndex: number) => {
chConnection.channel.forEach(
(channel: IChannel, channelIndex: number) => {
if (faderIndex === channel.assignedFader) {
Expand All @@ -218,9 +218,9 @@ export class MixerGenericConnection {
updateInputSelector = (faderIndex: number) => {
let inputSelected = state.faders[0].fader[faderIndex].inputSelector
console.log(faderIndex, inputSelected)
state.channels[0].chConnection.forEach(
(chConnection: IchConnection, mixerIndex: number) => {
chConnection.channel.forEach(
state.channels[0].chMixerConnection.forEach(
(chMixerConnection: IchMixerConnection, mixerIndex: number) => {
chMixerConnection.channel.forEach(
(channel: IChannel, channelIndex: number) => {
if (faderIndex === channel.assignedFader) {
this.mixerConnection[
Expand All @@ -238,8 +238,8 @@ export class MixerGenericConnection {
}

updateMuteState = (faderIndex: number) => {
state.channels[0].chConnection.forEach(
(chConnection: IchConnection, mixerIndex: number) => {
state.channels[0].chMixerConnection.forEach(
(chConnection: IchMixerConnection, mixerIndex: number) => {
chConnection.channel.forEach(
(channel: IChannel, channelIndex: number) => {
if (faderIndex === channel.assignedFader) {
Expand All @@ -255,8 +255,8 @@ export class MixerGenericConnection {
}

updateAMixState = (faderIndex: number) => {
state.channels[0].chConnection.forEach(
(chConnection: IchConnection, mixerIndex: number) => {
state.channels[0].chMixerConnection.forEach(
(chConnection: IchMixerConnection, mixerIndex: number) => {
chConnection.channel.forEach(
(channel: IChannel, channelIndex: number) => {
if (faderIndex === channel.assignedFader) {
Expand All @@ -281,8 +281,8 @@ export class MixerGenericConnection {
(100 - state.settings[0].voLevel)) /
100
}
state.channels[0].chConnection.forEach(
(chConnection: IchConnection, mixerIndex: number) => {
state.channels[0].chMixerConnection.forEach(
(chConnection: IchMixerConnection, mixerIndex: number) => {
chConnection.channel.forEach(
(channel: IChannel, channelIndex: number) => {
if (faderIndex === channel.assignedFader) {
Expand All @@ -299,8 +299,8 @@ export class MixerGenericConnection {

updateFx = (fxParam: fxParamsList, faderIndex: number) => {
let level: number = state.faders[0].fader[faderIndex][fxParam][0]
state.channels[0].chConnection.forEach(
(chConnection: IchConnection, mixerIndex: number) => {
state.channels[0].chMixerConnection.forEach(
(chConnection: IchMixerConnection, mixerIndex: number) => {
chConnection.channel.forEach(
(channel: IChannel, channelIndex: number) => {
if (faderIndex === channel.assignedFader) {
Expand All @@ -316,7 +316,8 @@ export class MixerGenericConnection {
)
}
updateAuxLevel = (channelIndex: number, auxSendIndex: number) => {
let channel = state.channels[0].chConnection[0].channel[channelIndex]
let channel =
state.channels[0].chMixerConnection[0].channel[channelIndex]
if (channel.auxLevel[auxSendIndex] > -1) {
this.mixerConnection[0].updateAuxLevel(
channelIndex,
Expand Down Expand Up @@ -354,13 +355,15 @@ export class MixerGenericConnection {
fadeTime: number
) => {
let faderIndex =
state.channels[0].chConnection[mixerIndex].channel[channelIndex]
.assignedFader
state.channels[0].chMixerConnection[mixerIndex].channel[
channelIndex
].assignedFader
if (
!state.faders[0].fader[faderIndex].pgmOn &&
!state.faders[0].fader[faderIndex].voOn &&
state.channels[0].chConnection[mixerIndex].channel[channelIndex]
.outputLevel === 0
state.channels[0].chMixerConnection[mixerIndex].channel[
channelIndex
].outputLevel === 0
) {
return
}
Expand All @@ -372,8 +375,9 @@ export class MixerGenericConnection {
}
//Clear Old timer or set Fade to active:
if (
state.channels[0].chConnection[mixerIndex].channel[channelIndex]
.fadeActive
state.channels[0].chMixerConnection[mixerIndex].channel[
channelIndex
].fadeActive
) {
clearInterval(
this.mixerTimers[mixerIndex].fadeActiveTimer[channelIndex]
Expand All @@ -398,8 +402,9 @@ export class MixerGenericConnection {
faderIndex: number
) => {
let outputLevel =
state.channels[0].chConnection[mixerIndex].channel[channelIndex]
.outputLevel
state.channels[0].chMixerConnection[mixerIndex].channel[
channelIndex
].outputLevel
let targetVal = state.faders[0].fader[faderIndex].faderLevel

if (state.faders[0].fader[faderIndex].voOn) {
Expand Down Expand Up @@ -513,8 +518,9 @@ export class MixerGenericConnection {

fadeDown = (mixerIndex: number, channelIndex: number, fadeTime: number) => {
let outputLevel =
state.channels[0].chConnection[mixerIndex].channel[channelIndex]
.outputLevel
state.channels[0].chMixerConnection[mixerIndex].channel[
channelIndex
].outputLevel
const step = outputLevel / (fadeTime / FADE_INOUT_SPEED)
const dispatchResolution: number =
this.mixerProtocol[mixerIndex].FADE_DISPATCH_RESOLUTION * step
Expand Down
58 changes: 29 additions & 29 deletions server/utils/mixerConnections/CasparCGConnection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ export class CasparCGConnection {
][vuChannelIndex]
) {
const faderIndex =
state.channels[0].chConnection[
state.channels[0].chMixerConnection[
this.mixerIndex
].channel[channelIndex].assignedFader
sendVuLevel(
Expand Down Expand Up @@ -228,7 +228,7 @@ export class CasparCGConnection {
}

// Restore mixer values to the ones we have internally
state.channels[0].chConnection[this.mixerIndex].channel.forEach(
state.channels[0].chMixerConnection[this.mixerIndex].channel.forEach(
(channel: IChannel, index) => {
// const fader = state.faders[0].fader[channel.assignedFader]
this.updateFadeIOLevel(index, channel.outputLevel)
Expand Down Expand Up @@ -379,11 +379,11 @@ export class CasparCGConnection {
}
logger.verbose('Update PFL state for ' + channelIndex)
const channel: IChannel =
state.channels[0].chConnection[this.mixerIndex].channel[
state.channels[0].chMixerConnection[this.mixerIndex].channel[
channelIndex
]
const fader: IFader = state.faders[0].fader[channel.assignedFader]
const otherFaders: Array<IFader> = state.channels[0].chConnection[
const otherFaders: Array<IFader> = state.channels[0].chMixerConnection[
this.mixerIndex
].channel
.filter((_ch: any, i: number) => i !== channelIndex)
Expand All @@ -399,7 +399,7 @@ export class CasparCGConnection {
)
// Ensure that all other non-SOLO channels are muted on MONITOR
// const others = state.channels[0].chConnection[this.mixerIndex].channel.map((ch: IChannel) => state.faders[0].fader[ch.assignedFader].pflOn ? undefined : index)
const others = state.channels[0].chConnection[
const others = state.channels[0].chMixerConnection[
this.mixerIndex
].channel
.map((ch: IChannel, index: number) =>
Expand Down Expand Up @@ -437,25 +437,24 @@ 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[this.mixerIndex].channel.forEach(
(_ch: IChannel, index: number) => {
if (
index >
this.mixerProtocol.toMixer.PFL_AUX_FADER_LEVEL
.length -
1
) {
return
}
const pairs = this.mixerProtocol.toMixer
.PFL_AUX_FADER_LEVEL[index]
this.setAllLayers(
pairs,
state.channels[0].chConnection[this.mixerIndex]
.channel[index].outputLevel
)
state.channels[0].chMixerConnection[
this.mixerIndex
].channel.forEach((_ch: IChannel, index: number) => {
if (
index >
this.mixerProtocol.toMixer.PFL_AUX_FADER_LEVEL.length -
1
) {
return
}
)
const pairs = this.mixerProtocol.toMixer
.PFL_AUX_FADER_LEVEL[index]
this.setAllLayers(
pairs,
state.channels[0].chMixerConnection[this.mixerIndex]
.channel[index].outputLevel
)
})
}
}
}
Expand All @@ -474,7 +473,7 @@ export class CasparCGConnection {
logger.verbose('Update NEXT AUX for ' + channelIndex)
if (this.mixerProtocol.toMixer.NEXT_AUX_FADER_LEVEL) {
const faderIndex: number =
state.channels[0].chConnection[this.mixerIndex].channel[
state.channels[0].chMixerConnection[this.mixerIndex].channel[
channelIndex
].assignedFader
if (state.faders[0].fader[faderIndex].pstOn === true) {
Expand Down Expand Up @@ -502,15 +501,16 @@ export class CasparCGConnection {
updateInputSelector(channelIndex: number, inputSelected: number) {
if (
this.mixerProtocol.toMixer.CHANNEL_INPUT_SELECTOR &&
state.channels[0].chConnection[this.mixerIndex].channel[
state.channels[0].chMixerConnection[this.mixerIndex].channel[
channelIndex
].private
) {
const pair = this.mixerProtocol.sourceOptions.sources[channelIndex]
const producer = state.channels[0].chConnection[this.mixerIndex]
.channel[channelIndex].private!['producer']
const producer = state.channels[0].chMixerConnection[
this.mixerIndex
].channel[channelIndex].private!['producer']
let filePath = String(
state.channels[0].chConnection[this.mixerIndex].channel[
state.channels[0].chMixerConnection[this.mixerIndex].channel[
channelIndex
].private!['file_path']
)
Expand Down Expand Up @@ -547,7 +547,7 @@ export class CasparCGConnection {
)

const faderIndex: number =
state.channels[0].chConnection[this.mixerIndex].channel[
state.channels[0].chMixerConnection[this.mixerIndex].channel[
channelIndex
].assignedFader
const pgmPairs = this.mixerProtocol.toMixer.PGM_CHANNEL_FADER_LEVEL[
Expand Down
Loading

0 comments on commit fc22e4e

Please sign in to comment.