diff options
-rw-r--r-- | cmd/dolmetschctld/statemachine.go | 20 | ||||
-rw-r--r-- | pkg/mixer/mixer.go | 15 |
2 files changed, 22 insertions, 13 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 } } diff --git a/pkg/mixer/mixer.go b/pkg/mixer/mixer.go index 58ae20b..dbc4dae 100644 --- a/pkg/mixer/mixer.go +++ b/pkg/mixer/mixer.go @@ -61,10 +61,11 @@ func (et EventType) String() string { type FaderLevel float32 const ( - FaderLevelUnknown = FaderLevel(-1.0) - FaderLevelMax = FaderLevel(1.00) - FaderLevel0db = FaderLevel(0.75) - FaderLevelOff = FaderLevel(0.00) + FaderLevelUnknown = FaderLevel(-1.0) + FaderLevelMax = FaderLevel(1.00) + FaderLevel0db = FaderLevel(0.75) + FaderLevelOff = FaderLevel(0.00) + FaderLevelIncrement = FaderLevel(0.01) ) func (fl FaderLevel) String() string { @@ -267,7 +268,11 @@ func (d oscDispatcher) Invoke(msg osc.Message, exactMatch bool) error { if err != nil { return err } - ev.Mute = Mute(arg) + if arg == 0 { + ev.Mute = MuteMuted + } else { + ev.Mute = MuteUnmuted + } case "fader": ev.Type = EventFaderChange arg, err := msg.Arguments[0].ReadFloat32() |