Skip to content

Move repeat and shuffle states to controller state - #81

Merged
kahrendt merged 1 commit into
mainfrom
move-repeat-shuffle-state
Apr 27, 2026
Merged

kahrendt merged 1 commit into
mainfrom
move-repeat-shuffle-state

Conversation

@kahrendt

Copy link
Copy Markdown
Contributor

These two states seem out of place for the metadata role, as they don't describe more textual details about the current playing audio. They do describe how the audio will playback (much like how volume and mute states describe it), and they are group wide settings. This PR moves those two fields to the controller state and makes them always required fields.

@kahrendt

Copy link
Copy Markdown
Contributor Author

Metadata describes what is playing. Controller describes how it is playing.

@maximmaxim345

maximmaxim345 commented Apr 27, 2026 •

Copy link
Copy Markdown
Member

Metadata describes what is playing. Controller describes how it is playing.

Makes sense! At least more sense than what it was before.
Should we add this to the Spec as well then? So we don't forget how to split "metadata" between both roles if we ever need to add more fields? But this PR might already be good enough as a documentation for the reasoning.

The only other consistent alternative I can think of that is putting everything into the metadata state.
But then you have a controller role where you can only write the group volume without ever knowing what the actual volume is right now. That sounds even more backwards.

@chrisuthe

Copy link
Copy Markdown
Member

I agree, this is the right way to approach, I think previously the spec awkwardly tried to keep the controller role mostly focused on the command behavior, and less about getting data back from the Server. There isn't a reason that existing split should be continued imho. We do need to update the spec + website though, to match.

@kahrendt
kahrendt merged commit 5e2c7bc into main Apr 27, 2026
@kahrendt

Copy link
Copy Markdown
Contributor Author

Thanks!

Makes sense! At least more sense than what it was before. Should we add this to the Spec as well then? So we don't forget how to split "metadata" between both roles if we ever need to add more fields? But this PR might already be good enough as a documentation for the reasoning.

I didn't see a great spot for adding that to the spec in general, we don't really have a pattern for the "why" questions in the spec itself. Maybe we should consider adding some supplemental document that we can update that has more context on how/why we made certain decisions.

@chrisuthe Would you mind handling the website update? I think there are now a few things out of date (a couple weeks ago didn't we discuss that the pause state was still there? Maybe that's been fixed though)

@kahrendt
kahrendt deleted the move-repeat-shuffle-state branch April 27, 2026 14:55
kahrendt added a commit to Sendspin/sendspin-cpp that referenced this pull request May 7, 2026
Breaking change!

Moves repeat and shuffle status from the metadata state to the
controller state to match the latest spec:
Sendspin/spec#81
maximmaxim345 added a commit to Sendspin/aiosendspin that referenced this pull request May 29, 2026
After [Sendspin/spec#81](Sendspin/spec#81),
`repeat` and `shuffle` now belong to the state object of the controller
role instead of the metadata role.

For now the existing `metadata.repeat` / `metadata.shuffle` are kept for
backwards compatibility with clients that haven't moved to the new
format yet. This will be removed in a future PR.

# Breaking changes

* `MetadataGroupRole.update(repeat=...)` / `update(shuffle=...)` no
longer exist. Use `ControllerGroupRole.set_repeat` / `set_shuffle`
instead.
* `ControllerStatePayload` requires `repeat` and `shuffle` when
constructed directly.
MarvinSchenkel pushed a commit to music-assistant/server that referenced this pull request Jun 1, 2026
#4042)

Implements the `visualizer@v1` role on the Sendspin server and updates
Music Assistant to aiosendspin 6.0.1. The older `visualizer@_draft_r1`
role is left unchanged and still carries no beats. Clients connecting
with the `visualizer@_draft_r1` role still remain fully functional.

## Visualizer

The Sendspin player derives a per-track beat schedule from `smart_fades`
analysis and streams it to visualizer clients over `visualizer@v1`. The
Hue Entertainment plugin is reworked to use the v1 role, including
beat-based colour cycling with selectable modes.
Older clients using `visualizer@_draft_r1` stay fully compatible after
this PR.

## Player timing

Reports each player's lead-time and live-source hints to the push stream
so it schedules the first chunk far enough ahead. This stops the AirPlay
bridge from cutting off the start of a track.
Older clients not implementing this stay fully compatible after this PR.

## Repeat and shuffle

Repeat and shuffle now ride on controller state, following the
aiosendspin 6.0 move off metadata. The server sets the controller state
and keeps the legacy metadata copy in sync so older and newer clients
both work.

## Known limitations

The Hue plugin's beat effects need the track's beat analysis. On the
first play of a track whose analysis has not been computed yet, the
lights use the peak and onset fallback for the first stretch (up to
~30s) until beats arrive.

During a smart-fades transition the beats of the crossfading tracks are
used as is and can drift slightly while the two tracks overlap.
Alignment is correct again once the transition completes.

The Hue bridge uses a small visualizer buffer for near-realtime
delivery, so after a track change beats take a few seconds to start
arriving (the first moments of the new schedule are kept near the
playhead and not delivered yet). The lights use the peak and onset
fallback until they do.

Beat data is loaded by a lightweight retry poller rather than an
audio-analysis event subscription. This is intentional, to keep the
changes contained to the Sendspin provider and avoid touching core Music
Assistant code before the 2.9 release.

Visualizer pitch detection is disabled server-wide for now. It is the
heaviest visualizer DSP and its result quality is still mixed, so it
needs more testing before being enabled.

## Relevant Specification this PR implements
- Sendspin/spec#86
- Sendspin/spec#69
- Sendspin/spec#81

## Testing

I tested this locally, on a Raspberry Pi 4, and a Home Assistant Green.
Lower powered clients may not be powerful enough to compute `beats` in
time, but the Hue bridge falls back to `peaks` if thats the case.
chrisuthe pushed a commit to music-assistant/server that referenced this pull request Jun 7, 2026
#4042)

Implements the `visualizer@v1` role on the Sendspin server and updates
Music Assistant to aiosendspin 6.0.1. The older `visualizer@_draft_r1`
role is left unchanged and still carries no beats. Clients connecting
with the `visualizer@_draft_r1` role still remain fully functional.

## Visualizer

The Sendspin player derives a per-track beat schedule from `smart_fades`
analysis and streams it to visualizer clients over `visualizer@v1`. The
Hue Entertainment plugin is reworked to use the v1 role, including
beat-based colour cycling with selectable modes.
Older clients using `visualizer@_draft_r1` stay fully compatible after
this PR.

## Player timing

Reports each player's lead-time and live-source hints to the push stream
so it schedules the first chunk far enough ahead. This stops the AirPlay
bridge from cutting off the start of a track.
Older clients not implementing this stay fully compatible after this PR.

## Repeat and shuffle

Repeat and shuffle now ride on controller state, following the
aiosendspin 6.0 move off metadata. The server sets the controller state
and keeps the legacy metadata copy in sync so older and newer clients
both work.

## Known limitations

The Hue plugin's beat effects need the track's beat analysis. On the
first play of a track whose analysis has not been computed yet, the
lights use the peak and onset fallback for the first stretch (up to
~30s) until beats arrive.

During a smart-fades transition the beats of the crossfading tracks are
used as is and can drift slightly while the two tracks overlap.
Alignment is correct again once the transition completes.

The Hue bridge uses a small visualizer buffer for near-realtime
delivery, so after a track change beats take a few seconds to start
arriving (the first moments of the new schedule are kept near the
playhead and not delivered yet). The lights use the peak and onset
fallback until they do.

Beat data is loaded by a lightweight retry poller rather than an
audio-analysis event subscription. This is intentional, to keep the
changes contained to the Sendspin provider and avoid touching core Music
Assistant code before the 2.9 release.

Visualizer pitch detection is disabled server-wide for now. It is the
heaviest visualizer DSP and its result quality is still mixed, so it
needs more testing before being enabled.

## Relevant Specification this PR implements
- Sendspin/spec#86
- Sendspin/spec#69
- Sendspin/spec#81

## Testing

I tested this locally, on a Raspberry Pi 4, and a Home Assistant Green.
Lower powered clients may not be powerful enough to compute `beats` in
time, but the Hue bridge falls back to `peaks` if thats the case.
maximmaxim345 added a commit to Sendspin/aiosendspin that referenced this pull request Oct 5, 2026
# What does this implement/fix?

<!-- Quick description and explanation of changes. -->

Since #408, the server no longer copies `repeat` and `shuffle` into the
metadata object, so clients that still read them there lose both. This
affects sendspin-cli, Sendspin-TUI and SendspinKit, and the sendspin-cli
TUI shows no repeat or shuffle state against a 10.0.0 server.

Legacy clients (unencrypted, or sending `trust_level` or player
`supported_commands` in their hello) now get both fields in metadata
again, and metadata is resent to them when either changes. Current
clients still only get them in the controller object.

**Related issue or spec PR (if applicable):**

- Sendspin/spec#81

## Types of changes

<!--
Tick exactly one box. CI (.github/workflows/pr-labels.yaml) applies the
matching label, and the release notes use it to sort this change.
-->

- [x] Bugfix (non-breaking change which fixes an issue): `bugfix`
- [ ] New feature (non-breaking change which adds functionality):
`new-feature`
- [ ] Enhancement to an existing feature: `enhancement`
- [ ] Breaking change (changes the public API or the protocol in a way
that is not backwards compatible): `breaking-change`
- [ ] Refactor (no behavior change): `refactor`
- [ ] Documentation only: `documentation`
- [ ] Maintenance / chore: `maintenance`
- [ ] CI / workflow change: `ci`
- [ ] Dependencies bump: `dependencies`
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.

3 participants