Skip to content

Commit

Permalink
feat: channelTypes - Ember+ level and gain implemented
Browse files Browse the repository at this point in the history
  • Loading branch information
olzzon committed Jun 27, 2019
1 parent fd6d9ef commit 5f2752f
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 55 deletions.
27 changes: 27 additions & 0 deletions src/constants/mixerProtocols/EmberLawo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,33 @@ export const LawoClient: IMixerProtocol = {
}],
AUX_SEND: ['none'],
},
},
{
channelTypeName: 'Sums',
channelTypeColor: '#2f2f2f',
fromMixer: {
CHANNEL_FADER_LEVEL: ['Sapphire/Sums/Source{channel}/Fader'],
CHANNEL_OUT_GAIN: [''],
CHANNEL_VU: ['/track/{channel}/vu'],
CHANNEL_NAME: '/track/{channel}/name',
PFL: ['todo'],
AUX_SEND: ['none'],
},
toMixer: {
CHANNEL_FADER_LEVEL: ['Sapphire/Sums/Source{channel}/Fader'],
CHANNEL_OUT_GAIN: ['Sapphire/Sums/Source{channel}/Gain'],
PFL_ON: [{
mixerMessage: "/track/{channel}/solo",
value: 1,
type: "i"
}],
PFL_OFF: [{
mixerMessage: "/track/{channel}/solo",
value: 0,
type: "i"
}],
AUX_SEND: ['none'],
},
}],
fader: {
min: 0,
Expand Down
103 changes: 48 additions & 55 deletions src/utils/EmberMixerConnection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,69 +50,35 @@ export class EmberMixerConnection {
}

setupMixerConnection() {
let node: any;
console.log("Ember Connected");

for (let ch=1; ch <= this.store.settings[0].numberOfChannelsInType[0] ; ch++) {
this.emberConnection.getNodeByPath(this.mixerProtocol.channelTypes[0].fromMixer.CHANNEL_FADER_LEVEL[0].replace("{channel}", String(ch)))
.then((node: any) => {
this.emberConnection.subscribe(node, (() => {
window.storeRedux.dispatch({
type:'SET_FADER_LEVEL',
channel: ch - 1,
level: node.contents.value
});

if (window.huiRemoteConnection) {
window.huiRemoteConnection.updateRemoteFaderState(ch-1, node.contents.value);
}
console.log("subscription :", node.contents.value)
})
)
})
}
let ch: number = 1;
this.store.settings[0].numberOfChannelsInType.forEach((numberOfChannels, typeIndex) => {
for (let channelTypeIndex=0; channelTypeIndex < numberOfChannels ; channelTypeIndex++) {
this.subscribeFaderLevel(ch, typeIndex);
ch++;
}
})

/*
.on('message', (message: any) => {
if (this.checkEmberCommand(message.address, this.mixerProtocol.channelTypes[0].fromMixer
.CHANNEL_VU)){
let ch = message.address.split("/")[this.cmdChannelIndex];
window.storeRedux.dispatch({
type:'SET_VU_LEVEL',
channel: ch - 1,
level: message.args[0]
});
} else if ( this.checkEmberCommand(message.address, this.mixerProtocol.channelTypes[0].fromMixer
.CHANNEL_FADER_LEVEL)){
let ch = message.address.split("/")[this.cmdChannelIndex];
window.storeRedux.dispatch({
type:'SET_FADER_LEVEL',
channel: ch - 1,
level: message.args[0]
});
if (window.huiRemoteConnection) {
window.huiRemoteConnection.updateRemoteFaderState(ch-1, message.args[0]);
}
if (this.mixerProtocol.mode === 'master') {
if (this.store.channels[0].channel[ch - 1].pgmOn)
{
this.updateOutLevel(ch-1);
}
}
} else if (this.checkEmberCommand(message.address, this.mixerProtocol.channelTypes[0].fromMixer
.CHANNEL_NAME)) {
let ch = message.address.split("/")[this.cmdChannelIndex];
window.storeRedux.dispatch({
type:'SET_CHANNEL_LABEL',
channel: ch - 1,
label: message.args[0]
});
console.log("OSC message: ", message.address);
}
})
*/
this.emberConnection
.on('error', (error: any) => {
Expand All @@ -131,6 +97,26 @@ export class EmberMixerConnection {
}
}

subscribeFaderLevel(ch: number, typeIndex: number) {
this.emberConnection.getNodeByPath(this.mixerProtocol.channelTypes[typeIndex].fromMixer.CHANNEL_FADER_LEVEL[0].replace("{channel}", String(ch)))
.then((node: any) => {
console.log("Subscribing to channel :", ch);
this.emberConnection.subscribe(node, (() => {
window.storeRedux.dispatch({
type:'SET_FADER_LEVEL',
channel: ch-1,
level: node.contents.value
});

if (window.huiRemoteConnection) {
window.huiRemoteConnection.updateRemoteFaderState(ch-1, node.contents.value);
}
console.log("subscription :", node.contents.value)
})
)
})
}

pingMixerCommand() {
//Ping Ember mixer if mixerProtocol needs it.
return;
Expand Down Expand Up @@ -177,42 +163,49 @@ export class EmberMixerConnection {
}

updateOutLevel(channelIndex: number) {
let channelType = this.store.channels[0].channel[channelIndex].channelType;
let channelTypeIndex = this.store.channels[0].channel[channelIndex].channelTypeIndex;
this.sendOutMessage(
this.mixerProtocol.channelTypes[0].toMixer.CHANNEL_OUT_GAIN[0],
channelIndex+1,
this.mixerProtocol.channelTypes[channelType].toMixer.CHANNEL_OUT_GAIN[0],
channelTypeIndex+1,
this.store.channels[0].channel[channelIndex].outputLevel,
"f"
);
this.sendOutMessage(
this.mixerProtocol.channelTypes[0].toMixer.CHANNEL_FADER_LEVEL[0],
channelIndex+1,
this.mixerProtocol.channelTypes[channelType].toMixer.CHANNEL_FADER_LEVEL[0],
channelTypeIndex+1,
this.store.channels[0].channel[channelIndex].faderLevel,
"f"
);
}

updatePflState(channelIndex: number) {
let channelType = this.store.channels[0].channel[channelIndex].channelType;
let channelTypeIndex = this.store.channels[0].channel[channelIndex].channelTypeIndex;

if (this.store.channels[0].channel[channelIndex].pflOn === true) {
this.sendOutMessage(
this.mixerProtocol.channelTypes[0].toMixer.PFL_ON[0].mixerMessage,
channelIndex+1,
this.mixerProtocol.channelTypes[0].toMixer.PFL_ON[0].value,
this.mixerProtocol.channelTypes[0].toMixer.PFL_ON[0].type
this.mixerProtocol.channelTypes[channelType].toMixer.PFL_ON[0].mixerMessage,
channelTypeIndex+1,
this.mixerProtocol.channelTypes[channelType].toMixer.PFL_ON[0].value,
this.mixerProtocol.channelTypes[channelType].toMixer.PFL_ON[0].type
);
} else {
this.sendOutMessage(
this.mixerProtocol.channelTypes[0].toMixer.PFL_OFF[0].mixerMessage,
channelIndex+1,
this.mixerProtocol.channelTypes[0].toMixer.PFL_OFF[0].value,
this.mixerProtocol.channelTypes[0].toMixer.PFL_OFF[0].type
this.mixerProtocol.channelTypes[channelType].toMixer.PFL_OFF[0].mixerMessage,
channelTypeIndex+1,
this.mixerProtocol.channelTypes[channelType].toMixer.PFL_OFF[0].value,
this.mixerProtocol.channelTypes[channelType].toMixer.PFL_OFF[0].type
);
}
}

updateFadeIOLevel(channelIndex: number, outputLevel: number) {
let channelType = this.store.channels[0].channel[channelIndex].channelType;
let channelTypeIndex = this.store.channels[0].channel[channelIndex].channelTypeIndex;
this.sendOutMessage(
this.mixerProtocol.channelTypes[0].toMixer.CHANNEL_OUT_GAIN[0],
channelIndex+1,
this.mixerProtocol.channelTypes[channelType].toMixer.CHANNEL_OUT_GAIN[0],
channelTypeIndex+1,
String(outputLevel),
"f"
);
Expand Down

0 comments on commit 5f2752f

Please sign in to comment.