Repository navigation
Conversation
…offset calibration - AudioCaptureCLI: headless, auto-starts streaming, stops on SIGINT/SIGTERM (replaces the RCS request, #20). Reads GUI .cfg files; flags override. Builds without Qt when a native backend is available. - Capture layer (capture.h) with a runtime registry: PipeWire and ALSA (Linux), CoreAudio (macOS), QtMultimedia fallback. Native backends stamp each buffer with the driver's capture time instead of its arrival time. Measured against hardware ground truth (30 min runs): timestamp SD 953 us (Qt) -> 18 us (PipeWire), 8 us (ALSA) on Linux; 1457 us (Qt) -> 13 us (CoreAudio) on macOS; no backwards timestamp steps. - CaptureSession (was reader.*): Qt-free; a watchdog restarts a failed or stalled backend on the same outlet (#12). - --ts-offset-us / timestamp_offset_us: per-device latency correction, recorded in the stream metadata. - scripts/measure_offset.py and scripts/pi_edge_markers.py, with a README section on measuring the offset against an MCC DAQ or a Raspberry Pi GPIO. - Fix restoring the saved device and settings from the config file (#19).
Stamps each packet with IAudioCaptureClient::GetBuffer's QPC position (device time of the first frame), mapped to steady_clock. Shared mode, event-driven, AUTOCONVERTPCM so any requested format works; warns when Windows resamples, since its resampler adds latency the timestamps do not include. Default API on Windows ahead of QtMultimedia; the CLI builds without Qt there. Builds with MSVC and MinGW. Measured on a Realtek HDA line input (Pi GPIO edges + LSL markers as reference): offset 519-549 us, SD ~9-11 us at the device rate; +0.72 ms through the 44.1 -> 48 kHz resampler.
This was
linked to
issues
Nov 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
AudioCaptureCLI: headless mode that starts streaming at once and stops on SIGINT/SIGTERM. That covers what [Enhancement] RCS functionality #20 asked for, start/stop from scripts, without adding remote control. It reads GUI.cfgfiles, and flags override them. Where a native backend exists it builds without Qt.Pluggable capture layer (
capture.h, runtime registry). New native backends:--api ALSA, exclusive)QtMultimedia stays as the fallback. Each native backend stamps a buffer with the driver's capture time instead of its arrival time.
CaptureSession(wasreader.*, now Qt-free): a watchdog restarts a backend that fails or stops delivering audio, keeping the same outlet (Stream hangs unexpectedly #12).Per-device latency correction:
--ts-offset-us/timestamp_offset_us, the same names App-MeasurementComputing uses. The value is recorded in the stream metadata.Measuring that offset:
scripts/measure_offset.py(XDF analysis) andscripts/pi_edge_markers.py(Raspberry Pi GPIO + LSL markers), plus a README section. The reference can be an MCC DAQ or a Raspberry Pi.Fixes restoring the saved device and sample format from the config file (Sample Format not parsed/recognized when loading configuration #19).
Timestamp accuracy
Square-wave edges were fed into the audio input. Each table compares the backends on the same hardware and input.
Linux (Realtek ALC897 line-in; reference: PTP-synchronized GPIO edge times; 30 min runs):
PipeWire's bias is 0.67 ms higher than ALSA's because PipeWire does not see the HDA driver's 32-frame FIFO delay. The offset setting absorbs it.
macOS (MacBook built-in mic; acoustic click loopback against an MCC DAQ; 30 min runs):
CoreAudio's lag includes the acoustic path.
Windows (same ALC897, Microsoft HDA driver; reference: Pi GPIO + LSL markers): WASAPI 519–549 us across runs, SD 9–11 us, at the device's 44.1 kHz rate. Through Windows' 44.1 to 48 kHz resampler the offset is 0.72 ms higher; the backend now warns when it resamples.
Testing
watchdog_test(ctest) covers stalled backends, backends that error, and a failed start. It passes on macOS, Linux, Windows MSVC and Windows MinGW.--ts-offset-usshifted the timestamps by exactly the set value, on Linux (ALSA) and macOS (CoreAudio).