GithubHelp home page GithubHelp logo

zb1ackcat / swiftsacn Goto Github PK

View Code? Open in Web Editor NEW

This project forked from dnadoba/sacn

0.0 0.0 0.0 151 KB

sACN (E1.31) protocol implementation in Swift to send DMX Data over UDP using Network.framework

Swift 100.00%

swiftsacn's Introduction

sACN (E1.31) Documentation

Swift Package for macOS, iOS, and tvOS to send sACN (E1.31) DMX Data over UDP using Network.framework.

Usage

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]))

Features

  • Sending DMX Data via UDP Multicast and Unicast on IPv4/IPv6
  • sACN Package Priority
  • Preview Data
  • Depends only on Foundation and Network.framework

Advanced Usage

Using IPv6

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)

Priority

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)

Preview Data

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)

Other Connection Initialization Configuration

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
)

Known Limitations

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.