Scrawls from Preston...

Powered by Pelican.

Thu 04 November 2010

MIDI to DMX light chases

As a follow on the previous post - I wanted to demonstrate how the individual lights (with all their own features) can not only be grouped into a simple synchronized group - but they can be added into a "sequence" container which will operate a chase. This also shows the type of interactive control provided by MIDI hardware.

Here is a video demonstrating some of the features, remember the lights on screen are just simple proxy lights for demo purposes. The main output is realtime DMX - which is an already working feature, I just don't have it hooked up to light gear yet.

Here is the code listing that created the demo sequence elements:

#!/usr/bin/env python# encoding: utf-8from midi_reader import MidiDispatcherimport timefrom lights import *import sys# create a light show - manages the updating of all lightsshow = LightShow()light_seqA = LightSequence()light_seqB = LightSequence()light_seqC = LightSequence()light_seqD = LightSequence()# create our 8 lights and add them to each sequence and the showfor i in range(1,9):    l = LightUnit(channels=[i])    l.release = .3    show.lights.append(l)    light_seqA.elements.append(SequenceElement(l))    light_seqB.elements.append(SequenceElement(l))    light_seqC.elements.append(SequenceElement(l))    light_seqD.elements.append(SequenceElement(l))# add the sequences themselves to the showshow.lights.append(light_seqA)show.lights.append(light_seqB)show.lights.append(light_seqC)show.lights.append(light_seqD)# set up the midi communication threaddispatcher = MidiDispatcher(0)light_seqA.speed_control = .01light_seqA.duration = 0light_seqA.on_off_trigger = "reverse"# set_message is a way of mapping a message to an attributelight_seqA.set_message((176, 14),['speed_control'])light_seqA.max_speed = .5light_seqB.speed_control = .01light_seqB.duration = 0light_seqB.on_off_trigger = "sequence"light_seqC.speed_control = .3light_seqC.duration = -1light_seqC.max_speed = .5light_seqC.max_duration = .5light_seqC.set_message((176, 15),['speed_control'])light_seqC.set_message((176, 16),['duration_control'])light_seqD.elements.reverse()light_seqD.speed_control = .3light_seqD.duration = -1dispatcher.add_observer((144, 42), light_seqA)dispatcher.add_observer((176, 14), light_seqA)dispatcher.add_observer((176, 15), light_seqC)dispatcher.add_observer((176, 16), light_seqC)dispatcher.add_observer((144, 44), light_seqB)dispatcher.add_observer((144, 54), light_seqC)dispatcher.add_observer((144, 49), light_seqD)# startup the midi communicationdispatcher.start()# this defaults to true for certain equipmentshow.dmx_keep_alive = False# run the showtry:    show.run_live()except KeyboardInterrupt:    # cleanup    dispatcher.stop()    sys.exit(0)


https://ptone.com/dablog