Skip to content

Commit

Permalink
feat: Vista - 2way MUTE support
Browse files Browse the repository at this point in the history
  • Loading branch information
olzzon authored and olzzon committed May 10, 2020
1 parent d2a38b2 commit f01291b
Show file tree
Hide file tree
Showing 2 changed files with 83 additions and 19 deletions.
5 changes: 2 additions & 3 deletions server/constants/mixerProtocols/StuderVistaEmber.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export const StuderVistaMaster: IMixerProtocol = {
fromMixer: {
CHANNEL_OUT_GAIN: [
{
mixerMessage: 'a1 a1 {ch-type} {channel} a1 a2',
mixerMessage: 'a1 a1 {ch-type} {channel} a1 a2 e1',
value: 0,
type: 'real',
min: -90,
Expand Down Expand Up @@ -70,8 +70,7 @@ export const StuderVistaMaster: IMixerProtocol = {
],
CHANNEL_MUTE_ON: [
{
mixerMessage:
'7f 8f ff fe d9 5c 80 30 80 a1 23 31 21 a1 1f 31 1d a1 1b 31 19 a1 17 31 15 {channel} 13 31 11 a1 0f 31 0d a2 0b 31 09 e2 07 31 05 63 03 02 01 01 00 00 00 00',
mixerMessage: 'a1 a1 {ch-type} {channel} a1 a2 e2',
value: 0,
type: 'real',
min: -90,
Expand Down
97 changes: 81 additions & 16 deletions server/utils/mixerConnections/StuderVistaMixerConnection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export class StuderVistaMixerConnection {
value,
argument,
commandValid,
} = this.convertEmberCommand(
} = this.convertEmberLevelCommand(
message,
this.mixerProtocol.channelTypes[0].fromMixer
.CHANNEL_OUT_GAIN[0].mixerMessage
Expand Down Expand Up @@ -176,27 +176,39 @@ export class StuderVistaMixerConnection {
)
) {
let {
channeltypeIndex: channel,
channeltypeIndex,
channelType,
value,
argument,
mute,
commandValid,
} = this.convertEmberCommand(
} = this.convertEmberMuteCommand(
message,
this.mixerProtocol.channelTypes[0].fromMixer
.CHANNEL_MUTE_ON[0].mixerMessage
)
let mute = 0 // message === 0 ? 1 : 0
store.dispatch({
type: SET_MUTE,
channel:
state.channels[0].channel[channel - 1]
.assignedFader,
muteOn: mute,
})
global.mainThreadHandler.updatePartialStore(
state.channels[0].channel[channel - 1].assignedFader
let channelArrayIndex = 0
let { assignedFader } = state.channels[0].channel.find(
(channel: IChannel, index: number) => {
if (
channel.channelType === channelType &&
channel.channelTypeIndex === channeltypeIndex
) {
channelArrayIndex = index
return true
}
}
)
if (
!state.channels[0].channel[channelArrayIndex].fadeActive
) {
store.dispatch({
type: SET_MUTE,
channel: assignedFader,
muteOn: mute,
})
global.mainThreadHandler.updatePartialStore(
assignedFader
)
}
} else {
logger.verbose(
'Unknown Vista message message: ' + message,
Expand Down Expand Up @@ -247,7 +259,7 @@ export class StuderVistaMixerConnection {
}
}

convertEmberCommand(
convertEmberLevelCommand(
message: string,
protocolMessage: string
): {
Expand Down Expand Up @@ -319,6 +331,59 @@ export class StuderVistaMixerConnection {
}
}

convertEmberMuteCommand(
message: string,
protocolMessage: string
): {
channeltypeIndex: number
channelType: number
mute: boolean
commandValid: boolean
} {
let messageArray = message.split('31 ')
let protocolArray = protocolMessage.split(' ')

let channelTypeIndex: number = 0
let channelType: number = 0
let mute: boolean = false
let commandValid: boolean = true

// Extract Channel number and Channel Type (mono-st-51)
protocolArray.forEach((value: string, index: number) => {
if (value === '{channel}') {
channelTypeIndex =
parseInt(messageArray[index + 1].split(' ')[1], 16) -
160 -
1
} else if (value === '{ch-type}') {
channelType =
parseInt(messageArray[index + 1].split(' ')[1], 16) -
160 -
1
}
})
// Extract Mute state:
mute =
parseInt(messageArray[messageArray.length - 1].split(' ')[5]) === 1
? true
: false

console.log(
'Channel :',
channelTypeIndex,
'Channel Type:',
channelType,
'Mute :',
mute
)
return {
channeltypeIndex: channelTypeIndex,
channelType: channelType,
mute: mute,
commandValid: commandValid,
}
}

mixerOnline(state: boolean) {
store.dispatch({
type: SET_MIXER_ONLINE,
Expand Down

0 comments on commit f01291b

Please sign in to comment.