Skip to content

Add AudioClipDump debugging utility (dump audio buffers to WAV)#307

Open
MaxHeimbrock wants to merge 2 commits into
mainfrom
max/audioclip-wav-dump
Open

Add AudioClipDump debugging utility (dump audio buffers to WAV)#307
MaxHeimbrock wants to merge 2 commits into
mainfrom
max/audioclip-wav-dump

Conversation

@MaxHeimbrock

Copy link
Copy Markdown
Contributor

Standalone debugging utility extracted from the microphone capture investigation, kept for future use.

LiveKit.Internal.AudioClipDump provides:

  • DumpClip(clip, fileName) — snapshot an AudioClip's full contents to a 16-bit PCM WAV in Application.temporaryCachePath (works in editor and on device) and return the path.
  • DumpClipAfter(clip, delaySeconds, fileName) — coroutine helper to dump a looping mic clip a few seconds after capture starts.
  • WriteWav(path, samples, channels, sampleRate) — generic interleaved-float → WAV writer.

Why keep it

A raw clip dump was what cracked the macOS + Bluetooth HFP capture bug (#306): the WAV revealed FMOD writing valid 320-sample audio fragments at a 1024-sample stride with exact-zero padding, while Microphone.GetPosition advanced ~3.2× faster than the data rate. No amount of reasoning about API values (clip.frequency, GetPosition) could show that — inspecting the actual buffer contents settled it in one run. This tool makes that diagnostic a one-liner next time.

No behavioral changes; the class is internal and unused by the runtime path.

🤖 Generated with Claude Code

Extracted from the microphone investigation: snapshots an AudioClip's raw
contents to a 16-bit PCM WAV (plus a generic float[]-to-WAV writer and a
delayed-dump coroutine helper) so buffer contents can be inspected offline.

A raw dump like this was what cracked the macOS + Bluetooth HFP capture bug:
it revealed FMOD writing valid 320-sample fragments at a 1024-sample stride
with exact-zero padding, while GetPosition advanced 3.2x faster than the data
rate — something no amount of reasoning about API values could show. Kept as
a permanent internal tool for future audio debugging.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Required for stable GUIDs when the package is imported.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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