Skip to content

Add real-time audio spectrum visualizer to the TUI#192

Merged
maximmaxim345 merged 14 commits intomainfrom
feat/visualizer
Mar 25, 2026
Merged

Add real-time audio spectrum visualizer to the TUI#192
maximmaxim345 merged 14 commits intomainfrom
feat/visualizer

Conversation

@maximmaxim345
Copy link
Copy Markdown
Member

@maximmaxim345 maximmaxim345 commented Mar 23, 2026

Summary

Adds a real-time frequency spectrum visualizer to the TUI, rendered below the info panels.
While the final visualizer role isn't part of the Sendspin Spec yet.
This uses the first WIP version of the role (with role id visualizer@_draft_r1) from this PR, available in Music Assistant 2.8.

The spectrum and loudness data is computed on the server, and then sent through the Sendspin protocol.

Toggle it by pressing the v key.

Screenshot

image

@maximmaxim345 maximmaxim345 added the new-feature Request or implement a new feature label Mar 24, 2026
maximmaxim345 and others added 11 commits March 24, 2026 12:30
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…zer toggle

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
… crash

When toggling the visualizer during an in-flight connection, the
cancelled connect task's CancelledError would propagate unhandled
and shut down the app. By setting the current server as pending,
_connect_cancellable catches it as ServerSwitchRequested and the
connection loop gracefully reconnects.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Update CommandHandler instantiation in test_volume_state.py to use
get_client callable parameter instead of the removed client keyword
argument, following the API change in f21c71b.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
When the visualizer role is active, the server sends two separate
stream/start messages — one for player and one for visualizer. The
audio and visualizer handlers were unconditionally clearing their
buffers on every stream/start, so the second (visualizer) stream/start
would wipe the player's catch-up audio buffer, causing silence.

Now each handler checks whether the stream/start is relevant to its
role before acting.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The cherry-picked stream/start role check made the existing test fail
because it passed a bare object() instead of a message with payload.
Fixed the test and added a new one verifying that a visualizer-only
stream/start does not touch the audio worker.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@maximmaxim345 maximmaxim345 marked this pull request as ready for review March 25, 2026 14:06
Copilot AI review requested due to automatic review settings March 25, 2026 14:06
@maximmaxim345 maximmaxim345 changed the title WIP: Add support for the visualizer@_draft_r1 role in the TUI Add support for the visualizer@_draft_r1 role Mar 25, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds end-to-end plumbing to display a server-provided spectrum visualizer in the Rich TUI, including a new connector that listens for visualizer frames, UI rendering/state, and keyboard toggling.

Changes:

  • Introduces VisualizerHandler to consume visualizer frames and feed the TUI.
  • Adds visualizer state + rendering (spectrum bars, loudness-based colors, peak hold) and integrates it into SendspinUI.
  • Updates TUI app/keyboard flow to support toggling the visualizer and reconnecting with the visualizer role enabled; bumps aiosendspin to ~4.4.

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 9 comments.

Show a summary per file
File Description
tests/tui/test_volume_state.py Updates CommandHandler construction to the new get_client API.
tests/tui/test_visualizer.py Adds unit tests for loudness color tiers, peak-hold behavior, and spectrum rendering.
tests/test_audio_connector.py Extends tests to ensure visualizer-only stream events don’t affect the audio worker.
sendspin/visualizer_connector.py New connector bridging Sendspin visualizer frames to the TUI.
sendspin/tui/visualizer.py New visualizer state + Rich rendering utilities.
sendspin/tui/ui.py Integrates visualizer into layout, refresh scheduling, and UI update methods.
sendspin/tui/keyboard.py Switches to get_client() indirection and adds v keybinding for visualizer toggling.
sendspin/tui/app.py Adds visualizer role/support negotiation, handler attach/detach, and reconnect-on-toggle behavior.
sendspin/settings.py Persists visualizer enabled state in settings.
sendspin/audio_connector.py Ignores stream/start messages that are not for the player role.
pyproject.toml Bumps aiosendspin dependency to ~=4.4.
README.md Documents the visualizer feature and how to enable it.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@maximmaxim345 maximmaxim345 changed the title Add support for the visualizer@_draft_r1 role Add real-time audio spectrum visualizer to the TUI Mar 25, 2026
@maximmaxim345 maximmaxim345 merged commit 3ad0278 into main Mar 25, 2026
1 check passed
@maximmaxim345 maximmaxim345 deleted the feat/visualizer branch March 25, 2026 14:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

new-feature Request or implement a new feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants