Skip to content

Define what visualizer analysis values describe - #343

Draft
maximmaxim345 wants to merge 4 commits into
mainfrom
fix/visualizer-analysis-values
Draft

maximmaxim345 wants to merge 4 commits into
mainfrom
fix/visualizer-analysis-values

Conversation

@maximmaxim345

@maximmaxim345 maximmaxim345 commented Nov 4, 2026 •

Copy link
Copy Markdown
Member

The visualizer role didn't say which audio a frame's timestamp describes, what 0 dB is, how spectrum bins are laid out, or what lights get on pause. aiosendspin stamps loudness, spectrum and peak at the end of their analysis window, so they lag the audio by 20 to 40 ms while beat lands on time. aiosendspin and sendspin-server-cpp also read a full-scale sine at different levels.

Rules:

  • A frame's timestamp is when the audio it describes plays, and a windowed value describes the middle of its window.
  • Analysis runs on the group's audio without any player's volume or mute.
  • 0 dB is the RMS level of a full-scale square wave, so a full-scale sine reads about -3 dB.
  • Channels are combined by averaging their power, and any smoothing is defined in time rather than in frames.
  • Spectrum bin edges are evenly spaced on the scale from f_min to f_max, the layout both servers already share. Each bin sums the power in its range rather than averaging it, so a tone reads the same in a wide or narrow bin and the bins add up to the full signal. Bins entirely above half the analysis sample rate read 0.
  • An n_disp_bins below 1, an f_min below 0, or an f_min at or above f_max is a protocol error.
  • A server's cap on spectrum bins is at least 256. Above its cap, a server leaves spectrum out of stream/start. sendspin-server-cpp caps at 256 and aiosendspin at 1024.
  • While the group's playback_state is 'stopped', the server sends no visualization messages.

The rest are SHOULDs in the spec rather than implementation guide text, since they change how lights look from one server to the next: give every spectrum bin a level, measure loudness over about 40 ms, and scale peak strength to reach 255 at about 9 dB above the energy of the last 300 ms. Both servers already use a 42.7 ms loudness window and this peak scale.

The analysis sample rate stays up to the server. aiosendspin analyzes at 48 kHz and sendspin-server-cpp at the source rate, which only changes bins above 24 kHz.

kahrendt pushed a commit that referenced this pull request Nov 5, 2026
<!-- Describe the change and why it is needed. -->

A server that can't run another analysis has no compliant way to serve a
new visualizer configuration, such as a fifth spectrum configuration in
a group. Serving a spectrum it already computes breaks the rule that
`spectrum` in `stream/start` matches the client's request. Sending no
visualizer stream also takes away loudness, `beat` and the other types,
which cost almost nothing (what sendspin-server-cpp does today). Leaving
out `spectrum` is only allowed when the current source is the reason.

This drops "for the current source", so a server may leave out any type
it can't stream, whatever the reason. The client still sees from
`stream/start` which types it gets, the same way it already handles any
omitted type.

Related:
- #343

- [x] I accept the [Contributor License
Agreement](../blob/main/CONTRIBUTOR-LICENSE-AGREEMENT.md) for this
contribution.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Next

Development

Successfully merging this pull request may close these issues.

1 participant