Skip to content

perf(audio): bulk-write captured WAV samples#543

Closed
JustYannicc wants to merge 1 commit into
SuperCmdLabs:mainfrom
JustYannicc:codex/perf-audio-bulk-wav-samples-pr
Closed

perf(audio): bulk-write captured WAV samples#543
JustYannicc wants to merge 1 commit into
SuperCmdLabs:mainfrom
JustYannicc:codex/perf-audio-bulk-wav-samples-pr

Conversation

@JustYannicc

Copy link
Copy Markdown
Collaborator

What changed

  • Convert captured float samples into one contiguous little-endian Int16 PCM buffer before appending it to the WAV Data.
  • Add scripts/test-audio-wav-bulk-write.swift to validate byte-for-byte legacy/bulk WAV output, header/data sizes, and the 30-second 16 kHz mono serialization timing.

Why

stopRecording() and takeSnapshot() both serialize captured WAV data on the native path. Live dictation snapshots call this periodically, so the previous two-byte Data append per sample added avoidable work on every snapshot.

Compatibility impact

  • WAV output remains RIFF/WAVE PCM, mono, 16-bit little-endian samples, using the passed sample rate.
  • Sample clamping/scaling and atomic file write behavior are unchanged.
  • No TypeScript bridge or API shape changes.

How tested

  • swiftc -O -o /tmp/supercmd-audio-capturer-check src/native/audio-capturer.swift -framework AVFoundation -framework Foundation
  • swiftc -O -o /tmp/supercmd-audio-wav-bulk-test scripts/test-audio-wav-bulk-write.swift
  • /tmp/supercmd-audio-wav-bulk-test
    • samples=480000 sampleRate=16000 iterations=5
    • validated byte-for-byte WAV output and header/data sizes
    • per-sample append: 15.27 ms avg checksum=617111545
    • bulk Int16 append: 0.83 ms avg checksum=617111545
    • speedup: 18.34x

Stack validation

@JustYannicc JustYannicc changed the title [codex] perf(audio): bulk-write captured WAV samples perf(audio): bulk-write captured WAV samples Jul 3, 2026
@JustYannicc

Copy link
Copy Markdown
Collaborator Author

Superseded by #556, which consolidates this AI/native media performance batch.

@JustYannicc JustYannicc closed this Jul 3, 2026
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