Skip to content

feat(audio): visualizer sample tap on the audio engine - #19

Open
rdapaz wants to merge 1 commit into
tornade-player:mainfrom
rdapaz:feat/visualizer-tap
Open

feat(audio): visualizer sample tap on the audio engine#19
rdapaz wants to merge 1 commit into
tornade-player:mainfrom
rdapaz:feat/visualizer-tap

Conversation

@rdapaz

@rdapaz rdapaz commented Aug 8, 2026

Copy link
Copy Markdown

Summary

Adds a real-time-safe visualizer tap so front-ends can render meters or spectra from what is actually playing:

  • The audio callback mirrors every output buffer (post-volume; zeros while paused/stopped) into a fixed 16384-sample lock-free ring in SharedState — relaxed atomic stores only, no locks or allocation on the real-time thread.
  • PlayerService::visualizer_samples(n) returns up to n of the most recent interleaved samples (newest last) plus the stream channel count. Empty when the engine is not initialized.
  • Readers may observe a partially written window; acceptable by design for visualization.

First consumer: the VU meters overlay in tornade-tui (PR to follow, depends on this).

Test plan

  • Two new unit tests: ring returns newest samples last; ring wraps without panicking
  • Full suite: 478 passed on Windows
  • Verified live with the tornade-tui VU overlay: meters track playback, fall silent on pause/stop

🤖 Generated with Claude Code

Mirror every output buffer (post-volume; zeros while paused/stopped)
into a lock-free ring in SharedState, written from the audio callback
with relaxed atomic stores only - no locks or allocation on the
real-time thread. PlayerService::visualizer_samples(n) returns the
most recent interleaved samples plus the stream channel count so
front-ends can render meters or spectra.

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