From ccf1144c0c6f4604bf90016e007e7ce5c50ab96c Mon Sep 17 00:00:00 2001 From: Jeff Kaufman Date: Wed, 6 Jan 2021 12:46:19 +0000 Subject: [PATCH] boost current leader volume. Fixes #159 --- server.py | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/server.py b/server.py index 52d8d6d..cbe6e5c 100755 --- a/server.py +++ b/server.py @@ -101,6 +101,19 @@ def reset(self): if recorder: recorder.reset() +def friendly_volume_to_scalar(volume): + if volume < 0.0000001: + return 0 + # https://www.dr-lex.be/info-stuff/volumecontrols.html + return math.exp(6.908 * volume) / 1000 + +def scalar_to_friendly_volume(scalar): + if scalar < 0.0001: + return 0 + return math.log(scalar * 1000)/6.908 + +LEADER_BOOST = friendly_volume_to_scalar(1.1) + QUEUE_SECONDS = 120 SAMPLE_RATE = 48000 @@ -717,17 +730,6 @@ def handle_json_post(in_json_raw, in_data): "x-audio-metadata": x_audio_metadata, }), out_data -def friendly_volume_to_scalar(volume): - if volume < 0.0000001: - return 0 - # https://www.dr-lex.be/info-stuff/volumecontrols.html - return math.exp(6.908 * volume) / 1000 - -def scalar_to_friendly_volume(scalar): - if scalar < 0.0001: - return 0 - return math.log(scalar * 1000)/6.908 - # Handle special operations that do not require a user (although they may # optionally support one), but can be done server-to-server as well. def handle_special(query_params, server_clock, user=None, client_read_clock=None): @@ -1063,6 +1065,8 @@ def handle_post(in_data, query_string, print_status, client_address=None) -> Tup user.last_write_clock = client_write_clock in_data *= user.scaled_mic_volume + if state.leader == user.userid: + in_data *= LEADER_BOOST # XXX: I'm not sure we consider this desirable for ritual engine? # Don't keep any input unless a song is in progress.