Lightscript

Wed, Dec 26, 2007 in Project using tags dmx , software , lighting

Lightscript is a scripting and control environment for stage lighting.

It consists of

  • lsc - lightscript compiler
  • lsi - lightscript interpreter

The compiler compiles code from the lightscript language to bytecode. The lightscript language is loosely C-like at the moment, and the bytecode is a simple stack-based architecture.

The interpreter implements a virtual machine. It loads in the bytecode from a file, and executes it. There is a simple threading model - threads run to completion, or until they yield or block. There is currently no pre-emption. There is support for events, which act as wait channels. Events can be sent by the VM, by plugins or by user code.

These two components are separated into different executables for the simple reason that the part which runs in real-time should be as simple and straightforward as possible. The compiler is a big chunk of code, but the VM is pretty simple and straightforward. It's relatively easy to reason about the correctness of the core of the VM, which makes it easier to write the rest of the interpreter in such a way that it will be difficult to make it fall over during a show. To date, the interpreter has never crashed during a show.

There are a number of plugins that are compiled into the interpreter. They implement I/O such as DMX, MIDI, audio beat detection, 3D geometry, persistent storage (via SQLite), mouse input, command listener (over TCP). Plugins are able to implement internal functions, which are made available to the code via a versioned ABI.

Lightscript has been used at a few events to provide lighting for various different types of show, ranging from theatrical through live band to disco. It has also been used a couple of times in a fully automated mode to provide lighting for a live recreation of a game show. It accepted input via the command listener from the show control computer and ran a lighting state machine which provided all of the lighting effects for the show, perfectly synchronised with the audio and video effects.

This software is still in development, and while it is already extremely powerful it is somewhat rough around the edges. There are also several shortcomings, mostly in the design of the language and in some of the I/O facilities.

Lightscript is available from the monotone branch org.coolfactor.lightscript. See the source page for information on downloading it.