Move the remaining encoder settings to Network; use sliders for redundancy and buffering

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-06 21:03:00 +00:00
co-authored by Claude Opus 5.5
parent 33317df2eb
commit a2bfcf9f28
6 changed files with 99 additions and 105 deletions
@@ -13,12 +13,13 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import com.ts3client.android.SessionController
import com.ts3client.config.Settings
import kotlin.math.abs
import kotlin.math.roundToInt
private const val MIN_BITRATE_KBITS = 8f
private const val MAX_BITRATE_KBITS = 160f
/** What voice costs and survives on the wire: bitrate, error correction, duplicate packets and receive buffering. */
/** What voice costs and survives on the wire: the encoder, duplicate packets and receive buffering. */
@Composable
fun NetworkSettingsScreen(vm: SessionController, onBack: () -> Unit) {
val settings = vm.settings
@@ -28,6 +29,7 @@ fun NetworkSettingsScreen(vm: SessionController, onBack: () -> Unit) {
}
var vbr by remember { mutableStateOf(settings.vbr) }
var fec by remember { mutableStateOf(settings.fec) }
var music by remember { mutableStateOf(settings.music) }
var redundancy by remember { mutableStateOf(settings.redundancyDelay) }
var copies by remember { mutableStateOf(settings.redundancyCopies) }
var receiveBuffer by remember { mutableStateOf(settings.receiveBuffer) }
@@ -46,24 +48,41 @@ fun NetworkSettingsScreen(vm: SessionController, onBack: () -> Unit) {
fec = it
change { this.fec = it }
}
Level("Complexity", settings.complexity.toFloat(), 0f..10f, { "${it.roundToInt()}" }, steps = 9) {
change { complexity = it.roundToInt() }
}
Toggle("Music codec (stereo, higher fidelity)", music) {
music = it
change { this.music = it }
}
Section("Redundancy")
Picker("Delay", Settings.REDUNDANCY_DELAYS.map { it to if (it == 0) "Off" else "$it ms" }, redundancy) {
ChoiceLevel("Delay", Settings.REDUNDANCY_DELAYS, redundancy) {
redundancy = it
change { redundancyDelay = it }
}
if (redundancy > 0) {
Picker("Copies", (1..Settings.MAX_REDUNDANCY_COPIES).map { it to "$it" }, copies) {
copies = it
change { redundancyCopies = it }
Level("Copies", copies.toFloat(), 1f..Settings.MAX_REDUNDANCY_COPIES.toFloat(), { "${it.roundToInt()}" },
steps = Settings.MAX_REDUNDANCY_COPIES - 2) {
copies = it.roundToInt()
change { redundancyCopies = copies }
}
}
Section("Receive")
Picker("Extra buffering", Settings.RECEIVE_BUFFERS.map { it to if (it == 0) "Off" else "$it ms" }, receiveBuffer) {
ChoiceLevel("Extra buffering", Settings.RECEIVE_BUFFERS, receiveBuffer) {
receiveBuffer = it
change { this.receiveBuffer = it }
}
}
}
}
/** A slider stepping through the millisecond [choices], starting at the one nearest [ms]. */
@Composable
private fun ChoiceLevel(label: String, choices: IntArray, ms: Int, onDone: (Int) -> Unit) {
val index = choices.indices.minBy { abs(choices[it] - ms) }
fun at(position: Float) = choices[position.roundToInt()]
Level(label, index.toFloat(), 0f..(choices.size - 1).toFloat(), { at(it).let { v -> if (v == 0) "Off" else "$v ms" } },
steps = choices.size - 2) { onDone(at(it)) }
}
@@ -51,7 +51,6 @@ fun SoundSettingsScreen(vm: SessionController, onBack: () -> Unit) {
var inputMode by remember { mutableStateOf(settings.inputMode) }
var vadMode by remember { mutableStateOf(settings.vadMode) }
var agc by remember { mutableStateOf(settings.agc) }
var music by remember { mutableStateOf(settings.music) }
var mutedTalkWarning by remember { mutableStateOf(settings.mutedTalkWarning) }
var threshold by remember { mutableFloatStateOf(settings.vadThresholdDb.toFloat()) }
var inputDevice by remember { mutableStateOf(settings.inputDevice) }
@@ -148,15 +147,6 @@ fun SoundSettingsScreen(vm: SessionController, onBack: () -> Unit) {
}
}
Section("Encoder")
Level("Complexity", settings.complexity.toFloat(), 0f..10f, { "${it.roundToInt()}" }, steps = 9) {
change { complexity = it.roundToInt() }
}
Toggle("Music codec (stereo, higher fidelity)", music) {
music = it
change { this.music = it }
}
Section("Playback")
Level("Volume", settings.outputVolume.toFloat(), 0f..2f, { "${(it * 100).roundToInt()} %" }) {
change { outputVolume = it.toDouble() }