Home

Awesome

node-dmx

DMX-512 controller library for node.js

Install

npm install dmx

Library API

const DMX = require('dmx')

Class DMX

new DMX()

Create a new DMX instance. This class is used to tie multiple universes together.

dmx.registerDriver(name, module)

Register a new DMX Driver module by its name. These drivers are currently registered by default:

dmx.addUniverse(name, driver, device_id, options)

Add a new DMX Universe with a name, driver and an optional device_id used by the driver to identify the device. For enttec-usb-dmx-pro and enttec-open-usb-dmx device_id is the path the the serial device. For artnet it is the target ip.

dmx.update(universe, channels[, extraData])

Update one or multiple channels of a universe. Also emits a <code>update</code> Event with the same information.

DMX.devices

A JSON Object describing some Devices and how many channels they use. Currently not many devices are in there but more can be added to the <code>devices.js</code> file. Pull requests welcome ;-)

The following Devices are known:

Class DMX.Animation

new DMX.Animation([options])

Create a new DMX Animation instance. This can be chained similar to jQuery.

The options Object takes the following keys:

If you specify a <code>filter</code> function, it must take a single object parameter in which keys are channel numbers and values are the values to set those channels to. You may modify the values in the object to override the values in real-time, for example to scale channel brightness based on a master fader.

animation.add(to, duration, options)

Add an animation Step. The options Object takes an <code>easing</code> key which allows to set a easing function from the following list:

Returns a Animation object with the animation step added.

animation.delay(duration)

Delay the next animation step for duration. Returns a Animation object with the delay step added.

animation.run(universe, onFinish)

Run the Animation on the specified universe.

animation.runLoop(universe)

Runs an animation constantly until <code>animation.stop()</code> is called

The example below shows a value being animated for 5 seconds:

const animation = new DMX.Animation().add({
  1: 255,
}, 100).add({
  1: 0,
}, 100).runLoop(universe)


setTimeout(() => {
  animation.stop()
}, 5000)

update Event

This event is emitted whenever <code>update</code> is called either by the integrating application or by an animation step.

If triggered by an animation step, <code>extraData.origin</code> will be the string <code>'animation'</code>.

Webinterface

Versions prior to 0.2 included a Webinterface. This has since been moved into its own repository at https://github.com/node-dmx/dmx-web

Community

We're happy to help. Chat with us on IRC in #dmx on libera.chat.