Skip to content

Commit

Permalink
fix(casparcg): better fader response
Browse files Browse the repository at this point in the history
  • Loading branch information
mint-dewit committed Nov 10, 2020
1 parent ee89d7c commit 50b3c30
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion server/utils/mixerConnections/CasparCGConnection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -257,11 +257,24 @@ export class CasparCGConnection {
}

private syncCommand = Promise.resolve()
floatToVolume = (float: number) => {
const db = floatToDB(float)
const volume = Math.pow(10, db / 20)

return Math.min(Math.max(volume, 0), 3.2) // clamp between 0 and 3.2
}
controlVolume = (channel: number, layer: number, value: number) => {
logger.verbose(`Set ${channel}-${layer} volume = ${value}`)
this.syncCommand = this.syncCommand
.then(() =>
this.connection
.mixerVolume(channel, layer, value, 0, undefined)
.mixerVolume(
channel,
layer,
this.floatToVolume(value),
0,
undefined
)
.catch((e: any) => {
logger.error(
'Failed to send command' + JSON.stringify(e)
Expand Down

0 comments on commit 50b3c30

Please sign in to comment.