[fix] clitools: multiple fixes and enhancements
This commit is contained in:
parent
e794ee2c5e
commit
cebdc67c54
5 changed files with 127 additions and 40 deletions
|
|
@ -28,11 +28,15 @@ name = "filters::cycle"
|
|||
argsparser = argparse.ArgumentParser(description="Redis exporter LJ")
|
||||
argsparser.add_argument("-x","--centerX",help="geometrical center X position",default=300,type=int)
|
||||
argsparser.add_argument("-y","--centerY",help="geometrical center Y position",default=300,type=int)
|
||||
argsparser.add_argument("-m","--min",help="Lowest value in the range 0-255",default=10,type=int)
|
||||
argsparser.add_argument("-M","--max",help="Highest value in the range 0-255",default=255,type=int)
|
||||
argsparser.add_argument("-f","--fps",help="Frame Per Second",default=30,type=int)
|
||||
argsparser.add_argument("-v","--verbose",action="store_true",help="Verbose")
|
||||
|
||||
args = argsparser.parse_args()
|
||||
fps = args.fps
|
||||
minVal = args.min
|
||||
maxVal = args.max
|
||||
centerX = args.centerX
|
||||
centerY = args.centerY
|
||||
verbose = args.verbose
|
||||
|
|
@ -60,9 +64,9 @@ def cycleColor( pl ):
|
|||
# debug(name,"pl:{}".format(pl))
|
||||
value = currentColor[composant]
|
||||
if currentDirection == UP:
|
||||
target = 255
|
||||
target = maxVal
|
||||
else:
|
||||
target = 0
|
||||
target = minVal
|
||||
value += currentDirection
|
||||
currentColor[composant] = value
|
||||
|
||||
|
|
@ -71,7 +75,7 @@ def cycleColor( pl ):
|
|||
pl[i][2] = rgb2int( currentColor)
|
||||
|
||||
# change the composant if target reached
|
||||
if value == target:
|
||||
if value <= target and currentDirection == DOWN or value >= target and currentDirection == UP :
|
||||
composant = random.randint( 0,2)
|
||||
value = currentColor[composant]
|
||||
if value == 0 :
|
||||
|
|
|
|||
|
|
@ -29,8 +29,8 @@ import time
|
|||
name = "filters::kaleidoscope"
|
||||
|
||||
argsparser = argparse.ArgumentParser(description="Redis exporter LJ")
|
||||
argsparser.add_argument("-x","--centerX",help="geometrical center X position",default=300,type=int)
|
||||
argsparser.add_argument("-y","--centerY",help="geometrical center Y position",default=300,type=int)
|
||||
argsparser.add_argument("-x","--centerX",help="geometrical center X position",default=400,type=int)
|
||||
argsparser.add_argument("-y","--centerY",help="geometrical center Y position",default=400,type=int)
|
||||
argsparser.add_argument("-f","--fps",help="Frame Per Second",default=30,type=int)
|
||||
argsparser.add_argument("-v","--verbose",action="store_true",help="Verbose")
|
||||
|
||||
|
|
|
|||
|
|
@ -40,7 +40,8 @@ def now():
|
|||
# The list of available modes and the redis keys they need
|
||||
oModeList = {
|
||||
"rms_noise": ["rms"],
|
||||
"rms_bounce": ["rms"]
|
||||
"rms_size": ["rms"],
|
||||
"bpm_size": ["bpm"]
|
||||
}
|
||||
CHAOS = 1
|
||||
REDIS_FREQ = 300
|
||||
|
|
@ -53,8 +54,8 @@ argsparser.add_argument("-i","--ip",help="IP address of the Redis server ",defau
|
|||
argsparser.add_argument("-p","--port",help="Port of the Redis server ",default="6379",type=str)
|
||||
argsparser.add_argument("-s","--redis-freq",help="Query Redis every x (in milliseconds). Default:{}".format(REDIS_FREQ),default=REDIS_FREQ,type=int)
|
||||
# General args
|
||||
argsparser.add_argument("-x","--centerX",help="geometrical center X position",default=300,type=int)
|
||||
argsparser.add_argument("-y","--centerY",help="geometrical center Y position",default=300,type=int)
|
||||
argsparser.add_argument("-x","--centerX",help="geometrical center X position",default=400,type=int)
|
||||
argsparser.add_argument("-y","--centerY",help="geometrical center Y position",default=400,type=int)
|
||||
argsparser.add_argument("-f","--fps",help="Frame Per Second",default=30,type=int)
|
||||
# Modes And Common Modes Parameters
|
||||
argsparser.add_argument("-m","--modelist",required=True,help="Comma separated list of modes to use from: {}".format("i, ".join(oModeList.keys())),type=str)
|
||||
|
|
@ -86,23 +87,66 @@ r = redis.Redis(
|
|||
host=ip,
|
||||
port=port)
|
||||
|
||||
def rms_bounce( pl ):
|
||||
# Records the last bpm
|
||||
last_bpm = time.time()
|
||||
|
||||
def gauss(x, mu, sigma):
|
||||
return( math.exp(-math.pow((x-mu),2)/(2*math.pow(sigma,2))/math.sqrt(2*math.pi*math.pow(sigma,2))))
|
||||
|
||||
|
||||
def bpm_size( pl ):
|
||||
global last_bpm
|
||||
bpm = float(redisData["bpm"])
|
||||
# Milliseconds ber beat
|
||||
milliSecondsPerBeat = int(60 / bpm * 1000)
|
||||
# Calculate the intensity based on bpm coming/leaving
|
||||
# The curb is a gaussian
|
||||
mu = math.sqrt(milliSecondsPerBeat)
|
||||
milliTimeToLastBeat = (time.time() - last_bpm) * 1000
|
||||
milliTimeToNextBeat = (milliSecondsPerBeat - milliTimeToLastBeat)
|
||||
intensity = gauss( milliTimeToNextBeat, 0 , mu)
|
||||
debug(name,"bpm_size","milliSecondsPerBeat:{}\tmu:{}".format(milliSecondsPerBeat, mu))
|
||||
debug(name,"bpm_size","milliTimeToLastBeat:{}\tmilliTimeToNextBeat:{}\tintensity:{}".format(milliTimeToLastBeat, milliTimeToNextBeat, intensity))
|
||||
if milliTimeToNextBeat <= 0 :
|
||||
last_bpm = time.time()
|
||||
for i, point in enumerate(pl):
|
||||
ref_x = point[0]-centerX
|
||||
ref_y = point[1]-centerY
|
||||
#debug(name,"In new ref x:{} y:{}".format(point[0]-centerX,point[1]-centerY))
|
||||
angle=math.atan2( point[0] - centerX , point[1] - centerY )
|
||||
l = ref_y / math.cos(angle)
|
||||
new_l = l * intensity
|
||||
#debug(name,"bpm_size","angle:{} l:{} new_l:{}".format(angle,l,new_l))
|
||||
new_x = math.sin(angle) * new_l + centerX
|
||||
new_y = math.cos(angle) * new_l + centerY
|
||||
#debug(name,"x,y:({},{}) x',y':({},{})".format(point[0],point[1],new_x,new_y))
|
||||
pl[i][0] = new_x
|
||||
pl[i][1] = new_y
|
||||
#debug( name,"bpm_noise output:{}".format(pl))
|
||||
return pl
|
||||
|
||||
def rms_size( pl ):
|
||||
rms = float(redisData["rms"])
|
||||
for i, point in enumerate(pl):
|
||||
#debug(name,"rms_noise chaos:{} rms:{}".format(chaos, rms))
|
||||
angle=math.atan2(point[0],point[1])
|
||||
l = point[1] / math.cos(angle)
|
||||
|
||||
ref_x = point[0]-centerX
|
||||
ref_y = point[1]-centerY
|
||||
debug(name,"In new ref x:{} y:{}".format(point[0]-centerX,point[1]-centerY))
|
||||
angle=math.atan2( point[0] - centerX , point[1] - centerY )
|
||||
l = ref_y / math.cos(angle)
|
||||
debug(name,"angle:{} l:{}".format(angle,l))
|
||||
new_l = l + rms * chaos
|
||||
new_x = math.sin(angle) * new_l
|
||||
new_y = math.cos(angle) * new_l
|
||||
new_x = math.sin(angle) * new_l + centerX
|
||||
new_y = math.cos(angle) * new_l + centerY
|
||||
debug(name,"x,y:({},{}) x',y':({},{})".format(point[0],point[1],new_x,new_y))
|
||||
pl[i][0] += new_x
|
||||
pl[i][1] += new_y
|
||||
pl[i][0] = new_x
|
||||
pl[i][1] = new_y
|
||||
#debug( name,"rms_noise output:{}".format(pl))
|
||||
return pl
|
||||
|
||||
def rms_noise( pl ):
|
||||
rms = float(redisData["rms"])
|
||||
debug(name, "pl:{}".format(pl))
|
||||
for i, point in enumerate(pl):
|
||||
#debug(name,"rms_noise chaos:{} rms:{}".format(chaos, rms))
|
||||
xRandom = random.uniform(-1,1) * rms * chaos
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue