From f01291b451fcce6a7eac8f13de44918ddda89180 Mon Sep 17 00:00:00 2001 From: olzzon Date: Sun, 10 May 2020 14:14:47 +0200 Subject: [PATCH] feat: Vista - 2way MUTE support --- .../mixerProtocols/StuderVistaEmber.ts | 5 +- .../StuderVistaMixerConnection.ts | 97 ++++++++++++++++--- 2 files changed, 83 insertions(+), 19 deletions(-) diff --git a/server/constants/mixerProtocols/StuderVistaEmber.ts b/server/constants/mixerProtocols/StuderVistaEmber.ts index d7ef7b97..3e3a8d71 100644 --- a/server/constants/mixerProtocols/StuderVistaEmber.ts +++ b/server/constants/mixerProtocols/StuderVistaEmber.ts @@ -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, @@ -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, diff --git a/server/utils/mixerConnections/StuderVistaMixerConnection.ts b/server/utils/mixerConnections/StuderVistaMixerConnection.ts index 53ce9001..81d2cf76 100644 --- a/server/utils/mixerConnections/StuderVistaMixerConnection.ts +++ b/server/utils/mixerConnections/StuderVistaMixerConnection.ts @@ -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 @@ -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, @@ -247,7 +259,7 @@ export class StuderVistaMixerConnection { } } - convertEmberCommand( + convertEmberLevelCommand( message: string, protocolMessage: string ): { @@ -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,