./jerome{m}jack in

~/Notes/Reading an SSTV Header Through a Room.md · note · seedling · 5 min · updated

Reading an SSTV Header Through a Room

// status: seedling

Every slow-scan TV transmission opens with a header that tells the receiver which mode is coming (the layout is on the Modem Lab page). Without it the receiver does not know the picture's size or timing and never starts. In one real room, a laptop 20 cm from the speakers heard that header loud and clear and failed to read it six times out of six. The lab showed "leader heard" and then nothing.

Two spectrograms of the same header from 1000 to 2400 Hz. Top, as sent: a long 1900 Hz leader with a brief break, then clean 30 ms steps between 1300 and 1100 Hz. Bottom, as a laptop heard it: the leader runs on past its end and the steps blur into each other

The header as sent (top) and as the laptop's microphone delivered it (bottom), 1000–2400 Hz, about one second.

Getting evidence instead of guesses

The lab cannot be debugged from a description of what it did, and a phone filming the screen records a different microphone in a different place. So the lab gained a button that saves what its own microphone delivered: a rolling four minutes, exactly as the decoder was fed it, with a log of the decoder's state changes in the file's comment.

The first such file settled several theories at once. No audio had been lost (the capture counts missing frames). Nothing clipped. The browser reported noise suppression, echo cancellation and gain control all off. And replayed offline, the decoder made the same decisions at the same instants as it had live: it found the header's start bit every time, and rejected the mode code 0.3 s later every time. For the attempts that sent the same mode, its eight bit readings matched to two decimal places. A failure that repeats exactly is not noise.

What the bits looked like

The mode code is eight bits of 30 ms each, 1100 Hz for a one and 1300 Hz for a zero, after a 30 ms start bit at 1200 Hz. The receiver finds the start bit, then measures the two tones in each bit's slot.

In that room each tone ran on into the next slot, as the lower spectrogram shows. Two things followed:

  • The 1900 Hz leader was still ringing where the start bit should have been, so the receiver placed the start bit 43 ms late. That is more than one whole bit.
  • Every slot therefore measured mostly the previous bit, mixed with the one before.

The word that came out was consistent, had valid parity, and was the code of no mode the lab knows. The existing reader already searched ±12 ms around the start bit and subtracted a first-order echo from each slot. It was built for a smear shorter than a bit, and this one was longer.

Fit the whole header

A header is 950 ms of exactly known signal, different for each mode only in its last 240 ms. So instead of sampling bits, ask a different question for each mode m: how much of what was heard can that mode's whole header x_m explain, if it passed through some short linear path h?

\hat{h}_m = \arg\min_h \; \lVert y - X_m h \rVert^2 + \lambda \lVert h \rVert^2

Here y is the recording in complex baseband (0.9–2.1 kHz, sampled at 1.5 kHz), the columns of X_m are the header delayed by 0, 1, 2, … samples, and h has 80 ms of taps. The path is a nuisance parameter: nobody needs to know the room, only whether a room exists that turns this header into that recording.

Solved naively this is five least-squares problems per candidate start time. Two observations make it nearly free:

  • The normal-equation matrix X_m^H X_m depends only on the header. It is the header's autocorrelation laid out as a Toeplitz matrix, so it is built and factorized once per mode.
  • The right-hand side X_m^H y for every start time is one cross-correlation of the recording with the header.

Reading a header then costs a cross-correlation and a few dozen triangular solves.

All five headers share their 610 ms of leader, so every mode explains most of any header. What separates them is the leftover. The reader accepts the best mode only if it explains at least 75% of the audio and leaves at least 1.4 times less unexplained than the runner-up.

The mistake in the first version

The first version scored each candidate over the header plus the 80 ms after it, to give the path room for its tail. Those 80 ms are the first scanline of the picture, which no header explains. A candidate start 70 ms too early pushes most of that picture out of the scoring window and replaces it with silence from before the transmission, so early starts scored better.

The mode was still right every time. The start time was up to 75 ms early, which put the first line's sync outside the decoder's search, and one older recording that used to decode at error 11.4 came out at 45. A regression run over every earlier recording caught it before release.

The fix is to stop the fit at the header's end, which means taking the products that reach past the end back out of the Toeplitz matrix. With that, the estimated start is within 3 ms of the truth on a clean signal. On the real recordings it is within 4 ms of where the digital copy's hiss begins in the laptop file, and within about 10 ms of the bit reader's own start bit in the older recordings where that reader had worked.

Results

RecordingRight mode explainsLeftover vs runner-up
The laptop file, six attempts98.5%5.2–5.9×
Older phone recording, Martin M296.8%3.2×
Older phone recording, Robot 896.7%4.7×
Clean synthetic header99.2%4.8×

Replayed through the new engine, all six attempts start in the right mode: four Robot 36, two Martin M1. Two long real pictures with no header in them start nothing.

Limits

  • Thinner inside the decoder. Those figures are on the raw recording. The live decoder only keeps its own band-filtered, gain-controlled audio, and on that the same headers give about 95% against 91%, a ratio of 1.8. One recording passes at 1.44. Fitting the raw microphone signal would be the obvious next step.
  • It is a second opinion. It runs only when the bit reader has found a start bit and failed to read the code. Simulated paths exist where the bit reader never settles on a start bit and so never asks, and one where it misreads Robot 36 as Martin M2 with full confidence.
  • One room. The thresholds come from one file. Only Robot 36 and Martin M1 were seen through that room.
  • A header is not a picture. Getting the picture started says nothing about how it looks; in that room it still needs repairing afterwards.

Part of the Modem Lab notes · what a room does to an FM picture · a blind equalizer · a digital copy above the picture · back to Notes.