summaryrefslogtreecommitdiff
path: root/cmd/dolmetschctld
diff options
context:
space:
mode:
authorChristian Pointner <equinox@spreadspace.org>2020-04-12 20:22:27 +0200
committerChristian Pointner <equinox@spreadspace.org>2020-04-12 20:22:27 +0200
commit89f471f9f129e2c9876091b4c229caac426db93d (patch)
tree8abc072693ffe564e496ad50889f59de00635b4b /cmd/dolmetschctld
parentnew mixer interface mostly done, remaining issues with floats and rounding er... (diff)
basic functionality works now
Diffstat (limited to 'cmd/dolmetschctld')
-rw-r--r--cmd/dolmetschctld/statemachine.go20
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
}
}