Modem speaker: hear the dialling, the answer tone and the training on the phone's speaker

As a modem's speaker had the line: on from off hook until CONNECT (ATM1,
the modem's default), all the call with ATM2, never with ATM0, at ATL's
volume; a switch in the settings silences it. The native modem passes
the line's sound (what came, its own at half level) on a socket the
app's player reads, never waiting for it; on SIP calls and on the line
to another phone.

D-Modem-RE to its latest (the V.90/V.92 analogue modem work) with
SipModem::on_speaker() on top (its branch claude/modem-speaker).

Tests: engine_test (SIP: the speaker on until CONNECT, nothing in data
mode, quiet with ATM0), PeerLineTest (the caller's speaker on a call to
another phone), ModemSpeakerTest (the player).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0172Hejd12i4aYikYW9vgpZs
This commit is contained in:
Claude committed 2026-10-17 08:57:09 +00:00
1 parent b26dfe5028
commit 32bddae3f5
16 files changed
+417 -8

No files matched your search

+17
View File
@@ -15,6 +15,7 @@
* answering): the line's samples on a
* connection to 127.0.0.1:<port>
* STATUS <link> <offhook> <tx> <rx>
* SPEAKER <level> <samples heard so far>
* EXIT <result>
* On stdin, the app's lines to the modem (RING, CANCEL, ANSWERED,
* FAILED <code>, DROPPED). The log on stderr.
@@ -137,6 +138,22 @@ int main(int argc, char *argv[])
cfg.peer = true;
cfg.peer_lead_ms = argc > 1 ? atoi(argv[1]) : 100;
cfg.log_level = getenv("PEER_LOG") ? atoi(getenv("PEER_LOG")) : 1;
/* the speaker: its level, the samples heard; PEER_SPEAKER=<file>:
the sound too, raw */
static FILE *sound = getenv("PEER_SPEAKER") ?
fopen(getenv("PEER_SPEAKER"), "wb") : nullptr;
static long heard;
e.set_speaker(
[](int level) {
say("SPEAKER %d %ld\n", level, heard);
},
[](const int16_t *pcm, int n) {
heard += n;
if (sound) {
fwrite(pcm, 2, n, sound);
fflush(sound);
}
});
int dte = e.start(cfg,
[](const Status &s) {
say("STATUS %d %d %u %u\n", (int)s.link, s.offhook,