mirror of
https://github.com/D-Modem/app.git
synced 2026-11-28 17:38:05 -08:00
USB line: automatic transmit level, on by default
A switch over the transmit level: on, D-Modem-RE's DMODEM_USB_TX_GAIN=auto sets it for each call from the remote's answer tone; off, the dB as before. Bumps d-modem-re for it (and rings no longer hidden by caller ID's listening). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0172Hejd12i4aYikYW9vgpZs
This commit is contained in:
5 files changed
+43
-9
No files matched your search
@@ -281,8 +281,9 @@ class ModemService : Service() {
|
||||
}
|
||||
// the modem's sound to a USB modem's line louder or softer (D-Modem-RE's DMODEM_USB_TX_GAIN)
|
||||
runCatching {
|
||||
if (settings.usb && settings.usbTxGain != 0) {
|
||||
android.system.Os.setenv("DMODEM_USB_TX_GAIN", settings.usbTxGain.coerceIn(-20, 20).toString(), true)
|
||||
val gain = settings.usbTxGainEnv
|
||||
if (gain != null) {
|
||||
android.system.Os.setenv("DMODEM_USB_TX_GAIN", gain, true)
|
||||
} else {
|
||||
android.system.Os.unsetenv("DMODEM_USB_TX_GAIN")
|
||||
}
|
||||
|
||||
@@ -67,7 +67,18 @@ data class ModemSettings(
|
||||
val recordLine: Boolean = false,
|
||||
/** a USB modem's line: the modem's sound to it louder or softer, dB (-20 to 20; D-Modem-RE's DMODEM_USB_TX_GAIN) */
|
||||
val usbTxGain: Int = 0,
|
||||
/** a USB modem's line: its transmit level set for each call from the remote's answer tone (DMODEM_USB_TX_GAIN=auto), not [usbTxGain] */
|
||||
val usbTxAuto: Boolean = true,
|
||||
) {
|
||||
/** D-Modem-RE's DMODEM_USB_TX_GAIN for this line: "auto", the dB, or null (none: 0 dB, or not a USB line) */
|
||||
val usbTxGainEnv: String?
|
||||
get() = when {
|
||||
!usb -> null
|
||||
usbTxAuto -> "auto"
|
||||
usbTxGain != 0 -> usbTxGain.coerceIn(-20, 20).toString()
|
||||
else -> null
|
||||
}
|
||||
|
||||
/** the line is another phone (or this phone's mobile calls, or none), not SIP: the app carries its samples */
|
||||
val peer: Boolean get() = line != LINE_SIP && line != LINE_USB && line != LINE_BT_MODEM
|
||||
|
||||
@@ -156,6 +167,7 @@ class SettingsStore(private val context: Context) {
|
||||
val btModemName = stringPreferencesKey("bt_modem_name")
|
||||
val recordLine = booleanPreferencesKey("record_line")
|
||||
val usbTxGain = intPreferencesKey("usb_tx_gain")
|
||||
val usbTxAuto = booleanPreferencesKey("usb_tx_auto")
|
||||
}
|
||||
|
||||
val settings: Flow<ModemSettings> = context.dataStore.data.map { p ->
|
||||
@@ -185,6 +197,7 @@ class SettingsStore(private val context: Context) {
|
||||
btModemName = p[Keys.btModemName] ?: d.btModemName,
|
||||
recordLine = p[Keys.recordLine] ?: d.recordLine,
|
||||
usbTxGain = p[Keys.usbTxGain] ?: d.usbTxGain,
|
||||
usbTxAuto = p[Keys.usbTxAuto] ?: d.usbTxAuto,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -216,6 +229,7 @@ class SettingsStore(private val context: Context) {
|
||||
p[Keys.btModemName] = s.btModemName
|
||||
p[Keys.recordLine] = s.recordLine
|
||||
p[Keys.usbTxGain] = s.usbTxGain.coerceIn(-20, 20)
|
||||
p[Keys.usbTxAuto] = s.usbTxAuto
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -157,12 +157,21 @@ fun SettingsScreen(modifier: Modifier = Modifier, onOpenTerminal: () -> Unit = {
|
||||
PeerLineFields(s) { s = it }
|
||||
} else if (s.usb) {
|
||||
UsbLineFields()
|
||||
SignedNumberField("Transmit level (dB, -20 to 20)", s.usbTxGain) { s = s.copy(usbTxGain = it.coerceIn(-20, 20)) }
|
||||
Text(
|
||||
"The modem's sound to the line louder (+) or softer (-) than D-Modem's own: for a line or modem " +
|
||||
"that hears it too faintly (0: as it is). Too loud distorts it.",
|
||||
style = MaterialTheme.typography.bodySmall,
|
||||
)
|
||||
Toggle("Automatic transmit level", s.usbTxAuto) { s = s.copy(usbTxAuto = it) }
|
||||
if (s.usbTxAuto) {
|
||||
Text(
|
||||
"Set for each call from how loud the other modem's answer tone arrives (louder on a longer line, " +
|
||||
"softer if it distorts); the log says what it chose.",
|
||||
style = MaterialTheme.typography.bodySmall,
|
||||
)
|
||||
} else {
|
||||
SignedNumberField("Transmit level (dB, -20 to 20)", s.usbTxGain) { s = s.copy(usbTxGain = it.coerceIn(-20, 20)) }
|
||||
Text(
|
||||
"The modem's sound to the line louder (+) or softer (-) than D-Modem's own: for a line or modem " +
|
||||
"that hears it too faintly (0: as it is). Too loud distorts it.",
|
||||
style = MaterialTheme.typography.bodySmall,
|
||||
)
|
||||
}
|
||||
Toggle("Record each call (for a bug report)", s.recordLine) { s = s.copy(recordLine = it) }
|
||||
Text(
|
||||
"Each call's sound, off hook to on hook, as a stereo WAV file (the line's, the modem's); " +
|
||||
|
||||
@@ -42,4 +42,14 @@ class ModemSettingsTest {
|
||||
assertTrue(ModemSettings().sip)
|
||||
assertFalse(ModemSettings().usb)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun aUsbLinesTransmitLevelIsAutomaticByDefault() {
|
||||
val usb = ModemSettings(line = ModemSettings.LINE_USB)
|
||||
assertEquals("auto", usb.usbTxGainEnv)
|
||||
assertEquals("6", usb.copy(usbTxAuto = false, usbTxGain = 6).usbTxGainEnv)
|
||||
assertEquals("-20", usb.copy(usbTxAuto = false, usbTxGain = -40).usbTxGainEnv)
|
||||
assertNull(usb.copy(usbTxAuto = false).usbTxGainEnv)
|
||||
assertNull(ModemSettings().usbTxGainEnv)
|
||||
}
|
||||
}
|
||||
Vendored
+1
-1
Submodule external/d-modem-re updated: 6bab61d5d3...5ea9ff5dc8.
Reference in new issue
Block a user