Skip to content

Commit

Permalink
ui: show whether people are muted
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffkaufman committed Jan 30, 2021
1 parent d74ea88 commit 7d10de8
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 6 deletions.
12 changes: 12 additions & 0 deletions html/demo.js
Original file line number Diff line number Diff line change
Expand Up @@ -1092,6 +1092,7 @@ function update_active_users(
const mic_volume = user_summary[i][2];
const userid = user_summary[i][3];
const rms_volume = user_summary[i][4];
const muted = user_summary[i][5];

let est_bucket = estimateBucket(offset_s);
if (!showBuckets) {
Expand Down Expand Up @@ -1129,6 +1130,14 @@ function update_active_users(

const participantDiv = participantDivs[userid];
const displayName = userid == myUserid ? (name + " (me)") : name;
if (participantDiv) {
if (muted) {
participantDiv.classList.add("muted");
} else {
participantDiv.classList.remove("muted");
}
}

if (participantDiv && participantDiv.name != displayName) {
// First child is always participantInfo.
participantDiv.children[0].innerText = displayName;
Expand Down Expand Up @@ -1829,6 +1838,9 @@ async function start_singing() {
window.bpr.value = server_bpr;
last_server_bpr = server_bpr;
}
if (micPaused) {
singer_client.x_send_metadata("muted", 1);
}
singer_client.x_send_metadata("user_summary", 1);
if (in_spectator_mode) {
singer_client.x_send_metadata("spectator", 1);
Expand Down
3 changes: 3 additions & 0 deletions html/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,9 @@
.dominant-speaker {
border: 1px solid #0b0;
}
.muted {
border: 1px solid #d00;
}
.participantInfo {
margin: 0.25em;
}
Expand Down
7 changes: 6 additions & 1 deletion html/net.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,12 @@ export class ServerConnection extends ServerConnectionBase {
0, /*littleEndian=*/false);
pos += 2;

metadata.user_summary.push([delay, name, mic_volume, userid, rms_volume]);
const muted =
new DataView(data.slice(pos, pos + 1)).getUint8(0);
pos += 1;

metadata.user_summary.push([
delay, name, mic_volume, userid, rms_volume, muted]);
}
data = data.slice(pos);
}
Expand Down
15 changes: 10 additions & 5 deletions server.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@
# 4 mic_volume: float32,
# 4 rms_volume: float32
# 2 delay: uint16
BINARY_USER_CONFIG_FORMAT = struct.Struct(">Q32sffH")
# 1 muted: boolean
BINARY_USER_CONFIG_FORMAT = struct.Struct(">Q32sffH?")

FRAME_SIZE = 128

Expand Down Expand Up @@ -353,6 +354,7 @@ def __init__(self, userid, name, last_heard_server_clock, delay_samples) -> None
self.client_telemetry = {} # unstructured info from client

self.in_spectator_mode = False;
self.muted = False;

self.mark_sent()

Expand Down Expand Up @@ -619,7 +621,8 @@ def user_summary(requested_user_summary) -> List[Any]:
user.name,
user.mic_volume,
user.userid,
user.rms_volume))
user.rms_volume,
user.muted))
summary.sort()
return summary

Expand All @@ -638,7 +641,7 @@ def binary_user_summary(summary):
compact by only sending names if they have changed.
"""
binary_summaries = [struct.pack(">H", len(summary))]
for delay, name, mic_volume, userid, rms_volume in summary:
for delay, name, mic_volume, userid, rms_volume, muted in summary:
# delay is encoded as a uint16
if delay < 0:
delay = 0
Expand All @@ -650,7 +653,8 @@ def binary_user_summary(summary):
name.encode('utf8'),
mic_volume,
rms_volume,
delay))
delay,
muted))
resp = np.frombuffer(b"".join(binary_summaries), dtype=np.uint8)

if len(resp) != summary_length(len(summary)):
Expand Down Expand Up @@ -1062,6 +1066,7 @@ def handle_post(in_json, in_data) -> Tuple[Any, str]:
user.client_address = in_json["client_address"]

user.in_spectator_mode = query_params.get("spectator", None)
user.muted = query_params.get("muted", None) == "1"

client_telemetry = query_params.get("client_telemetry", None)
if client_telemetry:
Expand Down Expand Up @@ -1229,7 +1234,7 @@ def maybe_print_status() -> None:
print("-"*70)

for delay, name, mic_volume, userid, \
rms_volume in user_summary(requested_user_summary=True):
rms_volume, muted in user_summary(requested_user_summary=True):
print ("%s %s vol=%.2f rms=%.5f" % (
str(delay).rjust(3),
name.rjust(30),
Expand Down

0 comments on commit 7d10de8

Please sign in to comment.