Compare commits
No commits in common. "5f7c61f61652eccec261f91b9d8fddeab9c59837" and "18aaa1b62501f44c67af6b39de91513f26c2b206" have entirely different histories.
5f7c61f616
...
18aaa1b625
@ -47,7 +47,6 @@ try:
|
||||
line = sys.stdin.readline()
|
||||
if line == "":
|
||||
time.sleep(0.01)
|
||||
continue
|
||||
line = line.rstrip('\n')
|
||||
line=line[1:-1]
|
||||
line = line.replace("[",'(')
|
||||
|
@ -162,7 +162,8 @@ try:
|
||||
pointsList = ast.literal_eval(line)
|
||||
# Do the filter
|
||||
result = kaleidoscope( pointsList )
|
||||
if len(result) : print( result, flush=True )
|
||||
print( result, flush=True )
|
||||
|
||||
looptime = time.time() - start
|
||||
# debug(name+" looptime:"+str(looptime))
|
||||
if( looptime < optimal_looptime ):
|
||||
|
6
clitools/filters/redilysis_colors.py
Executable file → Normal file
6
clitools/filters/redilysis_colors.py
Executable file → Normal file
@ -1,3 +1,4 @@
|
||||
|
||||
#!/usr/bin/python3
|
||||
# -*- coding: utf-8 -*-
|
||||
# -*- mode: Python -*-
|
||||
@ -144,11 +145,8 @@ def default( pl ):
|
||||
colorTuple = int2rgb(ocolor)
|
||||
x = point[0]
|
||||
dist = abs(x - max_width/2)
|
||||
key = int(2* dist / max_width * 7)
|
||||
try:
|
||||
key = int(2* dist / max_width * 8)
|
||||
power = spect[key] / spect10Correct[key] * chaos
|
||||
except:
|
||||
pass
|
||||
color = []
|
||||
for i in colorTuple:
|
||||
new_color = int(i * power)
|
||||
|
@ -1,53 +0,0 @@
|
||||
#!/usr/bin/python3
|
||||
# -*- coding: utf-8 -*-
|
||||
# -*- mode: Python -*-
|
||||
|
||||
|
||||
'''
|
||||
|
||||
Send only black points
|
||||
v0.1.0
|
||||
|
||||
Use it to test your filters and outputs
|
||||
|
||||
LICENCE : CC
|
||||
|
||||
by cocoa
|
||||
|
||||
'''
|
||||
|
||||
from __future__ import print_function
|
||||
import time
|
||||
import argparse
|
||||
import sys
|
||||
name="generator::dummy"
|
||||
|
||||
|
||||
def debug(*args, **kwargs):
|
||||
if( verbose == False ):
|
||||
return
|
||||
print(*args, file=sys.stderr, **kwargs)
|
||||
|
||||
argsparser = argparse.ArgumentParser(description="dummy generator")
|
||||
argsparser.add_argument("-f","--fps",help="Frame Per Second",default=30,type=int)
|
||||
argsparser.add_argument("-v","--verbose",action="store_true",help="Verbose output")
|
||||
args = argsparser.parse_args()
|
||||
|
||||
fps=args.fps
|
||||
verbose=args.verbose
|
||||
optimal_looptime = 1 / fps
|
||||
debug(name+" optimal looptime "+str(optimal_looptime))
|
||||
|
||||
|
||||
shape = [[400,400,0],[400,400,64],[400,400,0]]
|
||||
|
||||
|
||||
while True:
|
||||
start = time.time()
|
||||
print(shape, flush=True);
|
||||
looptime = time.time() - start
|
||||
if( looptime < optimal_looptime ):
|
||||
time.sleep( optimal_looptime - looptime)
|
||||
debug(name+" micro sleep:"+str( optimal_looptime - looptime))
|
||||
|
||||
|
@ -28,9 +28,9 @@ def debug(*args, **kwargs):
|
||||
return
|
||||
print(*args, file=sys.stderr, **kwargs)
|
||||
|
||||
argsparser = argparse.ArgumentParser(description="dummy generator")
|
||||
|
||||
argsparser = argparse.ArgumentParser(description="Dummy generator")
|
||||
argsparser.add_argument("-f","--fps",help="Frame Per Second",default=30,type=int)
|
||||
argsparser.add_argument("-s","--speed",help="point per frame progress",default=3,type=int)
|
||||
argsparser.add_argument("-v","--verbose",action="store_true",help="Verbose output")
|
||||
args = argsparser.parse_args()
|
||||
|
||||
@ -38,7 +38,7 @@ fps=args.fps
|
||||
verbose=args.verbose
|
||||
optimal_looptime = 1 / fps
|
||||
debug(name+" optimal looptime "+str(optimal_looptime))
|
||||
color = 16777215
|
||||
color = 65280
|
||||
square = [[100.0, 100.0, color], [100.0, 500.0, color], [500.0, 500.0, color], [500.0, 100.0, color], [100.0, 100.0, color]]
|
||||
line =[]
|
||||
for i in range(00,800,int(800/120)):
|
||||
|
@ -1,72 +0,0 @@
|
||||
#!/usr/bin/python3
|
||||
# -*- coding: utf-8 -*-
|
||||
# -*- mode: Python -*-
|
||||
|
||||
|
||||
'''
|
||||
|
||||
This generator reads a frame from redis
|
||||
v0.1.0
|
||||
|
||||
Use it to create feedback loops by writing to the same frame
|
||||
or to copy the frame from someone else
|
||||
|
||||
LICENCE : CC
|
||||
|
||||
by cocoa
|
||||
|
||||
'''
|
||||
|
||||
from __future__ import print_function
|
||||
import ast
|
||||
import argparse
|
||||
import json
|
||||
import redis
|
||||
import sys
|
||||
import time
|
||||
name="generator::fromRedis"
|
||||
|
||||
|
||||
def debug(*args, **kwargs):
|
||||
if( verbose == False ):
|
||||
return
|
||||
print(*args, file=sys.stderr, **kwargs)
|
||||
|
||||
|
||||
argsparser = argparse.ArgumentParser(description="Dummy generator")
|
||||
argsparser.add_argument("-k","--key",required=True,help="Redis key to look after",default=30,type=str)
|
||||
argsparser.add_argument("-i","--ip",help="IP address of the Redis server ",default="127.0.0.1",type=str)
|
||||
argsparser.add_argument("-p","--port",help="Port of the Redis server ",default="6379",type=str)
|
||||
argsparser.add_argument("-f","--fps",help="Frame Per Second",default=30,type=int)
|
||||
argsparser.add_argument("-v","--verbose",action="store_true",help="Verbose output")
|
||||
args = argsparser.parse_args()
|
||||
|
||||
fps = args.fps
|
||||
verbose = args.verbose
|
||||
key = args.key
|
||||
ip = args.ip
|
||||
port = args.port
|
||||
optimal_looptime = 1 / fps
|
||||
debug(name+" optimal looptime "+str(optimal_looptime))
|
||||
|
||||
r = redis.Redis(
|
||||
host=ip,
|
||||
port=port)
|
||||
|
||||
while True:
|
||||
start = time.time()
|
||||
# Read from Redis
|
||||
line = r.get(key)
|
||||
# Decode as list of tuples
|
||||
pointsList = ast.literal_eval(line.decode('ascii'))
|
||||
# convert to list of lists
|
||||
pointsList = [list(elem) for elem in pointsList]
|
||||
# Convert to JSON string
|
||||
line = json.dumps( pointsList )
|
||||
debug(name,"Key:{} line:{}".format(key,line))
|
||||
print(line, flush=True);
|
||||
looptime = time.time() - start
|
||||
if( looptime < optimal_looptime ):
|
||||
time.sleep( optimal_looptime - looptime)
|
||||
debug(name+" micro sleep:"+str( optimal_looptime - looptime))
|
||||
|
@ -62,25 +62,7 @@ square = [
|
||||
[-1,1]
|
||||
]
|
||||
|
||||
circle = [[1,0],
|
||||
[0.9238795325112867,0.3826834323650898],
|
||||
[0.7071067811865476,0.7071067811865475],
|
||||
[0.38268343236508984,0.9238795325112867],
|
||||
[0,1.0],
|
||||
[-0.3826834323650897,0.9238795325112867],
|
||||
[-0.7071067811865475,0.7071067811865476],
|
||||
[-0.9238795325112867,0.3826834323650899],
|
||||
[-1.0,0],
|
||||
[-0.9238795325112868,-0.38268343236508967],
|
||||
[-0.7071067811865477,-0.7071067811865475],
|
||||
[-0.38268343236509034,-0.9238795325112865],
|
||||
[0,-1.0],
|
||||
[0.38268343236509,-0.9238795325112866],
|
||||
[0.707106781186548,-0.707106781186547],
|
||||
[0.9238795325112872,-0.3826834323650887],
|
||||
[1,0]]
|
||||
|
||||
shape = circle
|
||||
shape = square
|
||||
currentCenter = [centerX, centerY]
|
||||
centerVector= [0,0]
|
||||
# tweak random basis
|
||||
|
@ -10,16 +10,6 @@ import json
|
||||
from pathlib import Path
|
||||
import redis
|
||||
|
||||
|
||||
environ = {
|
||||
# "REDIS_IP" : "127.0.0.1",
|
||||
"REDIS_IP" : "192.168.2.44",
|
||||
"REDIS_PORT" : "6379",
|
||||
"REDIS_KEY" : "/pl/0/0",
|
||||
"REDIS_SCENE" : "0",
|
||||
"REDIS_LASER" : "0"
|
||||
}
|
||||
|
||||
class bcolors:
|
||||
HL = '\033[31m'
|
||||
OKBLUE = '\033[94m'
|
||||
@ -115,12 +105,10 @@ def action_changeCommand( inc ):
|
||||
return True
|
||||
|
||||
def action_match( k ):
|
||||
global current_id, currentPlayList
|
||||
if int(k) > (len(currentPlayList) - 1):
|
||||
print( bcolors.HL + "This key does not exist" + bcolors.ENDC )
|
||||
return False
|
||||
else :
|
||||
_ok("Changed action id to {}.".format(k))
|
||||
current_id = int(k)
|
||||
|
||||
def action_runCommand():
|
||||
@ -167,7 +155,7 @@ def action_deleteCommand():
|
||||
action_listAll()
|
||||
key = int(input())
|
||||
# Exit early
|
||||
if "x" == key:
|
||||
if "x" == k:
|
||||
return(False)
|
||||
del currentPlayList[key]
|
||||
return True
|
||||
@ -175,7 +163,7 @@ def action_deleteCommand():
|
||||
|
||||
|
||||
def action_listAll():
|
||||
global currentPlayList, current_cmd, current_id
|
||||
global currentPlayList, current_cmd
|
||||
print("\n--------------------------------------")
|
||||
for i,seq in enumerate(currentPlayList):
|
||||
pre=""
|
||||
@ -244,7 +232,7 @@ def action_loadPlaylist():
|
||||
print( bcolors.HL + "This key '{}' is not valid".format(k) + bcolors.ENDC )
|
||||
return False
|
||||
|
||||
# @todo replace with _loadPlaylist
|
||||
# Load file
|
||||
playlistFile = Path("./playlists/"+file_list[k].name)
|
||||
currentPlayList = json.loads(playlistFile.read_text())
|
||||
current_playlist_name = file_list[k].name
|
||||
@ -254,18 +242,7 @@ def action_loadPlaylist():
|
||||
|
||||
|
||||
|
||||
def _loadPlaylist( filename ):
|
||||
|
||||
global currentPlayList, current_playlist_name, current_id
|
||||
try:
|
||||
playlistFile = Path(filename)
|
||||
currentPlayList = json.loads(playlistFile.read_text())
|
||||
current_playlist_name = filename
|
||||
current_id = 0
|
||||
_ok("Playlist loaded: {}\n".format(current_playlist_name))
|
||||
return True
|
||||
except Exception as e:
|
||||
_err("_loadPlaylist error when loading '{}':{}".format(filename,e))
|
||||
|
||||
|
||||
|
||||
@ -377,3 +354,12 @@ def action_quit():
|
||||
if quit != "n":
|
||||
_kill(process)
|
||||
sys.exit(1)
|
||||
|
||||
environ = {
|
||||
# "REDIS_IP" : "127.0.0.1",
|
||||
"REDIS_IP" : "192.168.2.44",
|
||||
"REDIS_PORT" : "6379",
|
||||
"REDIS_KEY" : "/pl/0/0",
|
||||
"REDIS_SCENE" : "0",
|
||||
"REDIS_LASER" : "0"
|
||||
}
|
||||
|
93
clitools/runner_midi.py
Executable file → Normal file
93
clitools/runner_midi.py
Executable file → Normal file
@ -1,87 +1,12 @@
|
||||
#!/usr/bin/python3
|
||||
|
||||
import argparse
|
||||
import re
|
||||
import redis
|
||||
import runner_lib as runner
|
||||
import sys
|
||||
import os
|
||||
import signal
|
||||
import subprocess
|
||||
import time
|
||||
|
||||
novationRows = [
|
||||
[ 0, 1, 2, 3, 4, 5, 6, 7 ],
|
||||
[ *range(16,24)],
|
||||
[ *range(32,40)],
|
||||
[ *range(48,56)]
|
||||
]
|
||||
|
||||
argsparser = argparse.ArgumentParser(description="Playlist midi")
|
||||
argsparser.add_argument("playlist",help="JSON playlist file ",type=str)
|
||||
argsparser.add_argument("-i","--ip",help="IP address of the Redis server ",default="127.0.0.1",type=str)
|
||||
argsparser.add_argument("-r","--row",help="Row of Novation pad. Default:1 ",default=1,type=str)
|
||||
argsparser.add_argument("-k","--key",help="Redis key to update",default="0",type=str)
|
||||
argsparser.add_argument("-l","--laser",help="Laser number. Default:0 ",default=0,type=int)
|
||||
argsparser.add_argument("-p","--port",help="Port of the Redis server ",default="6379",type=str)
|
||||
argsparser.add_argument("-s","--scene",help="Laser scene. Default:0 ",default=0,type=int)
|
||||
argsparser.add_argument("-v","--verbose",action="store_true",help="Verbose")
|
||||
args = argsparser.parse_args()
|
||||
|
||||
ip = args.ip
|
||||
port = args.port
|
||||
key = args.key
|
||||
verbose=args.verbose
|
||||
laser = args.laser
|
||||
scene = args.scene
|
||||
playlist = args.playlist
|
||||
row = args.row - 1
|
||||
rowKeys = novationRows[row]
|
||||
|
||||
|
||||
|
||||
# Subscriber
|
||||
|
||||
r = redis.StrictRedis(host=ip, port=port, db=0)
|
||||
p = r.pubsub()
|
||||
p.subscribe('/midi/last_event')
|
||||
runner._killBill()
|
||||
|
||||
# Set Laser and scene
|
||||
runner._setKey( laser = laser, scene = scene)
|
||||
|
||||
# Load playlist
|
||||
runner._loadPlaylist( playlist )
|
||||
|
||||
print("Loaded playlist : {}".format(runner.currentPlayList))
|
||||
|
||||
|
||||
runner.action_info()
|
||||
runner.current_id = -1
|
||||
while True:
|
||||
runner._killBill()
|
||||
|
||||
message = p.get_message()
|
||||
if message:
|
||||
#runner._ok ("Subscriber: %s" % message['data'])
|
||||
|
||||
|
||||
# b'/midi/noteon/0/19/127'
|
||||
match = re.match(".*/([0-9]+)/[0-9]+",str(message['data']))
|
||||
if not match:
|
||||
continue
|
||||
key = int(match.group(1))
|
||||
|
||||
# Check if the event is for us
|
||||
if key not in rowKeys:
|
||||
print("key {} not in {} ".format(key,rowKeys))
|
||||
continue
|
||||
|
||||
try:
|
||||
command_id = rowKeys.index(key)
|
||||
cmd = runner.currentPlayList[command_id]
|
||||
|
||||
if command_id != runner.current_id :
|
||||
runner._ok("Launching command #{}\n Previous was {}\n Cmd:{}".format(command_id,runner.current_id,cmd))
|
||||
runner.action_match(command_id)
|
||||
runner.action_runCommand()
|
||||
else :
|
||||
runner._err("Not running {} : already running.".format(command_id))
|
||||
except Exception as e :
|
||||
print("Woops.",e)
|
||||
import tty,termios
|
||||
import re
|
||||
import json
|
||||
from pathlib import Path
|
||||
import runner_lib as runner
|
||||
|
Loading…
Reference in New Issue
Block a user