FlipFlop Chaser

Discuss D-Pro Python macro programming, and post any new macros here!
Post Reply
flippatspace
Posts: 7
Joined: Tue Nov 06, 2018 1:58 pm

FlipFlop Chaser

Post by flippatspace » Thu Dec 20, 2018 9:13 am

Hi,

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)	
Any Idea how this can be done?

Regards

Philipp

Post Reply