OpenOSCKit - Communicate among computers, sound synthesizers, and other multimedia devices via OSC over an IP network

Overview

“OpenOSCKit”/

OpenOSCKit

The OpenOSCKit package provides the classes needed for your apps to communicate among computers, sound synthesizers, and other multimedia devices via OSC over an IP network.

Overview

Use the OpenOSCKit package to create client or server objects. In its simplest form a client can send a packet, either a Message or Bundle to a server. A server, when listening, can receive these packets and action upon them. Depending on a client or server using either UDP or TCP as a transport, there are varying levels of fuctionality and delegate methods for you to take advantage of.

OpenOSCKit implements all required argument types as specified in OSC 1.1.

Features

  • UDP and TCP Transport options
  • UDP Servers can join multicast groups
  • UDP Clients can broadcast packets
  • TCP Server with client management
  • TCP Stream Framing
  • OSC Bundles
  • OSC Timetags

Installation

Xcode 11+

Add the package dependency to your Xcode project using the following repository URL:

https://github.com/dsmurfin/OpenOSCKit

Swift Package Manager

Add the package dependency to your Package.swift and depend on "OpenOSCKit" in the necessary targets:

dependencies: [
    .package(url: "https://github.com/dsmurfin/OpenOSCKit", .upToNextMajor(from: "3.0.1"))
]

App Sandbox Network Settings

  • Enable Incoming Connections (Required for OSCTcpClient, OSCTcpServer & OSCUdpServer)
  • Enable Outgoing Connections (Required for OSCTcpClient, OSCTcpServer & OSCUdpClient)

Quick Start

TCP Client

Step 1

Import OpenOSCKit into your project

import OpenOSCKit

Step 2

Create a client

let client = OSCTcpClient(host: "10.101.130.101",
                          port: 24601,
                          streamFraming: .SLIP,
                          delegate: self)

Step 3

Conform to the clients delegate protocol OSCTcpClientDelegate:

func client(_ client: OSCTcpClient,
            didConnectTo host: String,
            port: UInt16) {
    print("client did connect to \(host):\(port)")
}

func client(_ client: OSCTcpClient,
            didDisconnectWith error: Error?) {
    if let error = error {
       print("client did disconnect with error: \(error.localizedDescription)")
    } else {
       print("client did disconnect")
    }
}

func client(_ client: OSCTcpClient,
            didSendPacket packet: OSCPacket) {
    print("Client did send packet")
}
    
func client(_ client: OSCTcpClient,
            didReceivePacket packet: OSCPacket) {
    print("Client did receive packet")
}
    
func client(_ client: OSCTcpClient,
            didReadData data: Data,
            with error: Error) {
    print("Client did read data with error: \(error.localizedDescription)"
}

Step 4

Create an OSCPacket e.g. An OSC message:

do {
    let message = try OSCMessage(with: "/osc/kit", arguments: [1,
                                                               3.142,
                                                               "hello world!"])
} catch {
    print("Unable to create OSCMessage: \(error.localizedDescription)")
}

Step 5

Send the packet

client.send(message)
TCP Server

Step 1

Import OpenOSCKit into your project

import OpenOSCKit

Step 2

Create a client

let server = OSCTcpServer(port: 24601,
                          streamFraming: .SLIP,
                          delegate: self)

Step 3

Conform to the servers delegate protocol OSCTcpServerDelegate:

func server(_ server: OSCTcpServer,
            didConnectToClientWithHost host: String,
            port: UInt16) {
    print("Server did connect to client \(host):\(port)")
}

func server(_ server: OSCTcpServer,
            didDisconnectFromClientWithHost host: String,
            port: UInt16) {
    print("Server did disconnect from client \(host):\(port)")
}

func server(_ server: OSCTcpServer,
            didReceivePacket packet: OSCPacket,
            fromHost host: String,
            port: UInt16) {
    print("Server did receive packet")
}
    
func server(_ server: OSCTcpServer,
            didSendPacket packet: OSCPacket,
            toClientWithHost host: String,
            port: UInt16) {
    print("Server did send packet to \(host):\(port)")
}
    
func server(_ server: OSCTcpServer,
            socketDidCloseWithError error: Error?) {
    if let error = error {
       print("server did stop listening with error: \(error.localizedDescription)")
    } else {
       print("server did stop listening")
    }
}
    
func server(_ server: OSCTcpServer,
            didReadData data: Data,
            with error: Error) {
    print("Server did read data with error: \(error.localizedDescription)"
}

Step 4

Start listening for new connections and packets:

do {
    try server.startListening()
} catch {
    print(error.localizedDescription)
}
UDP Client

Step 1

Import OpenOSCKit into your project

import OpenOSCKit

Step 2

Create a client

let client = OSCUdpClient(host: "10.101.130.101",
                          port: 24601,
                          delegate: self)

Step 3

Conform to the clients delegate protocol OSCUdpClientDelegate:

func client(_ client: OSCUdpClient,
            didSendPacket packet: OSCPacket,
            fromHost host: String?,
            port: UInt16?) {
    print("client sent packet to \(client.host):\(client.port)")
}

func client(_ client: OSCUdpClient,
            didNotSendPacket packet: OSCPacket,
            fromHost host: String?,
            port: UInt16?,
            error: Error?) {
    print("client did not send packet to \(client.host):\(client.port)")
}

func client(_ client: OSCUdpClient,
            socketDidCloseWithError error: Error) {
    print("Client Error: \(error.localizedDescription)")
}

Step 4

Create an OSCPacket e.g. An OSC message:

do {
    let message = try OSCMessage(with: "/osc/kit", arguments: [1,
                                                               3.142,
                                                               "hello world!"])
} catch {
    print("Unable to create OSCMessage: \(error.localizedDescription)")
}

Step 5

Send the packet

client.send(message)
UDP Server

Step 1

Import OpenOSCKit into your project

import OpenOSCKit

Step 2

Create a client

let server = OSCUdpServer(port: 24601,
                          delegate: self)

Step 3

Conform to the servers delegate protocol OSCUdpServerDelegate:

func server(_ server: OSCUdpServer,
            didReceivePacket packet: OSCPacket,
            fromHost host: String,
            port: UInt16) {
    print("server did receive packet from \(host):\(port)")
}

func server(_ server: OSCUdpServer,
            socketDidCloseWithError error: Error?) {
    if let error = error {
       print("server did stop listening with error: \(error.localizedDescription)")
    } else {
       print("server did stop listening")
    }
}

func server(_ server: OSCUdpServer,
            didReadData data: Data,
            with error: Error) {
    print("Server did read data with error: \(error.localizedDescription)"
}

Step 4

Start listening for packets:

do {
    try server.startListening()
} catch {
    print(error.localizedDescription)
}

OpenOSC

OpenOSCKit is supported by the infrastructural code provided by OpenOSC. For more detailed information pertaining to the OSC objects that OpenOSCKit uses, such as Address Patterns, Messages and Bundles, please direct all queries to OpenOSC.

Authors

Sammy Smallman - Initial Work - SammySmallman

Daniel Murfin - Fork - dsmurfin

See also the list of contributors who participated in this project.

Acknowledgments

You might also like...
Solitaire mahjong game with several themes and layouts. For android/iphone/ubuntu/firefoxos

green-mahjong Green Mahjong is a HTML5 based GPLv3 solitaire mahjong game. It features three nice themes, six different layouts and works accross all

🦁 🃏 📱 An animal matching puzzle card game– built with turn-based game engine boardgame.io and React-Native + React-Native-Web
🦁 🃏 📱 An animal matching puzzle card game– built with turn-based game engine boardgame.io and React-Native + React-Native-Web

Matchimals.fun an animal matching puzzle card game 🦁 🃏 🍎 Download for iOS from the App Store 🤖 Download for Android from the Google Play Store 🖥

A Modern MUD Client for iPhone and iPad.
A Modern MUD Client for iPhone and iPad.

MUDRammer — A Modern MUD Client invoke incantation of build status divination You move a hand through a series of quick gestures, your digits twin

3D Shoot'em Up written with OpenGL ES 1.1/2.0 running on iOS, Android, Windows and MacOS X.
3D Shoot'em Up written with OpenGL ES 1.1/2.0 running on iOS, Android, Windows and MacOS X.

SHMUP This is the source code of "SHMUP" a 3D Shoot 'em up that I wrote in 2009. It is very inspired of Treasure Ikaruga, the engine runs on iOS, Andr

Spare Parts is a 2D physics game that lets you build silly contraptions and machines.

Spare Parts Spare Parts is a 2D physics game that lets you build silly contraptions and machines. The goal for this project is: 100% of the code is op

Switshot is a game media manager helps you transfer your game media from Nintendo Switch to your phone, and manage your media just few taps.
Switshot is a game media manager helps you transfer your game media from Nintendo Switch to your phone, and manage your media just few taps.

Switshot is a game media manager helps you transfer your game media from Nintendo Switch to your phone, and manage your media just few taps.

Mobile IOS Game App Developed by Haemi Lee, Dominika Popov, and Dylan Walsh

VroombaWars Mobile IOS Game App Developed by Haemi Lee, Dominika Popov, and Dylan Walsh Why clean your room in real life when you can have a virtual v

The ultimate spinning wheel view that supports dynamic content and rich customization.
The ultimate spinning wheel view that supports dynamic content and rich customization.

The ultimate spinning wheel control that supports dynamic content and rich customization. Main Features 🏵 Dynamic content, supports texts, images, an

PokaPlayer's native client for iOS and macOS
PokaPlayer's native client for iOS and macOS

PokaNative PokaPlayer's native client for iOS and macOS Installation Get the ipa file from Releases. Use some software like AltStore to install the ip

Releases(2.1.4)
Owner
Dan Murfin
Dan Murfin
Use iOS devices as game controller for PC via usb-lighting cable.

Xpad v1.0 Use iOS devices as game controller for PC via usb-lighting cable. How to use Prequirments Download all files of this project. [iOS] Open /Xp

Jinglong Zhu 2 Apr 23, 2022
Use iOS devices as game controller for PC via usb-lighting cable.

Xpad v1.0 Use iOS devices as game controller for PC via usb-lighting cable. How to use Prequirments Download all files of this project. [iOS] Open /Xp

Jinglong Zhu 2 Apr 23, 2022
A snake engine written in SpriteKit for all Apple devices.

A snake engine written in SpriteKit for all Apple devices. ⭐ Features Fully tested engine functionality. Framework based, super easy to integrate in d

Chris Jimenez 59 Dec 13, 2022
The one and only open source 4X MMO mid-core strategy game for iOS. Similar to Game of War and Mobile Strike

4X MMO Strategy Game for iOS I have spent 4 years of my life and a significant amount of money into completing this game and I hope you enjoy it. For

shankqr 69 Nov 16, 2022
iPhone and iPod Touch version of Skeleton Key: is an addictive and unique puzzle game in which you shift keys around the board unlocking treasure chests. Made with cocos2d-iphone.

Skeleton Key (iOS) Skeleton Key is an addictive and unique puzzle game in which you shift keys around the board unlocking treasure chests. It's availa

null 117 Jun 6, 2022
Recreating the Poketch from Pokemon Diamond and Pearl on the Apple Watch with SwiftUI and WatchOS 8

Apple Watch Poketch What is it? It's an Apple Watch remake of the "Poketch" from Pokemon Diamond and Pearl made with SwiftUI! Check out the YouTube vi

Idrees Hassan 297 Dec 31, 2022
XCode and Swift game based on the generation of random cards and some functions related to the comparison of the results.

war-card-game-V1 XCode and Swift game based on the generation of random cards and some functions related to the comparison of the results. Once a card

Eduard 1 Dec 10, 2021
Gamer-s-Collection - An app for searching and saving favorite games using rawg.io api and Core Data

Gamer-s-Collection - An app for searching and saving favorite games using rawg.io api and Core Data

Rıdvan İmren 1 Aug 19, 2022
Glide is a SpriteKit and GameplayKit based engine for building 2d games easily

Glide is a SpriteKit and GameplayKit based engine for building 2d games easily, with a focus on side scrollers. Glide is developed with Swift and works on iOS, macOS and tvOS.

null 433 Jan 6, 2023
A game engine built with SDL and Swift.

Lark A game engine made with Swift and SDL. This is a pre-alpha work-in-progress. Don't try to use this unless you really know what you're doing. I ba

June Bash 41 Mar 11, 2022