Author Topic: Object oriented light sequencing with Python  (Read 4776 times)

Offline ptone

  • Sr. Member
  • ****
  • Posts: 107
Object oriented light sequencing with Python
« on: November 02, 2010, »
As I've mentioned on the Prancer forum, I've been working on something with some similar goals.

Its still kind of early - but I already like where it is going.

It is a scripted approach - so is somewhat technical, but the goal is flexibility and sophistication, not push-button ease of use.

Names under consideration are Nestor, and BirdFish - kudos to anyone who knows the references.

You are not allowed to view links. Register or Login

I'll update this thread as I get more done with additional screencasts.

Now here is the kicker - I STILL DON'T OWN A SPEC OF GEAR.  I've tried to jump on some used LE gear - but am always too late.  I'm hoping to use LE - but I've ordered some of RPMs DMX16 kits (I was hoping to find pre-assembled gear, I'm a software guy, not a hardware guy).  I am in the process of ordering an EthConGateway.  No expectation that this will all be running for xmass 2010 - but wanted to get started.

-Preston
--
budding channel wrangler

Offline jasond

  • Jr. Member
  • **
  • Posts: 13
Re: Object oriented light sequencing with Python
« Reply #1 on: November 02, 2010, »
I suppose I have been going in a similar direction.  I've never used any of the software mentioned often here and assumed that the software figured out what to do based on the music.  So that's what I wrote.  I figured that was easier than trying to set each value manually for the whole song(s).  I saw an application for Windows that did something similar, but it wasn't as easily configurable and crashed a lot, at least on my wife's computer.  There's crap for the Mac and I don't know why.

Offline ptone

  • Sr. Member
  • ****
  • Posts: 107
Re: Object oriented light sequencing with Python
« Reply #2 on: November 04, 2010, »
Well what I'm doing isn't classically very "Mac Like" as it is not point and click.  But I think the Mac today is as at the center of the geek culture as it was at the center of the desktop publishing world in the late 80's.

Anyway....

Here is the next update - showing a physical MIDI keyboard connected, controlling a chase sequence of lights - with knobs on the keyboard effecting things like speed and width of the chase pulse:

You are not allowed to view links. Register or Login

-Preston
--
budding channel wrangler

Offline KeithTarpley

  • Administrator
  • Sr. Member
  • *****
  • Posts: 1990
Re: Object oriented light sequencing with Python
« Reply #3 on: November 04, 2010, »
Greetings,,,

Don't currently have an Apple, but watching to see how this turns out.

Keith
"Now I know the only foe is time." -Moody Blues

Offline jasond

  • Jr. Member
  • **
  • Posts: 13
Re: Object oriented light sequencing with Python
« Reply #4 on: November 04, 2010, »
ptone, what is the output of the script?  Does it interface with devices directly?

Offline ptone

  • Sr. Member
  • ****
  • Posts: 107
Re: Object oriented light sequencing with Python
« Reply #5 on: November 04, 2010, »
You are not allowed to view links. Register or Login
ptone, what is the output of the script?  Does it interface with devices directly?

Currently it is outputting realtime DMX in response to realtime MIDI - the DMX is being generated by OLA (You are not allowed to view links. Register or Login) and so supports any of the hardware that library does.  I currently have a EthConGateway enroute and plan to use OLA's support for E1.31 DMX over ethernet.

The plan is to also allow realtime DMX generation in response to reading a MIDI file and allow for export of .vix or other sequence files from MIDI (live or file).  I think the need for a sequence format will be mandated by limits in the ability of the software to process many complex effects on many channels and keep up in realtime.

Does anyone have a pointer to a clear spec for the .vix format? - I took a quick look but didn't understand the relationship between channel data and events.

-Preston
--
budding channel wrangler

Offline travailen

  • Sr. Member
  • ****
  • Posts: 332
  • 77459
Re: Object oriented light sequencing with Python
« Reply #6 on: November 05, 2010, »
I know I am coming late to the party but, here is how I see a program could work quickly

1. Set up the channels in working groups. Trees, arches eves, etc
2. Program then automatically generates time based sections  that are synchronize to the music.
 something like music2light, but that automatically divides each working group into audio time based sections. Each working group could be assigned a frequency span to look for in the audio to make this assignment
3. The program would have a list of sequence scripts. some to start with and some that are built as desired and represent the look and feel of the light appearance for that script. These scripts could be shared. Each script would have a number. each of the time based sections generated in
the previous step would be assigned a script number. all this is so far colorless.
4. using a sliding color tool that has been set for a starting and ending color, run the audio slow while sliding the color tool to transition to the desired color though the program length of each working group.  -  Done

Rick

Offline jasond

  • Jr. Member
  • **
  • Posts: 13
Re: Object oriented light sequencing with Python
« Reply #7 on: November 06, 2010, »
I eventually want to get exactly what your are talking about.  Right now I have the ability to specify a frequency breakdown and assign a frequency to an analyzer that either triggers a channel, follows a channel, or bounces from channel to channel.  I also have prebuilt effects that just need to be assigned to channels.  This keeps the configuration of a show simple and allows you to do multiple songs in a list.  I do Halloween so my requirements are slightly different so I never added the feature for dividing up the song but it has crossed my mind.  I think ptone's functionality would also be a great thing to have when you need a sequence that doesn't syncopate well with the music.

E.g.  from my Halloween show.

Video:  You are not allowed to view links. Register or Login

The lights in the grass are on the oscillator
The lights in the windows are on the flicker effect
And the strobes are triggered when the sound frequency passes the threshold.

113 cue {
114     analyzer {
115         file:/Users/jason/Desktop/Halloween Tracks/Thunder Symphony.aiff;
116         ch:13;
117         threshold:0.750;
118         threshold_value:225;
119         bands:7;
120         freq:3;
121         type:0;
122     }
123     flicker {
124         ch:1,2,3,4;
125     }
126     oscillator {
127         ch:5,6,7,8,9,10,11,12;
128         low:0;
129         high:255;
130         speed:100000;
131     }
132 }

Offline ptone

  • Sr. Member
  • ****
  • Posts: 107
Re: Object oriented light sequencing with Python
« Reply #8 on: November 06, 2010, »
I think there are elements where cueing the lights directly to the music makes sense and others where it doesn't.  I think the best analogy I can think of is a dance performance.  If all dancers did when they got up on stage was twitched or jumped in sync to the music, then it wouldn't be that interesting.  What a direct trigger from a frequency mapping lacks is any sense of choreography.  Now for songs with a beat - a set of lights triggered by just the amplitude of the beat could be a valuable component, but they wouldn't quite be the same as something with more creative input.

-Preston
--
budding channel wrangler

Offline ptone

  • Sr. Member
  • ****
  • Posts: 107
Re: Object oriented light sequencing with Python
« Reply #9 on: November 17, 2010, »
So I've been making progress, some of it around stuff that is more oriented to theater lighting because we have a school play coming up at work.  I've also made progress on the layering of multiple "takes" and added support for tweening of a value.  Tweening is a term to refer the application of a non-linear curve to the way some value changes over time, and pretty much comes from animation.  It makes things often look more natural than linear movement.

Here is a quick video that shows a couple things - one is this is running a DIY DMX board, to show that it is not just some on-screen proxy that is being controlled, but real lights.  Two is it shows a non-linear (I believe it is a cubic curve) of a sequence trigger.  This is being done in this video live just by pressing a single key on the midi input.

You are not allowed to view links. Register or Login

for more examples of the types of curves that can be applied see:

You are not allowed to view links. Register or Login

-Preston
--
budding channel wrangler

Offline ptone

  • Sr. Member
  • ****
  • Posts: 107
Re: Object oriented light sequencing with Python
« Reply #10 on: November 22, 2010, »
Been playing with interfacing the kinect 3D sensor to this project:

You are not allowed to view links. Register or Login

-Preston
--
budding channel wrangler

Offline JonB256

  • Sr. Member
  • ****
  • Posts: 672
    • My website
Re: Object oriented light sequencing with Python
« Reply #11 on: November 22, 2010, »
Does Python capture that information, like a conductor in front of an orchestra? Then build a symphony from the different pieces?

Offline RJ

  • Administrator
  • Sr. Member
  • *****
  • Posts: 8519
Re: Object oriented light sequencing with Python
« Reply #12 on: November 22, 2010, »
Very cool stuff!  keep up the work. It would be awesome to be able to have a computer outside between shows for the kids to play with til the show starts.

I see them now dancing around making all the lights go on and off!!  How cool that would be.

RJ
Innovation beats imitation - and it's more satisfying

Offline rrowan

  • Administrator
  • Sr. Member
  • *****
  • Posts: 5899
  • 08096
Re: Object oriented light sequencing with Python
« Reply #13 on: November 22, 2010, »
You are not allowed to view links. Register or Login
Very cool stuff!  keep up the work. It would be awesome to be able to have a computer outside between shows for the kids to play with til the show starts.

I see them now dancing around making all the lights go on and off!!  How cool that would be.

RJ

Many in FL

But not in the colder states LOL

Its hard to keep track of all of these different posts about new software ideas

Keep it going guys

Cheers

Rick R.
Light Animation Hobby - Having fun and Learning at the same time. (21st member of DLA)
You are not allowed to view links. Register or Login
Warning SOME assembly required

Offline ptone

  • Sr. Member
  • ****
  • Posts: 107
Re: Object oriented light sequencing with Python
« Reply #14 on: November 23, 2010, »
Was thinking about RJ's pixel megatree.  Can't remember how many strings of 70 pixels, but working with a number of 32 strings (which is 32 * 70 * 3 = 6720 channels) I came up with some sample code of how this could be represented with several effects in just a few lines of code.  If you know any programming language - you should be able to follow along.  Not sure how this kind of thing could be easily done with a GUI.  Because code looks better highlighted - here is a dpaste that will eventually expire, code is below:

You are not allowed to view links. Register or Login

Code: You are not allowed to view links. Register or Login
num_strings = 32
lights_per_string = 70
num_lights = num_strings * lights_per_string
total_channels = num_lights * 3

# define all the pixels
pixels = []
for i in range(1,num_lights,3):
    # range gives a list of numbers, the 3 tells it to give us every third number
    p = RGBLight(start_channel=i)

# Group the pixels into string groups:
def group(l, n):
    for i in range(0, len(l), n):
        yield l[i:i+n]

strings_groups = group(pixels,70) # gathers the pixels into 70ct groups
strings = []
for string in string_groups
    g = LightGroup()
    g.lights = string
    strings.append(g)

# Now lets make a sequence of each string - this would be a chase from top to bottom along a string:
string_sequences = []
for string in string_groups:
    seq = LightSequence(elements=string)
    string_sequences.append(seq)

# How about a sequence of each string sequence - think about what this would do when triggered:
tree_string_sequence = LightSequence(elements=string_sequences)

# make a set of rows of the tree - first pixel or every string, then second pixel of every string etc
row_groups = zip(*strings)
rows = []
for row in row_groups:
    r = LightGroup()
    r.lights = row
    rows.append(r)

# Make the rows into a sequence:
row_sequence = LightSequence(elements=rows)

# How about a marquee effect using every 3rd string?
marquee_sequence = LightSequence()
for i in range(3):
    string_group = LightGroup()
    # grab every 3rd string starting at i and put it in a group
    string_group.lights = strings[i::3]
    # add that group to a sequence
    marquee_sequence.elements.append(string_group)
   

--
budding channel wrangler