The analogue audio is turned into a 1-bit signal — either high or low.
The machine then detects positive transitions, counting the amount of time between each. That allows them to be bucketed into one of three types:
- short, which are those closest to a 364 microseconds;
- long, which are those closest to 524 microseconds; and
- mark, which are 684 microseconds.
Each byte is preceded by a byte marker, which is a mark wave and a long wave.
From there onwards, 0s are stored as a short wave followed by a long wave, and 1s are stored as a long wave followed by a short wave, and each byte is completed by an odd parity bit.
So reading a byte is as simple as watching for a mark wave, then tracking the sequence of short and long waves, using the parity bit as confirmation.
All files are also preceded by periods of lead-in tone, which is just a prolonged period of short waves. The computer can use that section to calibrate itself to different tape speeds.
A complete program file then looks like:
- lead-in tone;
- 192 bytes of header;
- those bytes, repeated;
- the program data itself;
- the program data itself, repeated;
- 192 bytes of ending data; and
- those 192 bytes repeated.
Commodore used repeated data as a basic means of checking integrity; it's an outlier in this regard — other micros tend to do more intelligent things but the Commodore ROM just stores bytes directly to their intended destination on first run through, then checks them on the second.