GithubHelp home page GithubHelp logo

reykroona / swift-atem Goto Github PK

View Code? Open in Web Editor NEW

This project forked from dev1an/swift-atem

0.0 1.0 0.0 1.07 MB

Atem network protocol implementation in swift 4.1 using NIO

License: MIT License

Swift 99.91% Shell 0.09%

swift-atem's Introduction

Swift 5.1 Platforms: macOS & Linux

Atem network protocol implementation

Implementation of BlackMagicDesign's ATEM communication protocol in Swift. It is written on top of Apple's networking library NIO and implements both sides of the protocol: the control panel and the switcher side. This means that you can not only use it to control atem switchers but also to connect to your control panels without the need for a switcher. Opening a whole new world of applications for the Atem control panels. An example can be found at Atem-Simulator

Starting from version 1.0.0 this package uses Swift 5 and NIO2.

Tested platforms

  • macOS 10.14.6 on a MacBook Pro retina 15" late 2013
  • Raspbian GNU/Linux 9 stretch on a Raspberry Pi model 3 B

Installation

When starting a new project: create a Swift package via SPM

# Shell
> swift package init # --type empty|library|executable|system-module

Then add this library to the package description's dependencies

.package(url: "https://github.com/Dev1an/Swift-Atem", from: "1.0.0")

And resolve this new dependency

# Shell
> swift package resolve

Finally import the Atem module in your code

import Atem

You are now ready to create atem controllers and switchers ๐Ÿ˜Ž !

Usage

After looking at the following examples, study the API reference for more details.

Controller

This example shows how to create a controller that connects to a swicther at ip address 10.1.0.67 and print a message whenever the preview bus changes.

try Controller(ipAddress: "10.1.0.67") { handler in
    handler.when{ (change: PreviewBusChanged) in
        print(change) // prints: 'Preview bus changed to input(x)'
    }
}

Sending messages

To send a message to the switcher use the send(...) method like this:

controller.send(message: ChangeTransitionPosition(to: 5000))

Switcher

The following example shows how to emulate the basic functionality of an atem switcher. It will forward incoming messages containing transition and preview & program bus changes to the connected controller.

try Switcher { handler in
    handler.when { (change: ChangePreviewBus) in
        return [PreviewBusChanged(to: change.previewBus, mixEffect: change.mixEffect)]
    }
    handler.when{ (change: ChangeProgramBus) in
        return [ProgramBusChanged(to: change.programBus, mixEffect: change.mixEffect)]
    }
    handler.when { (change: ChangeTransitionPosition) in
        return [
            TransitionPositionChanged(
                to: change.position,
                remainingFrames: 250 - UInt8(change.position/40),
                mixEffect: change.mixEffect
            )
        ]
    }
}

swift-atem's People

Contributors

dev1an avatar reykroona avatar cattivole avatar

Watchers

James Cloos avatar

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.