YAACC - UPNP Client and Server
Loading...
Searching...
No Matches
de.yaacc.snapcast.control.GroupVolume Class Reference

The volume of a group, which the server does not have: the average of the members' percentages. More...

Collaboration diagram for de.yaacc.snapcast.control.GroupVolume:
Collaboration graph

Static Public Member Functions

static Map< String, Integer > levels (SnapcastGroup group)
 The members that play now (connected ones), in the order of the group, by id.
 
static int average (Map< String, Integer > levels)
 
static Map< String, Integer > apply (Map< String, Integer > start, int delta)
 Moves every member by delta points.
 
static Map< String, Integer > target (Map< String, Integer > start, int newAverage)
 Sets the group to a new average: the members move by the difference between the new and the current average.
 
static Map< String, Integer > changes (Map< String, Integer > start, Map< String, Integer > current, int newAverage)
 The members to set for a new group average, as a drag needs it: the targets are calculated from the levels at the start of the drag (so the steps do not add up and every member can return to its own level), and only the members whose target differs from their current level are returned.
 

Detailed Description

The volume of a group, which the server does not have: the average of the members' percentages.

Setting a new group volume moves every member by the same number of points, so the members keep their relative levels. A member that would pass 0 or 100 stops there, and the points that did not fit are shared by the members that still have room (repeated until everything is placed or everyone is at the edge), so the average still reaches the wanted value where the scale allows. The mute flag is not part of the calculation: a muted member moves with the others and stays muted (the caller keeps its flag). Pure.

Style and idea as de.yaacc.yxc.YxcGroupVolume: compute from the levels at the start of a drag, not from the last step, and dragging back restores every member's own level.

Member Function Documentation

◆ apply()

static Map< String, Integer > de.yaacc.snapcast.control.GroupVolume.apply ( Map< String, Integer > start,
int delta )
static

Moves every member by delta points.

Parameters
startthe levels when the move began
deltathe change in percentage points (negative: down)
Returns
the new level of each member, all within 0..100; the sum is the start sum plus delta times the number of members, as far as the scale allows

Referenced by de.yaacc.snapcast.control.GroupVolume.target().

Here is the caller graph for this function:

◆ average()

static int de.yaacc.snapcast.control.GroupVolume.average ( Map< String, Integer > levels)
static
Returns
the average in percent, rounded half up; -1 when there are no members

Referenced by de.yaacc.snapcast.feed.SnapcastFeedController.getVolume(), de.yaacc.snapcast.ui.SnapcastRowText.of(), and de.yaacc.snapcast.control.GroupVolume.target().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ changes()

static Map< String, Integer > de.yaacc.snapcast.control.GroupVolume.changes ( Map< String, Integer > start,
Map< String, Integer > current,
int newAverage )
static

The members to set for a new group average, as a drag needs it: the targets are calculated from the levels at the start of the drag (so the steps do not add up and every member can return to its own level), and only the members whose target differs from their current level are returned.

A member that is not in both maps (it left or joined meanwhile, or went offline) is not touched.

Parameters
startthe levels when the drag began, see levels
currentthe levels now
newAverageclamped into 0..100
Returns
the new level by client id, in the order of start

Referenced by de.yaacc.snapcast.control.SnapcastOperations.setGroupVolume().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ target()

static Map< String, Integer > de.yaacc.snapcast.control.GroupVolume.target ( Map< String, Integer > start,
int newAverage )
static

Sets the group to a new average: the members move by the difference between the new and the current average.

Parameters
newAverageclamped into 0..100

Referenced by de.yaacc.snapcast.control.GroupVolume.changes().

Here is the call graph for this function:
Here is the caller graph for this function:

The documentation for this class was generated from the following file: