Skip to content

Commit b2379f0

Browse files
Swap "buffer" verbiage to "overflow"
1 parent 2c7b7a5 commit b2379f0

File tree

6 files changed

+19
-19
lines changed

6 files changed

+19
-19
lines changed

amplipi/ctrl.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -852,13 +852,13 @@ def set_vol():
852852
# Field precedence: vol (db) > vol_delta > vol (float)
853853
# NOTE: checks happen in reverse precedence to cover default case of unchanged volume
854854
if update.vol_delta_f is not None and update.vol is None:
855-
true_vol_f = zone.vol_f + zone.vol_f_buffer
855+
true_vol_f = zone.vol_f + zone.vol_f_overflow
856856
totaled_delta = update.vol_delta_f + true_vol_f
857857
applied_delta = utils.clamp(totaled_delta, 0, 1)
858858

859859
vol_db = utils.vol_float_to_db(applied_delta, zone.vol_min, zone.vol_max)
860860
vol_f_new = applied_delta
861-
zone.vol_f_buffer = 0 if models.MIN_VOL_F < totaled_delta and totaled_delta < models.MAX_VOL_F else utils.clamp((totaled_delta - applied_delta), -1.0, 1.0)
861+
zone.vol_f_overflow = 0 if models.MIN_VOL_F < totaled_delta and totaled_delta < models.MAX_VOL_F else utils.clamp((totaled_delta - applied_delta), -1.0, 1.0)
862862

863863
elif update.vol_f is not None and update.vol is None:
864864
clamp_vol_f = utils.clamp(vol_f, 0, 1)
@@ -875,7 +875,7 @@ def set_vol():
875875
else:
876876
raise Exception('unable to update zone volume')
877877

878-
zone.vol_f_buffer = 0 if models.MIN_VOL_F < vol_f_new and vol_f_new < models.MAX_VOL_F else zone.vol_f_buffer
878+
zone.vol_f_overflow = 0 if models.MIN_VOL_F < vol_f_new and vol_f_new < models.MAX_VOL_F else zone.vol_f_overflow
879879

880880
# To avoid potential unwanted loud output:
881881
# If muting, mute before setting volumes

amplipi/defaults.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,17 +41,17 @@
4141
],
4242
"zones": [ # this is an array of zones, array length depends on # of boxes connected
4343
{"id": 0, "name": "Zone 1", "source_id": 0, "mute": True, "disabled": False,
44-
"vol_f": models.MIN_VOL_F, "vol_f_buffer": 0.0, "vol_min": models.MIN_VOL_DB, "vol_max": models.MAX_VOL_DB},
44+
"vol_f": models.MIN_VOL_F, "vol_f_overflow": 0.0, "vol_min": models.MIN_VOL_DB, "vol_max": models.MAX_VOL_DB},
4545
{"id": 1, "name": "Zone 2", "source_id": 0, "mute": True, "disabled": False,
46-
"vol_f": models.MIN_VOL_F, "vol_f_buffer": 0.0, "vol_min": models.MIN_VOL_DB, "vol_max": models.MAX_VOL_DB},
46+
"vol_f": models.MIN_VOL_F, "vol_f_overflow": 0.0, "vol_min": models.MIN_VOL_DB, "vol_max": models.MAX_VOL_DB},
4747
{"id": 2, "name": "Zone 3", "source_id": 0, "mute": True, "disabled": False,
48-
"vol_f": models.MIN_VOL_F, "vol_f_buffer": 0.0, "vol_min": models.MIN_VOL_DB, "vol_max": models.MAX_VOL_DB},
48+
"vol_f": models.MIN_VOL_F, "vol_f_overflow": 0.0, "vol_min": models.MIN_VOL_DB, "vol_max": models.MAX_VOL_DB},
4949
{"id": 3, "name": "Zone 4", "source_id": 0, "mute": True, "disabled": False,
50-
"vol_f": models.MIN_VOL_F, "vol_f_buffer": 0.0, "vol_min": models.MIN_VOL_DB, "vol_max": models.MAX_VOL_DB},
50+
"vol_f": models.MIN_VOL_F, "vol_f_overflow": 0.0, "vol_min": models.MIN_VOL_DB, "vol_max": models.MAX_VOL_DB},
5151
{"id": 4, "name": "Zone 5", "source_id": 0, "mute": True, "disabled": False,
52-
"vol_f": models.MIN_VOL_F, "vol_f_buffer": 0.0, "vol_min": models.MIN_VOL_DB, "vol_max": models.MAX_VOL_DB},
52+
"vol_f": models.MIN_VOL_F, "vol_f_overflow": 0.0, "vol_min": models.MIN_VOL_DB, "vol_max": models.MAX_VOL_DB},
5353
{"id": 5, "name": "Zone 6", "source_id": 0, "mute": True, "disabled": False,
54-
"vol_f": models.MIN_VOL_F, "vol_f_buffer": 0.0, "vol_min": models.MIN_VOL_DB, "vol_max": models.MAX_VOL_DB},
54+
"vol_f": models.MIN_VOL_F, "vol_f_overflow": 0.0, "vol_min": models.MIN_VOL_DB, "vol_max": models.MAX_VOL_DB},
5555
],
5656
"groups": [
5757
],

amplipi/models.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,8 @@ class fields_w_default(SimpleNamespace):
111111
Volume = Field(default=MIN_VOL_DB, ge=MIN_VOL_DB, le=MAX_VOL_DB, description='Output volume in dB')
112112
VolumeF = Field(default=MIN_VOL_F, ge=MIN_VOL_F, le=MAX_VOL_F,
113113
description='Output volume as a floating-point scalar from 0.0 to 1.0 representing MIN_VOL_DB to MAX_VOL_DB')
114-
VolumeFBuffer = Field(default=0.0, ge=(MIN_VOL_F - MAX_VOL_F), le=(MAX_VOL_F - MIN_VOL_F),
115-
description='Output volume as a floating-point scalar that has a range equal to MIN_VOL_F - MAX_VOL_F in both directions from zero, and is used to keep track of the relative distance between two or more zone volumes when they would otherwise have to exceed their VOL_F range')
114+
VolumeFOverflow = Field(default=0.0, ge=(MIN_VOL_F - MAX_VOL_F), le=(MAX_VOL_F - MIN_VOL_F),
115+
description='Output volume as a floating-point scalar that has a range equal to MIN_VOL_F - MAX_VOL_F in both directions from zero, and is used to keep track of the relative distance between two or more zone volumes when they would otherwise have to exceed their VOL_F range')
116116
VolumeMin = Field(default=MIN_VOL_DB, ge=MIN_VOL_DB, le=MAX_VOL_DB,
117117
description='Min output volume in dB')
118118
VolumeMax = Field(default=MAX_VOL_DB, ge=MIN_VOL_DB, le=MAX_VOL_DB,
@@ -323,7 +323,7 @@ class Zone(Base):
323323
mute: bool = fields_w_default.Mute
324324
vol: int = fields_w_default.Volume
325325
vol_f: float = fields_w_default.VolumeF
326-
vol_f_buffer: float = fields_w_default.VolumeFBuffer
326+
vol_f_overflow: float = fields_w_default.VolumeFOverflow
327327
vol_min: int = fields_w_default.VolumeMin
328328
vol_max: int = fields_w_default.VolumeMax
329329
disabled: bool = fields_w_default.Disabled

web/src/App.jsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,11 @@ export const useStatusStore = create((set, get) => ({
5050
applyPlayerVol(vol, zones, sourceId, (zone_id, new_vol) => {
5151
for (const i in s.status.zones) {
5252
if (s.status.zones[i].id === zone_id) {
53-
let true_vol = Math.round((new_vol + s.status.zones[i].vol_f_buffer) * 100) / 100;
53+
let true_vol = Math.round((new_vol + s.status.zones[i].vol_f_overflow) * 100) / 100;
5454
let clamped = Math.min(Math.max(true_vol, 0), 1);
5555

5656
s.status.zones[i].vol_f = clamped;
57-
s.status.zones[i].vol_f_buffer = true_vol - clamped;
57+
s.status.zones[i].vol_f_overflow = true_vol - clamped;
5858
}
5959
}
6060
});
@@ -174,7 +174,7 @@ export const useStatusStore = create((set, get) => ({
174174
const g = s.status.groups.filter((g) => g.id === groupId)[0];
175175
for (const i of g.zones) {
176176
s.skipUpdate = true;
177-
s.status.zones[i].vol_f = new_vol + s.status.zones[i].vol_f_buffer;
177+
s.status.zones[i].vol_f = new_vol + s.status.zones[i].vol_f_overflow;
178178
}
179179

180180
updateGroupVols(s);
@@ -208,7 +208,7 @@ export const useStatusStore = create((set, get) => ({
208208
const updateGroupVols = (s) => {
209209
s.status.groups.forEach((g) => {
210210
if (g.zones.length > 1) {
211-
const vols = g.zones.map((id) => s.status.zones[id].vol_f + s.status.zones[id].vol_f_buffer);
211+
const vols = g.zones.map((id) => s.status.zones[id].vol_f + s.status.zones[id].vol_f_overflow);
212212
let calculated_vol = Math.min(...vols) * 0.5 + Math.max(...vols) * 0.5;
213213
g.vol_f = calculated_vol;
214214
} else if (g.zones.length == 1) {

web/src/components/CardVolumeSlider/CardVolumeSlider.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const getPlayerVol = (sourceId, zones) => {
1111
let n = 0;
1212
for (const i of getSourceZones(sourceId, zones)) {
1313
n += 1;
14-
vol += i.vol_f + i.vol_f_buffer; // Add buffer to retain proper relative space when doing an action that would un-overload the slider
14+
vol += i.vol_f + i.vol_f_overflow; // Add buffer to retain proper relative space when doing an action that would un-overload the slider
1515
}
1616

1717
const avg = vol / n;

web/src/components/GroupVolumeSlider/GroupVolumeSlider.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ const GroupVolumeSlider = ({ groupId, sourceId, groupsLeft }) => {
2222
const setGroupMute = useStatusStore(s => s.setGroupMute);
2323
const [slidersOpen, setSlidersOpen] = React.useState(false);
2424

25-
const getVolume = () => { // Make sure group sliders account for vol_f_buffer
25+
const getVolume = () => { // Make sure group sliders account for vol_f_overflow
2626
let v = 0;
2727
for(let i = 0; i < group.zones.length; i++){
28-
v += (zones[group.zones[i]].vol_f + zones[group.zones[i]].vol_f_buffer);
28+
v += (zones[group.zones[i]].vol_f + zones[group.zones[i]].vol_f_overflow);
2929
}
3030

3131
return v / group.zones.length;

0 commit comments

Comments
 (0)