Skip to content

Commit

Permalink
fix: internal levels are always 0-1 conversion to protocol level must…
Browse files Browse the repository at this point in the history
… take place in the protocols mixerconnection
  • Loading branch information
olzzon authored and olzzon committed Feb 17, 2020
1 parent bc6c6bd commit 88dd14f
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 34 deletions.
11 changes: 2 additions & 9 deletions server/constants/mixerProtocols/EmberLawo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,20 +47,13 @@ export const LawoClient: IMixerProtocol = {
CHANNEL_MUTE_OFF: [emptyMixerMessage()]
},
toMixer: {
CHANNEL_FADER_LEVEL: [{
CHANNEL_FADER_LEVEL: [emptyMixerMessage()],
CHANNEL_OUT_GAIN: [{
mixerMessage: 'R3LAYVRX4/Ex/GUI/FaderSlot_{channel}/FaderPosition',
value: 0,
type: 'real',
min: 0,
max: 100,
zero: 75
}],
CHANNEL_OUT_GAIN: [{
mixerMessage: 'R3LAYVRX4/Ex/GUI/FaderSlot_{channel}/Amplification',
value: 0,
type: 'real',
min: -200,
max: 20,
zero: 0

}],
Expand Down
9 changes: 4 additions & 5 deletions server/utils/MixerConnection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export class MixerGenericConnection {


checkForAutoResetThreshold(channel: number) {
if (state.faders[0].fader[channel].faderLevel <= this.mixerProtocol.fader.min + (this.mixerProtocol.fader.max * state.settings[0].autoResetLevel / 100)) {
if (state.faders[0].fader[channel].faderLevel <= state.settings[0].autoResetLevel / 100) {
store.dispatch({
type: SET_FADER_LEVEL,
channel: channel,
Expand Down Expand Up @@ -322,8 +322,7 @@ export class MixerGenericConnection {

fadeDown(channelIndex: number, fadeTime: number) {
let outputLevel = state.channels[0].channel[channelIndex].outputLevel;
const min = this.mixerProtocol.channelTypes[0].toMixer.CHANNEL_OUT_GAIN[0].min;
const step = (outputLevel-min)/(fadeTime/FADE_INOUT_SPEED);
const step = (outputLevel)/(fadeTime/FADE_INOUT_SPEED);
const dispatchResolution: number = FADE_DISPATCH_RESOLUTION*step;
let dispatchTrigger: number = 0;

Expand All @@ -343,8 +342,8 @@ export class MixerGenericConnection {
dispatchTrigger = 0;
}

if ( outputLevel <= min ){
outputLevel=min;
if ( outputLevel <= 0 ){
outputLevel=0
this.mixerConnection.updateFadeIOLevel(channelIndex, outputLevel);
this.clearTimer(channelIndex)
store.dispatch({
Expand Down
48 changes: 28 additions & 20 deletions server/utils/mixerConnections/EmberMixerConnection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ export class EmberMixerConnection {
}

setupMixerConnection() {
logger.info('Ember connection established')

let ch: number = 1;
state.settings[0].numberOfChannelsInType.forEach((numberOfChannels, typeIndex) => {
Expand All @@ -76,12 +77,14 @@ export class EmberMixerConnection {
})

ch = 1;
/*
state.settings[0].numberOfChannelsInType.forEach((numberOfChannels, typeIndex) => {
for (let channelTypeIndex=0; channelTypeIndex < numberOfChannels ; channelTypeIndex++) {
this.subscribeChannelName(ch, typeIndex, channelTypeIndex);
ch++;
}
})
*/

/*
.CHANNEL_VU)){
Expand All @@ -91,11 +94,7 @@ export class EmberMixerConnection {
level: message.args[0]
});
*/
this.emberConnection
.on('error', (error: any) => {
console.log("Error : ", error);
console.log("Lost EMBER connection");
});


//Ping OSC mixer if mixerProtocol needs it.
if (this.mixerProtocol.pingTime > 0) {
Expand All @@ -109,7 +108,7 @@ export class EmberMixerConnection {
}

subscribeFaderLevel(ch: number, typeIndex: number, channelTypeIndex: number) {
this.emberConnection.getNodeByPath(this.mixerProtocol.channelTypes[typeIndex].fromMixer.CHANNEL_OUT_GAIN[0].mixerMessage.replace("{channel}", String(channelTypeIndex+1)))
this.emberConnection.getElementByPath(this.mixerProtocol.channelTypes[typeIndex].fromMixer.CHANNEL_OUT_GAIN[0].mixerMessage.replace("{channel}", String(channelTypeIndex+1)))
.then((node: any) => {
this.emberNodeObject[ch-1] = node;
this.emberConnection.subscribe(node, (() => {
Expand Down Expand Up @@ -160,16 +159,22 @@ export class EmberMixerConnection {

sendOutMessage(mixerMessage: string, channel: number, value: string | number, type: string) {
let channelString = this.mixerProtocol.leadingZeros ? ("0"+channel).slice(-2) : channel.toString();

let message = mixerMessage.replace(
"{channel}",
channelString
)

// this.emberConnection.QualifiedParameter.setValue("1.1.1.1.1.1", 21)
// this.emberConnection.getNodeByPath(message)
// .then((response: any) => {
// console.log("Node object :", response)
this.emberConnection.setValue(
mixerMessage,
typeof value === 'number' ? value : parseFloat(value)
)
// })
this.emberConnection.getElementByPath(message)
.then((element: any) => {
this.emberConnection.setValue(
element,
typeof value === 'number' ? value : parseFloat(value)
)
})
.catch((error: any) => {
console.log("Ember Error ", error)
})
}

sendOutRequest(mixerMessage: string, channel: number) {
Expand All @@ -190,10 +195,11 @@ export class EmberMixerConnection {
updateOutLevel(channelIndex: number) {
let channelType = state.channels[0].channel[channelIndex].channelType;
let channelTypeIndex = state.channels[0].channel[channelIndex].channelTypeIndex;
let level = state.channels[0].channel[channelIndex].outputLevel * 100
this.sendOutMessage(
this.emberNodeObject[channelIndex],
this.mixerProtocol.channelTypes[channelType].toMixer.CHANNEL_OUT_GAIN[0].mixerMessage,
channelTypeIndex+1,
state.channels[0].channel[channelIndex].outputLevel,
level,
"f"
);
}
Expand Down Expand Up @@ -257,12 +263,14 @@ export class EmberMixerConnection {
updateFadeIOLevel(channelIndex: number, outputLevel: number) {
let channelType = state.channels[0].channel[channelIndex].channelType;
let channelTypeIndex = state.channels[0].channel[channelIndex].channelTypeIndex;
let level = outputLevel * 100

this.sendOutMessage(
this.emberNodeObject[channelIndex],
this.mixerProtocol.channelTypes[channelType].toMixer.CHANNEL_OUT_GAIN[0].mixerMessage,
channelTypeIndex+1,
String(outputLevel),
String(level),
"f"
);
)
}

updateChannelName(channelIndex: number) {
Expand Down

0 comments on commit 88dd14f

Please sign in to comment.