rewrite visualizer
This commit is contained in:
parent
4fe3521160
commit
1f188988f0
@ -15,6 +15,7 @@ import time
|
||||
#from gi.repository import GLib
|
||||
#from pydbus import SessionBus
|
||||
import curses
|
||||
import toml
|
||||
|
||||
s1 = socket.socket()
|
||||
s2 = socket.socket()
|
||||
@ -43,31 +44,18 @@ def helpmenu():
|
||||
def base_color(color):
|
||||
return [i // min(color) for i in color]
|
||||
|
||||
def visualizer(color):
|
||||
def visualizer(color, amp_strength=0.6):
|
||||
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_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)
|
||||
amp_factor = amp_strength*((int(line)/500)-1)+1
|
||||
send(rgb_to_hex(int(r*amp_factor),int(g*amp_factor),int(b*amp_factor)))
|
||||
cava.stdout.close()
|
||||
sed.stdout.close()
|
||||
|
||||
_r,_g,_b = 0,0,0
|
||||
volume_amp = 1
|
||||
|
||||
def visualizer_cava_thread():
|
||||
global volume_amp
|
||||
|
||||
@ -79,7 +67,7 @@ def visualizer_cava_thread():
|
||||
cava.stdout.close()
|
||||
sed.stdout.close()
|
||||
|
||||
def visualizer_2(color, amp_strength):
|
||||
def amp_by_vol(color, amp_strength):
|
||||
global volume_amp
|
||||
# amp_strength in percentage
|
||||
amp_factor = amp_strength*((volume_amp/500)-1)+1
|
||||
@ -115,7 +103,8 @@ def ambient_light_thread():
|
||||
active_color = '\033[0;32;40m'
|
||||
else:
|
||||
active_color = '\033[0;31;40m'
|
||||
r_out,g_out,b_out = visualizer_2((r,g,b), 0.6)
|
||||
r_out,g_out,b_out = amp_by_vol((r,g,b), 0.6)
|
||||
#r_out,g_out,b_out = r,g,b
|
||||
print(active_color, round(r),round(g),round(b), round(r_out),round(g_out),round(b_out), '\033[0;37;40m')
|
||||
send(rgb_to_hex(int(r_out*brighness),int(g_out*brighness),int(b_out*brighness)))
|
||||
time.sleep(0.01)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user