Skip to content

Commit

Permalink
feat: implemented Midas support for multiple meters based on the assi…
Browse files Browse the repository at this point in the history
…gned channels to a fader. ToDo full support for multiple mixers
  • Loading branch information
olzzon committed Mar 22, 2021
1 parent 73749ab commit 01a6e36
Show file tree
Hide file tree
Showing 7 changed files with 90 additions and 24 deletions.
22 changes: 10 additions & 12 deletions client/components/Channel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ import VuMeter from './VuMeter'
import { Store, compose } from 'redux'
import Nouislider from 'nouislider-react'
import '../assets/css/NoUiSlider.css'
import { vuMeters } from '../utils/SocketClientHandlers'


//assets:
import '../assets/css/Channel.css'
Expand All @@ -20,7 +18,7 @@ import {
SOCKET_TOGGLE_IGNORE,
SOCKET_TOGGLE_AMIX,
} from '../../server/constants/SOCKET_IO_DISPATCHERS'
import { IFader } from '../../server/reducers/fadersReducer'
import { IChannelReference, IFader } from '../../server/reducers/fadersReducer'
import { ISettings } from '../../server/reducers/settingsReducer'
import { storeShowChanStrip } from '../../server/reducers/settingsActions'
import { withTranslation } from 'react-i18next'
Expand Down Expand Up @@ -151,17 +149,17 @@ class Channel extends React.Component<
</React.Fragment>
)
} else {
let assignedChannels: number[] = this.props.fader.assignedChannels || [1]
let assignedChannels: IChannelReference[] = this.props.fader
.assignedChannels || [{ mixerIndex: 0, channelIndex: 0 }]
return (
<React.Fragment>
{!window.location.search.includes('vu=0') && assignedChannels?.map(
(_, i) => (
<VuMeter
faderIndex={this.faderIndex}
channel={i}
/>
)
)}{' '}
{!window.location.search.includes('vu=0') &&
assignedChannels?.map((assigned: IChannelReference, index) => (
<VuMeter
faderIndex={this.faderIndex}
channel={index}
/>
))}{' '}
</React.Fragment>
)
}
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,13 @@
"winston-elasticsearch": "^0.15.2"
},
"devDependencies": {
"@babel/core": "^7.13.10",
"@babel/preset-typescript": "^7.13.0",
"@types/classnames": "^2.2.11",
"@types/hoist-non-react-statics": "^3.3.1",
"@types/jest": "^26.0.20",
"@types/jquery": "^3.5.5",
"@types/node": "^14.14.35",
"@types/rc-slider": "^8.6.6",
"@types/react-redux": "^7.1.16",
"@types/react-select": "^4.0.13",
Expand Down
23 changes: 23 additions & 0 deletions server/MainThreadHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ import {
storeToggleAMix,
storeAllManual,
storeInputSelector,
removeAllAssignedChannels,
storeSetAssignedChannel,
} from './reducers/faderActions'
import {
storeSetAssignedFader,
Expand All @@ -98,10 +100,12 @@ export class MainThreadHandlers {
}

updateFullClientStore() {
this.recalcAssignedChannels()
socketServer.emit(SOCKET_SET_FULL_STORE, state)
}

updatePartialStore(faderIndex: number) {
this.recalcAssignedChannels()
socketServer.emit(SOCKET_SET_STORE_FADER, {
faderIndex: faderIndex,
state: state.faders[0].fader[faderIndex],
Expand All @@ -128,6 +132,24 @@ export class MainThreadHandlers {
})
}

recalcAssignedChannels() {
store.dispatch(removeAllAssignedChannels())
state.channels[0].chMixerConnection.forEach((mixer, mixerIndex) => {
mixer.channel.forEach((channel: IChannel, channelIndex) => {
if (channel.assignedFader >= 0) {
store.dispatch(
storeSetAssignedChannel(
channel.assignedFader,
mixerIndex,
channelIndex,
true
)
)
}
})
})
}

socketServerHandlers(socket: any) {
logger.info('SETTING UP SOCKET IO MAIN HANDLERS', {})

Expand Down Expand Up @@ -262,6 +284,7 @@ export class MainThreadHandlers {
payload.faderAssign
)
)

this.updateFullClientStore()
})
.on(SOCKET_SET_FADER_MONITOR, (payload: any) => {
Expand Down
9 changes: 9 additions & 0 deletions server/reducers/faderActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export const SET_CHANNEL_LABEL = 'SET_CHANNEL_LABEL'
export const SET_FADER_FX = 'SET_FADER_FX'
export const SET_FADER_MONITOR = 'SET_FADER_MONITOR'
export const SET_ASSIGNED_CHANNEL = 'SET_ASSIGNED_CHANNEL'
export const REMOVE_ALL_ASSIGNED_CHANNELS = 'REMOVE_ASSIGNED_CHANNELS'
export const TOGGLE_PGM = 'TOGGLE_PGM'
export const SET_PGM = 'SET_PGM'
export const TOGGLE_VO = 'TOGGLE_VO'
Expand Down Expand Up @@ -273,14 +274,22 @@ export const storeSetAMix = (faderIndex: number, state: boolean) => {
}
}

export const removeAllAssignedChannels = () => {
return {
type: REMOVE_ALL_ASSIGNED_CHANNELS,
}
}

export const storeSetAssignedChannel = (
faderIndex: number,
mixerIndex: number,
channelIndex: number,
assigned: boolean
) => {
return {
type: SET_ASSIGNED_CHANNEL,
faderIndex: faderIndex,
mixerIndex: mixerIndex,
channelIndex: channelIndex,
assigned: assigned,
}
Expand Down
38 changes: 30 additions & 8 deletions server/reducers/fadersReducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,19 @@ import {
SET_CAPABILITY,
TOGGLE_ALL_MANUAL,
SET_ASSIGNED_CHANNEL,
REMOVE_ALL_ASSIGNED_CHANNELS,
} from '../reducers/faderActions'

export interface IFaders {
fader: Array<IFader>
vuMeters: Array<IVuMeters>
}

export interface IChannelReference {
mixerIndex: number
channelIndex: number
}

export interface IFader {
faderLevel: number
inputGain: number
Expand All @@ -57,7 +63,7 @@ export interface IFader {
showInMiniMonitor: boolean
ignoreAutomation: boolean
disabled: boolean
assignedChannels?: number[]
assignedChannels?: IChannelReference[]

/**
* Assuming that the protocol has a "feature", can it be enabled on this fader?
Expand Down Expand Up @@ -299,22 +305,38 @@ export const faders = (
case SET_AMIX: //channel
nextState[0].fader[action.faderIndex].amixOn = action.state
return nextState
case REMOVE_ALL_ASSIGNED_CHANNELS: //channel
nextState[0].fader.forEach((fader) => {
fader.assignedChannels = []
})
return nextState
case SET_ASSIGNED_CHANNEL:
if (action.assigned) {
let assignedChannels =
nextState[0].fader[action.faderIndex].assignedChannels
assignedChannels.push(action.channelIndex)
assignedChannels.sort((a: number, b: number) => a)
let assignedChannels: IChannelReference[] =
nextState[0].fader[action.faderIndex].assignedChannels || []
assignedChannels.push({
mixerIndex: action.mixerIndex,
channelIndex: action.channelIndex,
})
assignedChannels.sort(
(n1: IChannelReference, n2: IChannelReference) =>
n1.channelIndex - n2.channelIndex
)
nextState[0].fader[
action.faderIndex
].assignedChannels = assignedChannels
} else {
let assignedChannels =
nextState[0].fader[action.faderIndex].assignedChannels
if (
assignedChannels.find((channel: number, index: number) => {
return channel === action.channelIndex
})
assignedChannels.find(
(channelReference: IChannelReference) => {
return (
channelReference.channelIndex ===
action.channelIndex
)
}
)
) {
assignedChannels = assignedChannels.filter((channel) => {
return channel !== action.channelIndex
Expand Down
16 changes: 14 additions & 2 deletions server/utils/mixerConnections/productSpecific/midas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,25 @@ export const midasMeter = (mixerIndex: number, message: any) => {
assignedFader =
state.channels[0].chMixerConnection[mixerIndex].channel[i]
.assignedFader
if (assignedFader < state.settings[0].numberOfFaders) {
if (
assignedFader >= 0 &&
assignedFader < state.settings[0].numberOfFaders
) {
level = dataview.getFloat32(4 * i + DATA_OFFSET, true)
reductionLevel = dataview.getFloat32(
4 * (i + 64) + DATA_OFFSET,
true
)
sendVuLevel(assignedFader, VuType.Channel, 0, level)
let vuIndex: number = state.faders[0].fader[
assignedFader
].assignedChannels?.findIndex((assigned) => {
return (
assigned.mixerIndex === mixerIndex &&
assigned.channelIndex === i
)
})
if (vuIndex === -1) vuIndex = 0
sendVuLevel(assignedFader, VuType.Channel, vuIndex, level)
sendVuLevel(assignedFader, VuType.Reduction, 0, 1 - reductionLevel)
}
}
Expand Down
4 changes: 2 additions & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
resolved "https://registry.yarnpkg.com/@babel/compat-data/-/compat-data-7.13.11.tgz#9c8fe523c206979c9a81b1e12fe50c1254f1aa35"
integrity sha512-BwKEkO+2a67DcFeS3RLl0Z3Gs2OvdXewuWjc1Hfokhb5eQWP9YRYH1/+VrVZvql2CfjOiNGqSAFOYt4lsqTHzg==

"@babel/core@^7.1.0", "@babel/core@^7.7.5":
"@babel/core@^7.1.0", "@babel/core@^7.13.10", "@babel/core@^7.7.5":
version "7.13.10"
resolved "https://registry.yarnpkg.com/@babel/core/-/core-7.13.10.tgz#07de050bbd8193fcd8a3c27918c0890613a94559"
integrity sha512-bfIYcT0BdKeAZrovpMqX2Mx5NrgAckGbwT982AkdS5GNfn3KMGiprlBAtmBcFZRUmpaufS6WZFP8trvx8ptFDw==
Expand Down Expand Up @@ -771,7 +771,7 @@
resolved "https://registry.yarnpkg.com/@types/minimist/-/minimist-1.2.1.tgz#283f669ff76d7b8260df8ab7a4262cc83d988256"
integrity sha512-fZQQafSREFyuZcdWFAExYjBiCL7AUCdgsk80iO0q4yihYYdcIiH28CcuPTGFgLOCC8RlW49GSQxdHwZP+I7CNg==

"@types/node@*", "@types/node@>=10.0.0":
"@types/node@*", "@types/node@>=10.0.0", "@types/node@^14.14.35":
version "14.14.35"
resolved "https://registry.yarnpkg.com/@types/node/-/node-14.14.35.tgz#42c953a4e2b18ab931f72477e7012172f4ffa313"
integrity sha512-Lt+wj8NVPx0zUmUwumiVXapmaLUcAk3yPuHCFVXras9k5VT9TdhJqKqGVUQCD60OTMCl0qxJ57OiTL0Mic3Iag==
Expand Down

0 comments on commit 01a6e36

Please sign in to comment.