This project decodes SMPTE Linear Timecode (LTC) from an audio file (WAV format). SMPTE LTC is a format used to encode timecode data as an audio signal, commonly used in video and film post-production to sync devices.
Sure — let’s do a technical breakdown of how the SMPTE LTC Timecode decoder works, based on the code in the ZIP you provided.
To decode SMPTE Linear Timecode (LTC) from a WAV audio file — this involves detecting square wave audio patterns and translating them into binary timecode data.
This is the core decoding engine.
- Implements a zero-crossing detector (to find changes in the waveform).
- Measures the duration between crossings to distinguish between
0and1bits. - Identifies 80-bit LTC frames (with a sync word at the end).
- Parses the frame into timecode (hh:mm:ss:ff).
ltc_decoder_feed(): Accepts PCM samples and detects transitions.ltc_decoder_get_frame(): Retrieves a valid LTC frame once found.ltc_frame_t: Struct that stores decoded timecode data.
Handles bit-level data buffering.
- Buffers incoming bits.
- Detects the LTC sync word (typically
0011111111111101). - Builds a complete 80-bit frame for decoding.
Reads 16-bit PCM WAV files.
- Opens and parses WAV headers.
- Reads audio samples into a buffer.
- Converts stereo to mono if needed.
Provides a user interface or test harness to:
- Load a WAV file.
- Feed its audio samples into the decoder.
- Output the decoded timecodes.
flowchart TD
A[WAV File Loaded] --> B[Read Samples]
B --> C[Zero Crossing Detection]
C --> D[Bit Detection]
D --> E[Bitstream Assembly]
E --> F[Sync Word Match?]
F -- No --> C
F -- Yes --> G[Extract 80-bit Frame]
G --> H[Parse Timecode]
H --> I[Return hh:mm:ss:ff]
- Detects when the audio waveform goes from positive to negative (or vice versa).
- Used to determine the start of a bit period.
- Short duration =
1, long duration =0. - Based on duration between zero crossings.
- The last 16 bits of a valid frame always form a sync word.
- Decoder waits for this pattern to lock on.
A full LTC frame is 80 bits, structured like this:
| Field | Bits |
|---|---|
| Frames | 8 |
| Seconds | 8 |
| Minutes | 8 |
| Hours | 8 |
| User Bits | 32 |
| Sync Word | 16 (fixed) |
Each byte has even parity, and BCD-encoded values (e.g., 4 bits for tens, 4 for units).
This tool:
- Uses audio signal analysis to recover a digital timecode from LTC audio.
- Implements bit parsing, sync detection, and frame decoding entirely in C.
- Has a simple Objective-C interface to test and display results.
Let me know if you want to dive into how a specific part (like the sync word detection or parity check) works line-by-line.