hetzel.net

Binary Phase-Shift Keying

Acoustic Coupler

I'm currently chasing down an iOS bug that seemingly randomly drops or skips audio during transmission. Whatever it's doing, it sounds broken. But how much audio is being skipped, or duplicated, and where exactly? What's actually happening?

A job for binary phase-shift keying!

We generate a pseudorandom sequence of bits that we can recognize again after transmission. We can search for this bit sequence later, using it as a timecode.

101011 111100
chip (ms):  0  1  2  3  4  5
left bit:   1  0  1  0  1  1
right bit:  1  1  1  1  0  0
pair:      11 01 11 01 10 10

Each bit selects one of two phase positions: 0° or 180°. The left and right channels are handled separately, using different carrier frequencies. We generate chips with a length of 48 samples per bit. At a sample rate of 48 kHz, this gives the chip sequence a time resolution of 1 ms.

And just like that, we've built the world's most boring 2000 baud modem. It sounds like one, too:

We send this audio signal through the unreliable transmission path, record the result, and then search for the pseudorandom timecode in the recording. The detector shows how far the source time has jumped relative to the recording time, allowing us to measure skipped or repeated sections of the source audio.

This timing information provided the crucial clue for a workaround for the bug, at least.

And now I also have this fancy audio player for the blog, which conveniently generates the waveform peaks during upload.