Add real-time audio spectrum visualizer to the TUI#192
Merged
maximmaxim345 merged 14 commits intomainfrom Mar 25, 2026
Merged
Conversation
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>
58c4a7f to
420f6d7
Compare
visualizer@_draft_r1 role in the TUIvisualizer@_draft_r1 role
Contributor
There was a problem hiding this comment.
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
VisualizerHandlerto 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
aiosendspinto~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.
visualizer@_draft_r1 role
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
Adds a real-time frequency spectrum visualizer to the TUI, rendered below the info panels.
While the final
visualizerrole 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
vkey.Screenshot