Skip to content

Commit

Permalink
feat: multiple mixers - update redux actions: outputLevel and fadeActive
Browse files Browse the repository at this point in the history
  • Loading branch information
olzzon authored and olzzon committed Oct 5, 2020
1 parent 0f6aff4 commit 975f65b
Show file tree
Hide file tree
Showing 9 changed files with 52 additions and 14 deletions.
2 changes: 1 addition & 1 deletion server/__tests__/channelReducer.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ describe('Test redux channelReducer actions', () => {
let nextState = JSON.parse(parsedFullStoreJSON)
nextState.channels[0].chConnection[0].channel[10].outputLevel = 0.5
expect(
indexReducer(parsedFullStore, storeSetOutputLevel(10, 0.5))
indexReducer(parsedFullStore, storeSetOutputLevel(0, 10, 0.5))
).toEqual(nextState)
})

Expand Down
14 changes: 12 additions & 2 deletions server/reducers/channelActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,14 @@ export const FADE_ACTIVE = 'FADE_ACTIVE'
export const SET_ASSIGNED_FADER = 'SET_ASSIGNED_FADER'
export const SET_PRIVATE = 'SET_PRIVATE'

export const storeSetOutputLevel = (channel: number, level: number) => {
export const storeSetOutputLevel = (
mixerIndex: number,
channel: number,
level: number
) => {
return {
type: SET_OUTPUT_LEVEL,
mixerIndex: mixerIndex,
channel: channel,
level: level,
}
Expand Down Expand Up @@ -51,9 +56,14 @@ export const storeSetSingleChState = (
}
}

export const storeFadeActive = (channelIndex: number, active: boolean) => {
export const storeFadeActive = (
mixerIndex: number,
channelIndex: number,
active: boolean
) => {
return {
type: FADE_ACTIVE,
mixerIndex: mixerIndex,
channel: channelIndex,
active: active,
}
Expand Down
4 changes: 2 additions & 2 deletions server/reducers/channelsReducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export const channels = (

switch (action.type) {
case SET_OUTPUT_LEVEL: //channel: level:
nextState[0].chConnection[0].channel[
nextState[0].chConnection[action.mixerIndex].channel[
action.channel
].outputLevel = parseFloat(action.level)
return nextState
Expand Down Expand Up @@ -96,7 +96,7 @@ export const channels = (
action.state
return nextState
case FADE_ACTIVE:
nextState[0].chConnection[0].channel[
nextState[0].chConnection[action.mixerIndex].channel[
action.channel
].fadeActive = !!action.active
return nextState
Expand Down
36 changes: 28 additions & 8 deletions server/utils/MixerConnection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ export class MixerGenericConnection {
delayedFadeActiveDisable(mixerIndex: number, channelIndex: number) {
this.mixerTimers[mixerIndex].fadeActiveTimer[channelIndex] = setTimeout(
() => {
store.dispatch(storeFadeActive(channelIndex, false))
store.dispatch(storeFadeActive(mixerIndex, channelIndex, false))
},
state.settings[0].mixers[0].protocolLatency
)
Expand Down Expand Up @@ -471,7 +471,7 @@ export class MixerGenericConnection {
)
this.clearTimer(mixerIndex, channelIndex)
}
store.dispatch(storeFadeActive(channelIndex, true))
store.dispatch(storeFadeActive(mixerIndex, channelIndex, true))
if (
state.faders[0].fader[faderIndex].pgmOn ||
state.faders[0].fader[faderIndex].voOn
Expand Down Expand Up @@ -515,7 +515,11 @@ export class MixerGenericConnection {
outputLevel
)
store.dispatch(
storeSetOutputLevel(channelIndex, outputLevel)
storeSetOutputLevel(
mixerIndex,
channelIndex,
outputLevel
)
)
dispatchTrigger = 0
}
Expand All @@ -529,7 +533,11 @@ export class MixerGenericConnection {
this.clearTimer(mixerIndex, channelIndex)

store.dispatch(
storeSetOutputLevel(channelIndex, outputLevel)
storeSetOutputLevel(
mixerIndex,
channelIndex,
outputLevel
)
)
this.delayedFadeActiveDisable(mixerIndex, channelIndex)
return true
Expand All @@ -549,7 +557,11 @@ export class MixerGenericConnection {

if (dispatchTrigger > dispatchResolution) {
store.dispatch(
storeSetOutputLevel(channelIndex, outputLevel)
storeSetOutputLevel(
mixerIndex,
channelIndex,
outputLevel
)
)
dispatchTrigger = 0
}
Expand All @@ -562,7 +574,11 @@ export class MixerGenericConnection {
)
this.clearTimer(mixerIndex, channelIndex)
store.dispatch(
storeSetOutputLevel(channelIndex, outputLevel)
storeSetOutputLevel(
mixerIndex,
channelIndex,
outputLevel
)
)
this.delayedFadeActiveDisable(mixerIndex, channelIndex)
return true
Expand Down Expand Up @@ -593,7 +609,9 @@ export class MixerGenericConnection {
)

if (dispatchTrigger > dispatchResolution) {
store.dispatch(storeSetOutputLevel(channelIndex, outputLevel))
store.dispatch(
storeSetOutputLevel(mixerIndex, channelIndex, outputLevel)
)
dispatchTrigger = 0
}

Expand All @@ -604,7 +622,9 @@ export class MixerGenericConnection {
outputLevel
)
this.clearTimer(mixerIndex, channelIndex)
store.dispatch(storeSetOutputLevel(channelIndex, outputLevel))
store.dispatch(
storeSetOutputLevel(mixerIndex, channelIndex, outputLevel)
)
this.delayedFadeActiveDisable(mixerIndex, channelIndex)
return true
}
Expand Down
1 change: 1 addition & 0 deletions server/utils/mixerConnections/MidiMixerConnection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ export class MidiMixerConnection {
if (state.faders[0].fader[faderIndex].pgmOn) {
store.dispatch(
storeSetOutputLevel(
this.mixerIndex,
channelIndex,
state.faders[0].fader[faderIndex].faderLevel
)
Expand Down
2 changes: 2 additions & 0 deletions server/utils/mixerConnections/OscMixerConnection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ export class OscMixerConnection {
if (item.assignedFader === assignedFaderIndex) {
store.dispatch(
storeSetOutputLevel(
this.mixerIndex,
index,
message.args[0]
)
Expand Down Expand Up @@ -236,6 +237,7 @@ export class OscMixerConnection {
if (item.assignedFader === assignedFaderIndex) {
store.dispatch(
storeSetOutputLevel(
this.mixerIndex,
index,
message.args[0]
)
Expand Down
2 changes: 2 additions & 0 deletions server/utils/mixerConnections/SSLMixerConnection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ export class SSLMixerConnection {
) {
store.dispatch(
storeSetOutputLevel(
this.mixerIndex,
index,
value
)
Expand Down Expand Up @@ -430,6 +431,7 @@ export class SSLMixerConnection {
if (state.faders[0].fader[faderIndex].pgmOn) {
store.dispatch(
storeSetOutputLevel(
this.mixerIndex,
channelIndex,
state.faders[0].fader[faderIndex].faderLevel
)
Expand Down
4 changes: 3 additions & 1 deletion server/utils/mixerConnections/StuderVistaMixerConnection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,9 @@ export class StuderVistaMixerConnection {
state.channels[0].chConnection[this.mixerIndex].channel.forEach(
(item, index) => {
if (item.assignedFader === assignedFader) {
store.dispatch(storeSetOutputLevel(index, value))
store.dispatch(
storeSetOutputLevel(this.mixerIndex, index, value)
)
}
}
)
Expand Down
1 change: 1 addition & 0 deletions server/utils/mixerConnections/YamahaQlClConnection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,7 @@ export class QlClMixerConnection {
if (state.faders[0].fader[faderIndex].pgmOn) {
store.dispatch(
storeSetOutputLevel(
this.mixerIndex,
channelIndex,
state.faders[0].fader[faderIndex].faderLevel
)
Expand Down

0 comments on commit 975f65b

Please sign in to comment.