Swift Package for macOS, iOS, and tvOS to send sACN (E1.31) DMX Data over UDP using Network.framework.
You only need to initiate a Connection for a universe and you can start sending DMX Data.
let connection = Connection(universe: 1)
connection.sendDMXData(Data([0, 10, 255, 0, 0, 0, 255]))If you want to use UDP Unicast instead of Multicast, you can simply specify an endpoint yourself:
let connection = Connection(endpoint: .hostPort(host: "192.168.2.102", .sACN), universe: 2)
connection.sendDMXData(Data([0, 10, 255, 0, 0, 0, 255]))- Sending DMX Data via UDP Multicast and Unicast on IPv4/IPv6
- sACN Package Priority
- Per-Address Priority (0xDD packets)
- Preview Data
- Depends only on
FoundationandNetwork.framework
For Unicast, you need to specify an IPv6 Endpoint. For Multicast, you need to specify the IP version you want to use:
let connection = Connection(universe: 1, ipVersion: .v6)After you created a connection, you can set the priority per packet using the Connection.sendDMXData(_:priority:isPreviewData:) method. The default priority is 100.
connection.sendDMXData(data, priority: 200)Send per-address priority (E1.31 start code 0xDD) to claim specific DMX addresses at different priority levels. Each byte represents the priority for the corresponding address. Priority 0 means this source has no data for that address.
// Claim addresses 1-5 at priority 150, ignore all others
var priorities = Data(repeating: 0, count: 512)
priorities[0] = 150 // Address 1
priorities[1] = 150 // Address 2
priorities[2] = 150 // Address 3
priorities[3] = 150 // Address 4
priorities[4] = 150 // Address 5
connection.sendPerAddressPriority(priorities, priority: 150)Send per-address priority alongside your DMX data packets so receivers know which addresses your source claims:
connection.sendDMXData(dmxData, priority: 150)
connection.sendPerAddressPriority(priorities, priority: 150)After you created a connection, you can choose per packet if it is preview data or not using the Connection.sendDMXData(_:priority:isPreviewData:) method. isPreviewData defaults to false.
connection.sendDMXData(data, isPreviewData: true)Connection does support customizing the port, component identifier (CID), source name, DispatchQueue, and NWConneciton.Parameter. Look into the Documentation for more information.
public convenience init(
universe: UInt16,
ipVersion: IPVersion = .v4,
port: NWEndpoint.Port = .sACN,
cid: UUID = .init(),
sourceName: String = getDeviceName(),
queue: DispatchQueue? = nil,
parameters: NWParameters? = nil
)- Receiving DMX Data (have a look at this repository: https://github.com/jkmassel/ACNKit)
- Universe Discovery is not implemented