Skip to content

1.0.6: output audio at 29.97 / 59.94 frames/s on the TAI sample grid - #24

Merged
LeeO86 merged 1 commit into
mainfrom
fix/audio-ntsc-rates
Oct 16, 2026
Merged

LeeO86 merged 1 commit into
mainfrom
fix/audio-ntsc-rates

Conversation

@LeeO86

@LeeO86 LeeO86 commented Oct 16, 2026 •

Copy link
Copy Markdown
Owner

Rebased on main after #23 (3668151).

Bug (pre-existing): an output's audio read position was frame index × floor(48000 / frame rate) (output_channel.cpp 528, 620, 653, 963, 1127, 1224). At 29.97 that is 1601 instead of 1601.6 samples per frame, at 59.94 800 instead of 800.8. At today's TAI frame indexes the position is about 7.8 days (29.97) or 20.7 days (59.94) behind the sample index the sources write, far outside the ring, so every 29.97/59.94 output (progressive or interlaced) played silence for good.

Fix:

  • The audio position is a frame number (_audioEndFrame). Frame k's block runs from util::audioSampleIndexOfFrame(rate, k) = mxlTimestampToIndex(48000, mxlIndexToTimestamp(rate, k)) to the same for k + 1: the 1602/1601 cadence at 29.97 and 801/800 at 59.94 (8008 / 4004 samples per 5 frames). Slips, catch-ups, preroll and the out-of-ring reset move the frame number as before.
  • PCM scratch buffers are reserved for the largest block (ceil(48000 / rate)) at bring-up; the read-offset cap uses the largest block.
  • Whole rates are byte-identical: the unit test checks that at today's TAI indexes the sample index is exactly k × 1920 / 960 / 2000 / 1600 / 800 / 2002 at 25 / 50 / 24 / 30 / 60 / 23.98.

Tests (120/120 locally):

  • Block math: whole rates identical to before; 29.97/59.94 cadence, 5-frame sums, within one sample of the TAI time (and the old formula days away).
  • Outputs at HD720p59.94 and HD1080p29.97 with a stamped audio source on the fake card: sound in the blocks, every block 800/801 resp. 1601/1602, in sync with the video.
  • 1.0.5: interlaced video follows the shared field-per-grain convention #23's interlaced output test now requires sound for NTSC (29.97) too, and its block-size check accepts the 1601/1602 cadence. Passes (PAL and NTSC, 3 of 3 runs).
  • NMOS ANC source grain_rate uses ancRateOf like its flow (field rate for interlaced modes).

Version 1.0.6 (CMakeLists, version.hpp, deploy manifest), CHANGELOG, SPECIFICATION §2.4 lip-sync text.

🤖 Generated with Claude Code

https://claude.ai/code/session_01St7QwmonpoG9EEEqaLFXLi

The output's audio read position was frame index x floor(48000 / rate)
samples: 1601 instead of 1601.6 at 29.97, 800 instead of 800.8 at 59.94.
At today's TAI frame indexes that is 7.8 resp. 20.7 days behind the sample
index the sources write, so these outputs played silence for good.

The position is now a frame number; each frame's block runs from the 48 kHz
sample index of the frame's TAI start to that of the next frame
(mxlTimestampToIndex(48000, mxlIndexToTimestamp(frame rate, k))), giving the
1602/1601 and 801/800 cadence. Scratch buffers are reserved for the largest
block, and the read-offset cap uses it. Whole rates (25, 50, 24, 30, 60,
23.98) give exactly the same sample indexes as before.

Rebased on #23: its interlaced output test now requires sound for NTSC
too, and the NMOS ANC source's grain_rate uses the field rate like its
flow (ancRateOf).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01St7QwmonpoG9EEEqaLFXLi
@LeeO86
LeeO86 force-pushed the fix/audio-ntsc-rates branch from db634c5 to 2272cba Compare October 16, 2026 10:07
@LeeO86
LeeO86 merged commit 06fdddc into main Oct 16, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant