Skip to content

Commit

Permalink
Merge pull request #337 from bbc/fix/pgmon-while-faderlevel-is-fading
Browse files Browse the repository at this point in the history
fix: setting PGM ON/OFF while faderLevel is fading caused level bump
  • Loading branch information
KvelaGorrrrnio authored Oct 4, 2024
2 parents 36c8b73 + 7586750 commit 341eb25
Showing 1 changed file with 28 additions and 17 deletions.
45 changes: 28 additions & 17 deletions server/src/utils/MixerConnection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,12 @@ export class MixerGenericConnection {
chTimer: NodeJS.Timeout[]
fadeActiveTimer: NodeJS.Timeout[]
}[]
currentOutputLevel: number[]

constructor() {
this.mixerProtocol = []
this.mixerConnection = []
this.currentOutputLevel = []
// Get mixer protocol
state.settings[0].mixers.forEach((none: any, index: number) => {
this.mixerProtocol.push(
Expand Down Expand Up @@ -446,17 +448,35 @@ export class MixerGenericConnection {
fadeTime: number,
faderIndex: number
) => {
const outputLevel =
state.channels[0].chMixerConnection[mixerIndex].channel[
channelIndex
].outputLevel
let startLevel = state.channels[0].chMixerConnection[mixerIndex].channel[
channelIndex].outputLevel

if (state.channels[0].chMixerConnection[mixerIndex].channel[channelIndex].fadeActive
&& this.currentOutputLevel[channelIndex] !== undefined
) {
startLevel = this.currentOutputLevel[channelIndex]
}

let targetVal = state.faders[0].fader[faderIndex].faderLevel

if (state.faders[0].fader[faderIndex].voOn) {
targetVal = (targetVal * (100 - state.settings[0].voLevel)) / 100
}

this.fade(fadeTime, mixerIndex, channelIndex, outputLevel, targetVal)
this.fade(fadeTime, mixerIndex, channelIndex, startLevel, targetVal)
}

fadeDown = (mixerIndex: number, channelIndex: number, fadeTime: number) => {
let startLevel = state.channels[0].chMixerConnection[mixerIndex].channel[
channelIndex].outputLevel

if (state.channels[0].chMixerConnection[mixerIndex].channel[channelIndex].fadeActive
&& this.currentOutputLevel[channelIndex] !== undefined
) {
startLevel = this.currentOutputLevel[channelIndex]
}

this.fade(fadeTime, mixerIndex, channelIndex, startLevel, 0)
}

fade(
Expand Down Expand Up @@ -523,14 +543,14 @@ export class MixerGenericConnection {
return true
}

const currentOutputLevel =
this.currentOutputLevel[channelIndex] =
startLevel +
(endLevel - startLevel) *
Math.max(0, Math.min(1, elapsedTimeMS / fadeTime))

this.mixerConnection[mixerIndex].updateFadeIOLevel(
channelIndex,
currentOutputLevel
this.currentOutputLevel[channelIndex]
)

store.dispatch({
Expand All @@ -539,16 +559,7 @@ export class MixerGenericConnection {
channel: channelIndex,
level: endLevel,
})
sendChLevelsToOuputServer(mixerIndex, channelIndex, currentOutputLevel)
}

fadeDown = (mixerIndex: number, channelIndex: number, fadeTime: number) => {
const outputLevel =
state.channels[0].chMixerConnection[mixerIndex].channel[
channelIndex
].outputLevel

this.fade(fadeTime, mixerIndex, channelIndex, outputLevel, 0)
sendChLevelsToOuputServer(mixerIndex, channelIndex, this.currentOutputLevel[channelIndex])
}
}

0 comments on commit 341eb25

Please sign in to comment.