Skip to content

Commit

Permalink
feat: Vista 1-5-9 support fader level from Sisyfos on mono, st, and 5…
Browse files Browse the repository at this point in the history
….1 channels
  • Loading branch information
olzzon authored and olzzon committed Apr 20, 2020
1 parent c0e3469 commit 5cf60b4
Show file tree
Hide file tree
Showing 2 changed files with 83 additions and 21 deletions.
39 changes: 35 additions & 4 deletions server/constants/mixerProtocols/StuderVistaEmber.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,20 @@ export const StuderVistaMaster: IMixerProtocol = {
protocol: 'VISTA',
label: 'Studer Vista 1-5-9',
mode: "master",
FADE_DISPATCH_RESOLUTION: 50,
FADE_DISPATCH_RESOLUTION: 5,
leadingZeros: false, //some OSC protocols needs channels to be 01, 02 etc.
pingCommand: [emptyMixerMessage()],
// [127, 143, 255, 254, 217, 92, 128, 48, 128, 0, 0, 0, 0
// 7F 8F FF FE D9 5C 80 30 80 00 00 00 00
pingCommand: [{
mixerMessage: '7F 8F FF FE D9 5C 80 30 80 00 00 00 00',
value: 0,
type: 'real',
min: -90,
max: 10,
zero: 0
}],
pingResponseCommand: [emptyMixerMessage()],
pingTime: 0, //Bypass ping when pingTime is zero
pingTime: 6000, //Bypass ping when pingTime is zero
initializeCommands: [emptyMixerMessage()],
channelTypes: [{
channelTypeName: 'MONO',
Expand All @@ -32,7 +41,21 @@ export const StuderVistaMaster: IMixerProtocol = {
CHANNEL_MUTE_OFF: [emptyMixerMessage()]
},
toMixer: {
CHANNEL_OUT_GAIN: [{ // 7f 8f ff fe d9 5c 80 30 80 a1 25 31 23 a1 21 31 1f a1 1d 31 1b a1 19 31 17 {a3} 15 31 13 a1 11 31 0f a2 0d 31 0b e1 09 31 07 63 {05 09 03 c0 06 13 00 00 00 00}

/*
VSM gadget mono fader 1 level
0000 00 1b 21 c6 30 96 ac 16 2d 72 97 88 08 00 45 00
0010 00 5c 00 a3 40 00 80 06 00 00 0a e1 0f 0d 0a e1
0020 0f c4 d5 2a 1f 97 04 8c d9 46 a3 4d c7 d7 50 18
0030 00 fd 34 e1 00 00
*/

CHANNEL_OUT_GAIN: [{ // 7f 8f ff fe d9 5c 80 30 80 a1 25 31 23 a1 21 31 1f a1 1d 31 1b a1 19 31 17 {a3} 15 31 13 a1 11 31 0f a2 0d 31 0b e1 09 31 07 63 {05 09 03 c0 06 13 00 00 00 00}
mixerMessage: '7f 8f ff fe d9 5c 80 30 80 a1 25 31 23 a1 21 31 1f a1 1d 31 1b a1 19 31 17 {channel} 15 31 13 a1 11 31 0f a2 0d 31 0b e1 09 31 07 63 {level}',
value: 0,
type: 'real',
Expand Down Expand Up @@ -100,7 +123,15 @@ export const StuderVistaMaster: IMixerProtocol = {
CHANNEL_MUTE_OFF: [emptyMixerMessage()]
},
toMixer: {
/*
0000 00 1b 21 c6 30 96 ac 16 2d 72 97 88 08 00 45 00
0010 00 5c 39 93 40 00 80 06 00 00 0a e1 0f 0d 0a e1
0020 0f c4 f5 a8 1f 97 38 06 5f b9 53 17 12 6f 50 18
0030 01 00 34 e1 00 00
7f 8f ff fe d9 5c 80 30 80 a1 25 31 23 a1 21 31 1f a1 1d 31 1b a2 19 31 17 a1 15 31 13 a1 11 31 0f a2 0d 31 0b e1 09 31 07 63 05 09 03 c0 05 3b 00 00 00 00
*/
CHANNEL_OUT_GAIN: [{ // 7f 8f ff fe d9 5c 80 30 80 a1 25 31 23 a1 21 31 1f a1 1d 31 1b a2 19 31 17 b9 15 31 13 a1 11 31 0f a2 0d 31 0b e1 09 31 07 63 05 09 03 80 03 05 00 00 00 00
// 7f 8f ff fe d9 5c 80 30 80 a1 25 31 23 a1 21 31 1f a1 1d 31 1b a2 19 31 17 a1 15 31 13 a1 11 31 0f a2 0d 31 0b e1 09 31 07 63 05 09 03 c0 05 3b 00 00 00 00
mixerMessage: '7f 8f ff fe d9 5c 80 30 80 a1 25 31 23 a1 21 31 1f a1 1d 31 1b a2 19 31 17 {channel} 15 31 13 a1 11 31 0f a2 0d 31 0b e1 09 31 07 63 {level}',
value: 0,
type: 'real',
Expand Down
65 changes: 48 additions & 17 deletions server/utils/mixerConnections/StuderVistaMixerConnection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import { EmberClient, BER } from 'node-emberplus'
import { store, state } from '../../reducers/store'
import { huiRemoteConnection } from '../../mainClasses'
const net = require('net')

//Utils:
import { IMixerProtocol } from '../../constants/MixerProtocolInterface';
Expand All @@ -19,6 +20,7 @@ export class StuderVistaMixerConnection {
emberConnection: EmberClient
deviceRoot: any;
emberNodeObject: Array<any>;
socket: any

constructor(mixerProtocol: IMixerProtocol) {
this.sendOutMessage = this.sendOutMessage.bind(this);
Expand All @@ -32,6 +34,7 @@ export class StuderVistaMixerConnection {
state.settings[0].deviceIp,
state.settings[0].devicePort
);
/*
this.emberConnection.on('error', (error: any) => {
if (
(error.message + '').match(/econnrefused/i) ||
Expand All @@ -54,18 +57,52 @@ export class StuderVistaMixerConnection {
.catch((e: any) => {
console.log(e.stack);
});
*/
this.socket = net.createConnection(
{
port: 8087,
host: "10.225.15.196",
timeout: 20000000
},
() => {
// Disable connect timeout to hand-over to keepalive mechanism
// this.socket.setTimeout(20000000);
}
)
this.socket.on('data', (data: any) => {
console.log('Ember Server data recieved');
// this.socket.write(data)
})

// When connection disconnected.
this.socket.on('end',() => {
console.log('Ember Client socket disconnect. ');
})

this.socket.on('timeout', () => {
console.log('Ember Client connection timeout. ');
})

this.socket.on('error', (err: any) => {
console.error(JSON.stringify(err));
})

this.socket.on('connect', () => {
this.setupMixerConnection()
})
}

setupMixerConnection() {
logger.info('Ember connection established - setting up subscription of channels')

logger.info('Ember connection established')
/*
let ch: number = 1;
state.settings[0].numberOfChannelsInType.forEach((numberOfChannels, typeIndex) => {
for (let channelTypeIndex=0; channelTypeIndex < numberOfChannels ; channelTypeIndex++) {
this.subscribeFaderLevel(ch, typeIndex, channelTypeIndex);
ch++;
}
})
*/
/*
.CHANNEL_VU)){
store.dispatch({
Expand Down Expand Up @@ -133,16 +170,12 @@ export class StuderVistaMixerConnection {
}

pingMixerCommand() {
//Ping Ember mixer if mixerProtocol needs it.
return;
this.mixerProtocol.pingCommand.map((command) => {
this.sendOutMessage(
command.mixerMessage,
0,
command.value,
command.type
);
});
let hexArray = command.mixerMessage.split(' ')
let buf = new Buffer(hexArray.map((val:string) => { return parseInt(val, 16) }))
this.socket.write(buf)
console.log('WRITING PING TO MIXER')
})
}

sendOutMessage(mixerMessage: string, channel: number, value: string | number, type: string) {
Expand Down Expand Up @@ -194,11 +227,11 @@ export class StuderVistaMixerConnection {
bufferString += ('0' + element.toString(16)).slice(-2) + ' '
});
levelMessage = levelMessage.replace('{channel}', ('0' + channelByte[0].toString(16)).slice(-2))
levelMessage = levelMessage.replace('{level}', (bufferString + '00 00 00 00 00').slice(0, 32))
levelMessage = levelMessage.replace('{level}', (bufferString + '00 00 00 00 00').slice(3, 35))

let hexArray = levelMessage.split(' ')
let buf = new Buffer(hexArray.map((val:string) => { return parseInt(val, 16) }))
this.emberConnection._client.socket.write(buf)
this.socket.write(buf)
logger.verbose("Send HEX: " + levelMessage)
}

Expand All @@ -218,7 +251,6 @@ export class StuderVistaMixerConnection {
}

updateOutLevel(channelIndex: number) {
let channelTypeIndex = state.channels[0].channel[channelIndex].channelTypeIndex;
let outputlevel = state.channels[0].channel[channelIndex].outputLevel
let level = 20 * Math.log((1.3*outputlevel)/0.775)
if (level < -90) {
Expand All @@ -227,21 +259,20 @@ export class StuderVistaMixerConnection {
// console.log('Log level :', level)

this.sendOutLevelMessage(
channelTypeIndex+1,
channelIndex+1,
level,
);
}

updateFadeIOLevel(channelIndex: number, outputLevel: number) {
let channelTypeIndex = state.channels[0].channel[channelIndex].channelTypeIndex;
let level = 20 * Math.log((1.3*outputLevel)/0.775)
if (level < -90) {
level = -90
}
// console.log('Log level :', level)

this.sendOutLevelMessage(
channelTypeIndex+1,
channelIndex+1,
level
)
}
Expand Down

0 comments on commit 5cf60b4

Please sign in to comment.