Skip to content
Mark Slee edited this page Nov 24, 2020 · 3 revisions

Output mapping is handled inside of the initialize callback method. Inside this method, you should construct the appropriate LXOutput and LXDatagram objects and add them to the LX engine.

ArtNet via UDP

void initialize(heronarts.lx.studio.LXStudio lx, heronarts.lx.studio.LXStudio.UI ui) {
  final String ARTNET_IP = "192.168.1.1";
  try {
    // Construct a new DatagramOutput object
    LXDatagramOutput output = new LXDatagramOutput(lx);

    // Add an ArtNetDatagram which sends all of the points in our model
    ArtNetDatagram datagram = new ArtNetDatagram(lx.model);
    datagram.setAddress(ARTNET_IP);
    output.addDatagram(datagram);

    // Here's an example of a custom ArtNetDatagram which only sends specific points
    int universeNumber = 0;
    int[] first100Points = new int[100];
    for (int i = 0; i < first100Points.length; ++i) {
      first100Points[i] = i;
    }
    ArtNetDatagram first100PointsDatagram = new ArtNetDatagram(first100Points, universeNumber);
    first100PointsDatagram.setAddress(ARTNET_IP);
    output.addDatagram(datagram);    

    // Add the datagram output to the LX engine
    lx.addOutput(output);
  } catch (Exception x) {
    x.printStackTrace();
  }
}