From 3dde78fbae74b690758e99b4acc7c27698732527 Mon Sep 17 00:00:00 2001 From: Lucca Ketterer Date: Mon, 22 Feb 2021 20:14:36 +0100 Subject: [PATCH] visualizer improvments --- client/cava.conf | 2 +- client/client.py | 26 ++++++++++++++++++-------- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/client/cava.conf b/client/cava.conf index d004670..677c8cf 100644 --- a/client/cava.conf +++ b/client/cava.conf @@ -17,7 +17,7 @@ autosens = 1 # Manual sensitivity in %. Autosens must be turned off for this to take effect. # 200 means double height. Accepts only non-negative values. -; sensitivity = 100 +; sensitivity = 100 # The number of bars (0-200). 0 sets it to auto (fill up console). # Bars' width and space between bars in number of characters. diff --git a/client/client.py b/client/client.py index 3cc6fc6..d487bc6 100755 --- a/client/client.py +++ b/client/client.py @@ -37,18 +37,28 @@ def helpmenu(): print("-s set static color") print("-v visualizer") +def base_color(r,g,b): + min_value = min([r,g,b]) + return r//min_value, g//min_value, b//min_value + def visualizer(color): + r,g,b = hex_to_rgb(color) + r_base,g_base,b_base = base_color(r,g,b) cava = subprocess.Popen(["cava", "-p", "/etc/lc/cava.conf"], stdout=subprocess.PIPE) sed = subprocess.Popen(["sed", "-u", "s/;.*;$//"], stdin=cava.stdout, stdout=subprocess.PIPE) #subprocess.Popen([sys.argv[0]], stdin=sed.stdout, shell=False) for line in sed.stdout: line = int(line) - r,g,b = hex_to_rgb(color) - r = int(r*(line/1000)) - g = int(g*(line/1000)) - b = int(b*(line/1000)) - hex_color = rgb_to_hex(r,g,b) - print(r,g,b) + r_out = int(r*(line/1000)) + g_out = int(g*(line/1000)) + b_out = int(b*(line/1000)) + # print(line, ',', r_out,g_out,b_out, ' | ', r,g,b) + print(r_out,g_out,b_out) + if r_out < r_base or g_out < g_base or b_out < b_base: + r_out = r_base + g_out = g_base + b_out = b_base + hex_color = rgb_to_hex(r_out,g_out,b_out) send(hex_color) cava.stdout.close() sed.stdout.close() @@ -112,7 +122,7 @@ def ambient_light(): #GNOMEScreencast.Screencast('/tmp/a', {}) #GNOMEScreencast.StopScreencast() #time.sleep(1) - + amp = [1,1,0.8] counter = 0 start_time = time.time() @@ -159,7 +169,7 @@ def ambient_light(): _r,_g,_b = vibrant(r,g,b) time.sleep(0.05) - + def rgb_to_hex(r,g,b): return "%02x%02x%02x" % (r,g,b)