OSCKit - The OSCKit package provides the classes needed for your apps to communicate among computers, sound synthesizers

Related tags

Audio OSCKit
Overview

“OSCKit”/

OSCKit

The OSCKit 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 OSCKit 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.

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

An example project can be found in OSCKitDemo.

License

OSCKit is licensed under the GNU Affero General Public License, version 3. If you require a commercial license for an application that you would not like to trigger AGPLv3 obligations (e.g. open sourcing your application), please get in touch. The probability of obtaining a commerical license for free is high.

Features

  • UDP and TCP Transport options
  • UDP Servers can join multicast groups
  • UDP Clients can broadcast packets
  • UDP Peer (A shared socket for sending and receiving OSC packets on)
  • 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/SammySmallman/OSCKit

Swift Package Manager

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

dependencies: [
    .package(url: "https://github.com/SammySmallman/OSCKit", .upToNextMajor(from: "3.1.0"))
]

App Sandbox Network Settings

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

Quick Start

TCP Client

Step 1

Import OSCKit into your project

import OSCKit

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 OSCKit into your project

import OSCKit

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 OSCKit into your project

import OSCKit

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 OSCKit into your project

import OSCKit

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)
}
UDP Peer

Step 1

Import OSCKit into your project

import OSCKit

Step 2

Create a peer

let peer = OSCUdpPeer(host: "10.101.130.101",
                      port: 24601,
                      hostPort: 3001)

Step 3

Conform to the peers delegate protocol OSCUdpPeerDelegate:

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

    func peer(_ peer: OSCUdpPeer, didReadData data: Data, with error: Error) {
        print("Peer did read data with error: \(error.localizedDescription)")
    }

    func peer(_ peer: OSCUdpPeer, didSendPacket packet: OSCPacket, fromHost host: String?, port: UInt16?) {
        print("Peer sent packet to \(peer.host):\(peer.hostPort) from \(host):\(port)")
    }

    func peer(_ peer: OSCUdpPeer, didNotSendPacket packet: OSCPacket, fromHost host: String?, port: UInt16?, error: Error?) {
        print("Peer did not send packet to \(peer.host):\(peer.hostPort) from \(host):\(port)")
    }

    func peer(_ peer: OSCUdpPeer, socketDidCloseWithError error: Error?) {
        print("Peer 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

peer.send(message)

CoreOSC

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

Authors

Sammy Smallman - Initial Work - SammySmallman

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

Acknowledgments

You might also like...
Provides type-safe access to localized musical instruments and their tunings.

InstrumentKit InstrumentKit provides type-safe access to localized musical instruments and their tunings. Table of Contents Work In Progress Installat

Fast Campus iOS App Development All-in-one Package Online Clone Coding
Fast Campus iOS App Development All-in-one Package Online Clone Coding

애플뮤직 클론 코딩 패스트캠퍼스 iOS 앱 개발 올인원 패키지 Online 클론코딩 사용요소 UICollectionReusableView , c

AudioPlayer is a simple class for playing audio in iOS, macOS and tvOS apps.
AudioPlayer is a simple class for playing audio in iOS, macOS and tvOS apps.

AudioPlayer AudioPlayer is a simple class for playing audio in iOS, macOS and tvOS apps.

Learn to Code While Building Apps - The Complete iOS Development Bootcamp
Learn to Code While Building Apps - The Complete iOS Development Bootcamp

Xylophone Our Goal The goal of this tutorial is to dive into a simple iOS recipe - how to play sound and use an Apple library called AVFoundation. The

Run iOS apps & games on M1 Mac with mouse, keyboard and controller support.
Run iOS apps & games on M1 Mac with mouse, keyboard and controller support.

‎ PlayCover Run iOS apps & games on M1 Mac with mouse, keyboard and controller support. Showcase · Contribute · Discord About the fork & Disclaimer Th

🖥 Control your display's brightness & volume on your Mac as if it was a native Apple Display
🖥 Control your display's brightness & volume on your Mac as if it was a native Apple Display

🖥 Control your display's brightness & volume on your Mac as if it was a native Apple Display. Use Apple Keyboard keys or custom shortcuts. Shows the native macOS OSDs.

AudioPlayer is syntax and feature sugar over AVPlayer. It plays your audio files (local & remote).

AudioPlayer AudioPlayer is a wrapper around AVPlayer. It also offers cool features such as: Quality control based on number of interruption (buffering

FDWaveformView is an easy way to display an audio waveform in your app
FDWaveformView is an easy way to display an audio waveform in your app

FDWaveformView is an easy way to display an audio waveform in your app. It is a nice visualization to show a playing audio file or to select a position in a file.

🗣Voice overlay helps you turn your user's voice into text, providing a polished UX while handling for you the necessary permissions
🗣Voice overlay helps you turn your user's voice into text, providing a polished UX while handling for you the necessary permissions

Voice overlay helps you turn your user's voice into text, providing a polished UX while handling for you the necessary permissions. It uses i

Comments
  • OSCTcpClient delegate method

    OSCTcpClient delegate method

    client(_ client: OSCTcpClient, didDisconnectWith error: Error?) should be client(_ client: OSCTcpClient, didDisconnectWithError error: Error?) to follow all other method naming styles.

    opened by sammysmallman 0
Releases(3.1.0)
Owner
Sammy Smallman
Founder of @artifice-industries
Sammy Smallman
AudioKit Sample Player (ROM Player) - EXS24, Sound Font, Wave Player

AudioKit ROM / Sample Player Welcome to the official AudioKit example of a sample-based music instrument written in Swift. It can be modified to play

AudioKit 500 Dec 27, 2022
A sound fader for AVAudioPlayer written in Swift for iOS, tvOS and macOS.

Cephalopod, a sound fader for AvAudioPlayer written in Swift - iOS, tvOS and macOS This library can help fading sounds in and out with AvAudioPlayer.

Evgenii Neumerzhitckii 109 Dec 16, 2022
iOS framework for the Quiet Modem (data over sound)

QuietModemKit This is the iOS framework for https://github.com/quiet/quiet With this library, you can send data through sound. Live demo: https://quie

Quiet Modem Project 442 Nov 17, 2022
PitchPerfect - A simple iOS app for the Udacity Nanodegree which explores AVFoundation to record a short sound

PitchPerfect App A simple iOS app for the Udacity Nanodegree which explores AVFo

Mark Han 0 Feb 12, 2022
Play and share sound inserts from Medo e Delírio em Brasília, a Brazilian podcast.

Play and share sound inserts from Medo e Delírio em Brasília, a Brazilian podcast.

Rafael Schmitt 18 Dec 26, 2022
Extensions and classes in Swift that make it easy to get an iOS device reading and processing MIDI data

MorkAndMIDI A really thin Swift layer on top of CoreMIDI that opens a virtual MIDI destination and port and connects to any MIDI endpoints that appear

Brad Howes 11 Nov 5, 2022
Swift-music - swift-music is a swift package that provides an easy-to-use API for music related developments.

?? swift-music Introduction swift-music is a swift package that provides an easy-to-use API for music related developments. Currently available module

Jin Zhang 4 Feb 8, 2022
KeyAudioManager - A swift package to make it a lot easier to play audio in your app

KeyAudioManager A swift package to make it a lot easier to play audio in your ap

Pedro Esli 3 Apr 28, 2022
MusicTheoryKit: a swift module that provides an easy-to-use API for most commonly used music terms

MusicTheoryKit Introduction MusicTheoryKit is a Swift framework that provides an easy-to-use API for most commonly used music terms. Create notes, ass

Jin Zhang 4 Feb 8, 2022
Provides API access to localized musical instruments and their tunings.

instruments.fyi instruments.fyi provides API access to localized musical instruments and their tunings provided by InstrumentKit. Table of Contents Wo

Brian Drelling 10 Sep 5, 2022