Art-Net sample
Using the Art-Net sample bundle
The Art-Net example bundle in samples/artnet-console
demonstrates the ability
send data via Art-Net to e.g., open lighting architecture or professional
lighting equipment. Here is a guide to how to get it working. The underlying
service is using
jeffreykog/node-artnet-protocol
as its library.
Prerequisites
You will need a working nodecg-io
installation. If you have non yet take a
look at installation guide. You may need to
install this bundle, so take a look at the
“Try an included sample”-Guide. It
will also tell you how to log in and how to use the GUI.
You also need:
- A working Art-Net Node in the current network
Configure the Art-Net sample bundle
- In NodeCG, create a new Art-Net service instance.
-
Enter the host to witch the service should broadcast:
Host
The broadcast address the Art-Net library will use to send
dmx
packages.{ "host": "127.0.0.1" }
After entering it, click save.
Info
You may overwrite this broadcast address in code with
client.bind("host address");
. -
Set the sample's (
artnet-console
) dependency to be the newly created service instance (of typeartnet
). - Check the NodeCG logs. You should see data logged.
Explanations
Receiving DMX data
client.onDMX((dmx) => {
// dmx contains an ArtDmx object
nodecg.log.info(dmx.universe, dmx.data);
});
The data you receive has the following fields:
declare class ArtDmx {
opcode: number;
protocolVersion: number;
sequence: number;
physical: number;
universe: number;
data: number[];
constructor(sequence: number, physical: number, universe: number, data: number[]);
isSequenceEnabled(): boolean;
static decode(data: Buffer): ArtDmx;
toString(): string;
encode(): Buffer;
}
Sending DMX data
// send new data every 0,8 seconds.
// This is the official timing for re-transmiting data in the artnet specifciation.
setInterval(() => {
client.send(
universe,
values // number[] of values for each of the 512 channels
);
}, 800);
Note
Since neither this library nor nodecg-io does not yet contain an abstraction, so the data is sent to the timings set by the specification, you should respect this part of specification in your implementation.
However, an input that is active but not changing, will re-transmit the last valid ArtDmx packet at approximately 4-second intervals. (Note. In order to converge the needs of Art- Net and sACN it is recommended that Art-Net devices actually use a re-transmit time of 800mS to 1000mS). — Art-Net 4 Specification p. 48