diff options
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/dolmetschctld/statemachine.go | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/cmd/dolmetschctld/statemachine.go b/cmd/dolmetschctld/statemachine.go index b6d46ba..3e7461b 100644 --- a/cmd/dolmetschctld/statemachine.go +++ b/cmd/dolmetschctld/statemachine.go @@ -168,8 +168,8 @@ func (sm *StateMachine) handleMixerEvent(ev mixer.Event) { } switch ev.Type { - case mixer.EventFaderChange: - mc.current.level = ev.Level + // case mixer.EventFaderChange: + // mc.current.level = ev.Level case mixer.EventMute: mc.current.mute = ev.Mute } @@ -220,10 +220,10 @@ func (sm *StateMachine) setOriginal2InterpreterRatio(r float32) error { func calcNextLevel(target, current mixer.FaderLevel) mixer.FaderLevel { next := target if current != mixer.FaderLevelUnknown { - if next > current { - next = current + 0.01 - } else { - next = current - 0.01 + if next > (current + mixer.FaderLevelIncrement/2) { + next = current + mixer.FaderLevelIncrement + } else if next < (current - mixer.FaderLevelIncrement/2) { + next = current - mixer.FaderLevelIncrement } } return next @@ -249,11 +249,15 @@ func (sm *StateMachine) reconcile(ticker bool) { sm.state = types.StateSettled for _, mcs := range sm.languages { if mcs.original.target.level != mcs.original.current.level { - sm.mixer.SetLevel(mcs.original.num, calcNextLevel(mcs.original.target.level, mcs.original.current.level)) + nextLevel := calcNextLevel(mcs.original.target.level, mcs.original.current.level) + sm.mixer.SetLevel(mcs.original.num, nextLevel) + mcs.original.current.level = nextLevel sm.state = types.StateSettling } if mcs.interpreter.target.level != mcs.interpreter.current.level { - sm.mixer.SetLevel(mcs.interpreter.num, calcNextLevel(mcs.interpreter.target.level, mcs.interpreter.current.level)) + nextLevel := calcNextLevel(mcs.interpreter.target.level, mcs.interpreter.current.level) + sm.mixer.SetLevel(mcs.interpreter.num, nextLevel) + mcs.interpreter.current.level = nextLevel sm.state = types.StateSettling } } |