Skip to content

Commit

Permalink
feat/offtube: receive aux level from X32
Browse files Browse the repository at this point in the history
chore: rewrite checkOscCommand
  • Loading branch information
olzzon committed Nov 27, 2019
1 parent 182d442 commit 69b1953
Show file tree
Hide file tree
Showing 13 changed files with 70 additions and 50 deletions.
4 changes: 2 additions & 2 deletions src/constants/MixerProtocolInterface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export interface IChannelTypes {
LOW: Array<IMixerMessageProtocol>
MID: Array<IMixerMessageProtocol>
HIGH: Array<IMixerMessageProtocol>
MONITOR: Array<IMixerMessageProtocol>
AUX_LEVEL: Array<IMixerMessageProtocol>
CHANNEL_MUTE_ON: Array<IMixerMessageProtocol>
CHANNEL_MUTE_OFF: Array<IMixerMessageProtocol>
},
Expand All @@ -56,7 +56,7 @@ export interface IChannelTypes {
LOW: Array<IMixerMessageProtocol>
MID: Array<IMixerMessageProtocol>
HIGH: Array<IMixerMessageProtocol>
MONITOR: Array<IMixerMessageProtocol>
AUX_LEVEL: Array<IMixerMessageProtocol>
CHANNEL_MUTE_ON: Array<IMixerMessageProtocol>
CHANNEL_MUTE_OFF: Array<IMixerMessageProtocol>
}
Expand Down
4 changes: 2 additions & 2 deletions src/constants/mixerProtocols/DmxIs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export const DMXIS: IMixerProtocol = {
LOW: [emptyMixerMessage()],
MID: [emptyMixerMessage()],
HIGH: [emptyMixerMessage()],
MONITOR: [emptyMixerMessage()],
AUX_LEVEL: [emptyMixerMessage()],
CHANNEL_MUTE_ON: [emptyMixerMessage()],
CHANNEL_MUTE_OFF: [emptyMixerMessage()]
},
Expand All @@ -41,7 +41,7 @@ export const DMXIS: IMixerProtocol = {
LOW: [emptyMixerMessage()],
MID: [emptyMixerMessage()],
HIGH: [emptyMixerMessage()],
MONITOR: [emptyMixerMessage()],
AUX_LEVEL: [emptyMixerMessage()],
CHANNEL_MUTE_ON: [emptyMixerMessage()],
CHANNEL_MUTE_OFF: [emptyMixerMessage()]
},
Expand Down
4 changes: 2 additions & 2 deletions src/constants/mixerProtocols/EmberLawo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export const LawoClient: IMixerProtocol = {
LOW: [emptyMixerMessage()],
MID: [emptyMixerMessage()],
HIGH: [emptyMixerMessage()],
MONITOR: [emptyMixerMessage()],
AUX_LEVEL: [emptyMixerMessage()],
CHANNEL_MUTE_ON: [emptyMixerMessage()],
CHANNEL_MUTE_OFF: [emptyMixerMessage()]
},
Expand Down Expand Up @@ -82,7 +82,7 @@ export const LawoClient: IMixerProtocol = {
LOW: [emptyMixerMessage()],
MID: [emptyMixerMessage()],
HIGH: [emptyMixerMessage()],
MONITOR: [emptyMixerMessage()],
AUX_LEVEL: [emptyMixerMessage()],
CHANNEL_MUTE_ON: [emptyMixerMessage()],
CHANNEL_MUTE_OFF: [emptyMixerMessage()]
}
Expand Down
4 changes: 2 additions & 2 deletions src/constants/mixerProtocols/SSLsystemT.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export const SSLSystemT: IMixerProtocol = {
LOW: [emptyMixerMessage()],
MID: [emptyMixerMessage()],
HIGH: [emptyMixerMessage()],
MONITOR: [emptyMixerMessage()],
AUX_LEVEL: [emptyMixerMessage()],
CHANNEL_MUTE_ON: [{ mixerMessage: "f1 04 00 01 00 {channel}", value: 0, type: '', min: 0, max: 1, zero: 0.75}],
CHANNEL_MUTE_OFF: [emptyMixerMessage()]
},
Expand All @@ -41,7 +41,7 @@ export const SSLSystemT: IMixerProtocol = {
LOW: [emptyMixerMessage()],
MID: [emptyMixerMessage()],
HIGH: [emptyMixerMessage()],
MONITOR: [emptyMixerMessage()],
AUX_LEVEL: [emptyMixerMessage()],
CHANNEL_MUTE_ON: [{ mixerMessage: "f1 05 00 80 01 {channel} 00", value: 0, type: '', min: 0, max: 1, zero: 0.75}],
CHANNEL_MUTE_OFF: [{ mixerMessage: "f1 05 00 80 01 {channel} 01", value: 0, type: '', min: 0, max: 1, zero: 0.75}]
},
Expand Down
12 changes: 6 additions & 6 deletions src/constants/mixerProtocols/StuderVistaEmber.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export const StuderVistaMaster: IMixerProtocol = {
LOW: [emptyMixerMessage()],
MID: [emptyMixerMessage()],
HIGH: [emptyMixerMessage()],
MONITOR: [emptyMixerMessage()],
AUX_LEVEL: [emptyMixerMessage()],
CHANNEL_MUTE_ON: [emptyMixerMessage()],
CHANNEL_MUTE_OFF: [emptyMixerMessage()]
},
Expand Down Expand Up @@ -73,7 +73,7 @@ export const StuderVistaMaster: IMixerProtocol = {
LOW: [emptyMixerMessage()],
MID: [emptyMixerMessage()],
HIGH: [emptyMixerMessage()],
MONITOR: [emptyMixerMessage()],
AUX_LEVEL: [emptyMixerMessage()],
CHANNEL_MUTE_ON: [emptyMixerMessage()],
CHANNEL_MUTE_OFF: [emptyMixerMessage()]
},
Expand Down Expand Up @@ -107,7 +107,7 @@ export const StuderVistaMaster: IMixerProtocol = {
LOW: [emptyMixerMessage()],
MID: [emptyMixerMessage()],
HIGH: [emptyMixerMessage()],
MONITOR: [emptyMixerMessage()],
AUX_LEVEL: [emptyMixerMessage()],
CHANNEL_MUTE_ON: [emptyMixerMessage()],
CHANNEL_MUTE_OFF: [emptyMixerMessage()]
},
Expand Down Expand Up @@ -138,7 +138,7 @@ export const StuderVistaMaster: IMixerProtocol = {
LOW: [emptyMixerMessage()],
MID: [emptyMixerMessage()],
HIGH: [emptyMixerMessage()],
MONITOR: [emptyMixerMessage()],
AUX_LEVEL: [emptyMixerMessage()],
CHANNEL_MUTE_ON: [emptyMixerMessage()],
CHANNEL_MUTE_OFF: [emptyMixerMessage()]
},
Expand Down Expand Up @@ -172,7 +172,7 @@ export const StuderVistaMaster: IMixerProtocol = {
LOW: [emptyMixerMessage()],
MID: [emptyMixerMessage()],
HIGH: [emptyMixerMessage()],
MONITOR: [emptyMixerMessage()],
AUX_LEVEL: [emptyMixerMessage()],
CHANNEL_MUTE_ON: [emptyMixerMessage()],
CHANNEL_MUTE_OFF: [emptyMixerMessage()]
},
Expand Down Expand Up @@ -203,7 +203,7 @@ export const StuderVistaMaster: IMixerProtocol = {
LOW: [emptyMixerMessage()],
MID: [emptyMixerMessage()],
HIGH: [emptyMixerMessage()],
MONITOR: [emptyMixerMessage()],
AUX_LEVEL: [emptyMixerMessage()],
CHANNEL_MUTE_ON: [emptyMixerMessage()],
CHANNEL_MUTE_OFF: [emptyMixerMessage()]
},
Expand Down
4 changes: 2 additions & 2 deletions src/constants/mixerProtocols/ardourMaster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export const ArdourMaster: IMixerProtocol = {
LOW: [emptyMixerMessage()],
MID: [emptyMixerMessage()],
HIGH: [emptyMixerMessage()],
MONITOR: [emptyMixerMessage()],
AUX_LEVEL: [emptyMixerMessage()],
CHANNEL_MUTE_ON: [emptyMixerMessage()],
CHANNEL_MUTE_OFF: [emptyMixerMessage()]
},
Expand All @@ -68,7 +68,7 @@ export const ArdourMaster: IMixerProtocol = {
LOW: [emptyMixerMessage()],
MID: [emptyMixerMessage()],
HIGH: [emptyMixerMessage()],
MONITOR: [emptyMixerMessage()],
AUX_LEVEL: [emptyMixerMessage()],
CHANNEL_MUTE_ON: [emptyMixerMessage()],
CHANNEL_MUTE_OFF: [emptyMixerMessage()]
}
Expand Down
4 changes: 2 additions & 2 deletions src/constants/mixerProtocols/behringerXrMaster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export const BehringerXrMaster: IMixerProtocol = {
LOW: [emptyMixerMessage()],
MID: [emptyMixerMessage()],
HIGH: [emptyMixerMessage()],
MONITOR: [emptyMixerMessage()],
AUX_LEVEL: [emptyMixerMessage()],
CHANNEL_MUTE_ON: [emptyMixerMessage()],
CHANNEL_MUTE_OFF: [emptyMixerMessage()]
},
Expand All @@ -63,7 +63,7 @@ export const BehringerXrMaster: IMixerProtocol = {
LOW: [emptyMixerMessage()],
MID: [emptyMixerMessage()],
HIGH: [emptyMixerMessage()],
MONITOR: [emptyMixerMessage()],
AUX_LEVEL: [emptyMixerMessage()],
CHANNEL_MUTE_ON: [emptyMixerMessage()],
CHANNEL_MUTE_OFF: [emptyMixerMessage()]
},
Expand Down
4 changes: 2 additions & 2 deletions src/constants/mixerProtocols/casparCGMaster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ if (geometry) {
LOW: [emptyMixerMessage()],
MID: [emptyMixerMessage()],
HIGH: [emptyMixerMessage()],
MONITOR: [emptyMixerMessage()],
AUX_LEVEL: [emptyMixerMessage()],
CHANNEL_MUTE_ON: [emptyMixerMessage()],
CHANNEL_MUTE_OFF: [emptyMixerMessage()]
},
Expand All @@ -79,7 +79,7 @@ if (geometry) {
LOW: [emptyMixerMessage()],
MID: [emptyMixerMessage()],
HIGH: [emptyMixerMessage()],
MONITOR: [emptyMixerMessage()],
AUX_LEVEL: [emptyMixerMessage()],
CHANNEL_MUTE_ON: [emptyMixerMessage()],
CHANNEL_MUTE_OFF: [emptyMixerMessage()]
},
Expand Down
4 changes: 2 additions & 2 deletions src/constants/mixerProtocols/genericMidi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export const GenericMidi: IMixerProtocol = {
LOW: [emptyMixerMessage()],
MID: [emptyMixerMessage()],
HIGH: [emptyMixerMessage()],
MONITOR: [emptyMixerMessage()],
AUX_LEVEL: [emptyMixerMessage()],
CHANNEL_MUTE_ON: [emptyMixerMessage()],
CHANNEL_MUTE_OFF: [emptyMixerMessage()]
},
Expand All @@ -41,7 +41,7 @@ export const GenericMidi: IMixerProtocol = {
LOW: [emptyMixerMessage()],
MID: [emptyMixerMessage()],
HIGH: [emptyMixerMessage()],
MONITOR: [emptyMixerMessage()],
AUX_LEVEL: [emptyMixerMessage()],
CHANNEL_MUTE_ON: [emptyMixerMessage()],
CHANNEL_MUTE_OFF: [emptyMixerMessage()]
},
Expand Down
4 changes: 2 additions & 2 deletions src/constants/mixerProtocols/midasMaster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export const MidasMaster: IMixerProtocol = {
LOW: [{ mixerMessage: '/ch/{channel}/eq/2/g', value: 0, type: 'f', min: 0, max: 1, zero: 0}],
MID: [{ mixerMessage: '/ch/{channel}/eq/3/g', value: 0, type: 'f', min: 0, max: 1, zero: 0}],
HIGH: [{ mixerMessage: '/ch/{channel}/eq/4/g', value: 0, type: 'f', min: 0, max: 1, zero: 0}],
MONITOR: [{mixerMessage: '/ch/{channel}/mix/{argument1}/level', value: 0, type: 'f', min: 0, max: 1, zero: 0}],
AUX_LEVEL: [{mixerMessage: '/ch/{channel}/mix/{argument}/level', value: 0, type: 'f', min: 0, max: 1, zero: 0}],
CHANNEL_MUTE_ON: [emptyMixerMessage()],
CHANNEL_MUTE_OFF: [emptyMixerMessage()]
},
Expand All @@ -81,7 +81,7 @@ export const MidasMaster: IMixerProtocol = {
LOW: [{ mixerMessage: '/ch/{channel}/eq/2/g', value: 0, type: 'f', min: 0, max: 1, zero: 0}],
MID: [{ mixerMessage: '/ch/{channel}/eq/3/g', value: 0, type: 'f', min: 0, max: 1, zero: 0}],
HIGH: [{ mixerMessage: '/ch/{channel}/eq/4/g', value: 0, type: 'f', min: 0, max: 1, zero: 0}],
MONITOR: [{mixerMessage: '/ch/{channel}/mix/{argument1}/level', value: 0, type: 'f', min: 0, max: 1, zero: 0}],
AUX_LEVEL: [{mixerMessage: '/ch/{channel}/mix/{argument}/level', value: 0, type: 'f', min: 0, max: 1, zero: 0}],
CHANNEL_MUTE_ON: [emptyMixerMessage()],
CHANNEL_MUTE_OFF: [emptyMixerMessage()]
},
Expand Down
8 changes: 4 additions & 4 deletions src/constants/mixerProtocols/reaperMaster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export const ReaperMaster: IMixerProtocol = {
LOW: [emptyMixerMessage()],
MID: [emptyMixerMessage()],
HIGH: [emptyMixerMessage()],
MONITOR: [emptyMixerMessage()],
AUX_LEVEL: [emptyMixerMessage()],
CHANNEL_MUTE_ON: [emptyMixerMessage()],
CHANNEL_MUTE_OFF: [emptyMixerMessage()]
},
Expand Down Expand Up @@ -55,7 +55,7 @@ export const ReaperMaster: IMixerProtocol = {
LOW: [emptyMixerMessage()],
MID: [emptyMixerMessage()],
HIGH: [emptyMixerMessage()],
MONITOR: [emptyMixerMessage()],
AUX_LEVEL: [emptyMixerMessage()],
CHANNEL_MUTE_ON: [emptyMixerMessage()],
CHANNEL_MUTE_OFF: [emptyMixerMessage()]
},
Expand All @@ -78,7 +78,7 @@ export const ReaperMaster: IMixerProtocol = {
LOW: [emptyMixerMessage()],
MID: [emptyMixerMessage()],
HIGH: [emptyMixerMessage()],
MONITOR: [emptyMixerMessage()],
AUX_LEVEL: [emptyMixerMessage()],
CHANNEL_MUTE_ON: [emptyMixerMessage()],
CHANNEL_MUTE_OFF: [emptyMixerMessage()]
},
Expand All @@ -94,7 +94,7 @@ export const ReaperMaster: IMixerProtocol = {
LOW: [emptyMixerMessage()],
MID: [emptyMixerMessage()],
HIGH: [emptyMixerMessage()],
MONITOR: [emptyMixerMessage()],
AUX_LEVEL: [emptyMixerMessage()],
CHANNEL_MUTE_ON: [emptyMixerMessage()],
CHANNEL_MUTE_OFF: [emptyMixerMessage()]
},
Expand Down
4 changes: 2 additions & 2 deletions src/constants/mixerProtocols/yamahaQLCL.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export const YamahaQLCL: IMixerProtocol = {
LOW: [emptyMixerMessage()],
MID: [emptyMixerMessage()],
HIGH: [emptyMixerMessage()],
MONITOR: [emptyMixerMessage()],
AUX_LEVEL: [emptyMixerMessage()],
CHANNEL_MUTE_ON: [emptyMixerMessage()],
CHANNEL_MUTE_OFF: [emptyMixerMessage()]
},
Expand All @@ -41,7 +41,7 @@ export const YamahaQLCL: IMixerProtocol = {
LOW: [emptyMixerMessage()],
MID: [emptyMixerMessage()],
HIGH: [emptyMixerMessage()],
MONITOR: [emptyMixerMessage()],
AUX_LEVEL: [emptyMixerMessage()],
CHANNEL_MUTE_ON: [emptyMixerMessage()],
CHANNEL_MUTE_OFF: [emptyMixerMessage()]
},
Expand Down
60 changes: 40 additions & 20 deletions src/utils/OscMixerConnection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { IMixerProtocol } from '../constants/MixerProtocolInterface';
import { behringerMeter } from './productSpecific/behringer';
import { midasMeter } from './productSpecific/midas';
import { IStore } from '../reducers/indexReducer';
import { SET_OUTPUT_LEVEL } from '../reducers/channelActions'
import { SET_OUTPUT_LEVEL, SET_AUX_LEVEL } from '../reducers/channelActions'
import {
SET_VU_LEVEL,
SET_FADER_LEVEL,
Expand Down Expand Up @@ -143,6 +143,29 @@ export class OscMixerConnection {
window.huiRemoteConnection.updateRemoteFaderState(assignedFaderIndex, message.args[0]);
}
}
} else if ( this.checkOscCommand(message.address, this.mixerProtocol.channelTypes[0].fromMixer
.AUX_LEVEL[0].mixerMessage)){

let commandArray: string[] = this.mixerProtocol.channelTypes[0].fromMixer
.AUX_LEVEL[0].mixerMessage.split('/')
let messageArray: string[] = message.address.split('/')
let ch = 0
let auxIndex = 0

commandArray.forEach((commandPart: string, index: number) => {
if (commandPart === '{channel}') {
ch = parseFloat(messageArray[index])
} else if (commandPart === '{argument}') {
auxIndex = parseFloat(messageArray[index])
}
})

window.storeRedux.dispatch({
type: SET_AUX_LEVEL,
channel: ch - 1,
level: message.args[0]
});

} else if (this.checkOscCommand(message.address, this.mixerProtocol.channelTypes[0].fromMixer
.CHANNEL_NAME[0].mixerMessage)) {
let ch = message.address.split("/")[this.cmdChannelIndex];
Expand Down Expand Up @@ -195,25 +218,22 @@ export class OscMixerConnection {
}, this.mixerProtocol.pingTime)
}

checkOscCommand(message: string, command: string) {
checkOscCommand(message: string, command: string): boolean {
if (message === command) return true;
let messageArray: string[] = message.split('/')
let commandArray: string[] = command.split('/')

let cmdArray = command.split("{channel}");
if (message.substr(0, cmdArray[0].length) === cmdArray[0])
{
if (
message.substr(-cmdArray[1].length) === cmdArray[1] &&
message.length >= command.replace("{channel}", "").length
) {
return true;
} else if (
cmdArray[1] === "" &&
message.length >= command.replace("{channel}", "").length
) {
return true;
}
}
return false;
commandArray.forEach((commandPart: string, index: number) => {
if (commandPart === '{channel}') {
if (typeof(parseFloat(messageArray[index])) !== 'number') { return false }
} else if (commandPart === '{argument}') {
if (typeof(parseFloat(messageArray[index])) !== 'number') { return false }
} else if (commandPart !== messageArray[index]) {
return false
}
})

return true
}

sendOutMessage(oscMessage: string, channel: number, value: string | number, type: string) {
Expand Down Expand Up @@ -351,9 +371,9 @@ export class OscMixerConnection {
updateAuxLevel(channelIndex: number, auxSendIndex: number, level: number) {
let channelType = this.store.channels[0].channel[channelIndex].channelType;
let channel = this.store.channels[0].channel[channelIndex].channelTypeIndex+1
let auxSendCmd = this.mixerProtocol.channelTypes[channelType].toMixer.MONITOR[0]
let auxSendCmd = this.mixerProtocol.channelTypes[channelType].toMixer.AUX_LEVEL[0]
let auxSendNumber = this.mixerProtocol.leadingZeros ? ("0"+String(auxSendIndex + 1)).slice(-2) : String(auxSendIndex + 1);
let message = auxSendCmd.mixerMessage.replace('{argument1}', auxSendNumber)
let message = auxSendCmd.mixerMessage.replace('{argument}', auxSendNumber)

level = level * (auxSendCmd.max-auxSendCmd.min) + auxSendCmd.min
this.sendOutMessage(
Expand Down

0 comments on commit 69b1953

Please sign in to comment.