I am trying to create a flopflop chaser. So that it goes from left to right and then right to left again.
Here is what I have tried, but this only reverses the order:
Code: Select all
#===============================================================
# DMXIS PRO Macro (c) 2010 db audioware limited
#===============================================================
if QueryParams():
nd = GetNumSelDevices()
AddParam("Speed", " sec", 0.0, 20.0, 1.0, True)
AddParam("Level", "%", 0.0, 100.0, 100.0, True)
AddParam("Width", "%", 0.0, 100.0, 100.0/nd, False)
AddSwitch5("Shape", "Sine", "Square", "Triangle", "Saw Up", "Saw Dn", 1)
AddSwitch2("Direction", "Forward", "Backward", False)
QueryParamsComplete()
else:
spd = GetParamVal("Speed")
level = GetParamVal("Level")/100
pw = GetParamVal("Width")/100
wav = GetSwitchVal("Shape")
dir = GetSwitchVal("Direction")
nd = GetNumSelDevices()
from itertools import chain, cycle
def cycle_up_and_down(first, last):
up = xrange(first, last+1, 1)
down = xrange(last, first-1, -1)
return cycle(chain(up, down))
turns = cycle_up_and_down(0, nd-1)
print [next(turns) for n in xrange(nd+nd)] # [1, 2, 3, 4, 4, 3, 2, 1, 1, 2]
flipflop = [next(turns) for n in xrange(nd+nd)]
if dir==1 :
ph = 0
delta = 1.0/float(nd)
else :
ph = 1
delta = -1.0/float(nd)
for i in flipflop:
OscDimmer(i, wav, spd, ph, level, pw);
ph = ph+delta;
print 'Device ID = %d' % (i)
Regards
Philipp