Skip to content

Commit

Permalink
fix: MixerConnection - Fade dispatch resolution didn´t iterate
Browse files Browse the repository at this point in the history
  • Loading branch information
olzzon committed Jun 23, 2019
1 parent 6c31adb commit 4cf207f
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/utils/MixerConnection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import { CasparCGConnection } from './CasparCGConnection';

// FADE_INOUT_SPEED defines the resolution of the fade in ms
// The lower the more CPU
let FADE_INOUT_SPEED = 3;
const FADE_INOUT_SPEED = 3;
const FADE_DISPATCH_RESOLUTION = 5;

export class MixerGenericConnection {
store: any;
Expand Down Expand Up @@ -95,15 +96,14 @@ export class MixerGenericConnection {
targetVal = parseFloat(this.store.channels[0].channel[channelIndex].faderLevel);
}
const step: number = (targetVal-outputLevel)/(fadeTime/FADE_INOUT_SPEED);
const dispatchResolution: number = 5*step;
const dispatchResolution: number = FADE_DISPATCH_RESOLUTION*step;
let dispatchTrigger: number = 0;

if (targetVal<outputLevel) {
this.timer[channelIndex] = setInterval(() => {
outputLevel += step;
this.mixerConnection.updateFadeIOLevel(channelIndex, outputLevel);

dispatchTrigger += step;
this.mixerConnection.updateFadeIOLevel(channelIndex, outputLevel);

if (dispatchTrigger > dispatchResolution) {
window.storeRedux.dispatch({
Expand Down Expand Up @@ -135,6 +135,7 @@ export class MixerGenericConnection {
} else {
this.timer[channelIndex] = setInterval(() => {
outputLevel += step;
dispatchTrigger += step;
this.mixerConnection.updateFadeIOLevel(channelIndex, outputLevel);

if (dispatchTrigger > dispatchResolution) {
Expand Down Expand Up @@ -172,12 +173,12 @@ export class MixerGenericConnection {
let outputLevel = this.store.channels[0].channel[channelIndex].outputLevel;
const min = this.mixerProtocol.fader.min;
const step = (outputLevel-min)/(fadeTime/FADE_INOUT_SPEED);
const dispatchResolution: number = 5*step;
const dispatchResolution: number = FADE_DISPATCH_RESOLUTION*step;
let dispatchTrigger: number = 0;

this.timer[channelIndex] = setInterval(() => {

outputLevel -= step;
dispatchTrigger += step;
this.mixerConnection.updateFadeIOLevel(channelIndex, outputLevel);

if (dispatchTrigger > dispatchResolution) {
Expand Down

0 comments on commit 4cf207f

Please sign in to comment.