v160 · webrtc · composition
IVR decoder
The far end of every DTMF call is usually a phone menu. Here the second peer is that menu: it listens to the audio it receives over the loopback, runs a Goertzel filter bank over the eight DTMF frequencies, and navigates on the keys it hears. The caller sends with the standard RTCRtpSender.dtmf — so a match between “sent” and “decoded” proves the replacement for createDTMFSender() puts real tones on the wire.
Chrome sends DTMF as RTP telephone-events (RFC 4733) and the receiving peer regenerates the tones in its audio playout, which is what the decoder hears. The decoder needs the page to stay in the foreground; background tabs throttle its timer. Nothing plays through your speakers.
Idle.
Caller — pc1 · sender.dtmf
- sent
- —
IVR — pc2 · Goertzel decoder
(not connected)
- decoded
- —
- hearing
- —
how the decoder works
// caller
sender.dtmf.insertDTMF(key, 120, 80);
// IVR: remote track → AnalyserNode → Goertzel power at 8 frequencies
const coeff = 2 * Math.cos(2 * Math.PI * f / sampleRate);
let s1 = 0, s2 = 0;
for (const x of samples) { const s0 = x + coeff * s1 - s2; s2 = s1; s1 = s0; }
power = s1 * s1 + s2 * s2 - coeff * s1 * s2;
// strongest low (697–941 Hz) × strongest high (1209–1633 Hz) = key,
// accepted only when both dominate their group and persist 2 frames.