WSOSC

- a Cocoa framework for Open Sound Control


Introduction

WSOSC is a Cocoa framework, written in pure Objective-C, which supports functions for handling Open Sound Control data. Compared to the previously available Cocoa OSC libraries, WSOSC provides an integrated environment and easier ways to parse OSC packets; classes for client functions (that is, to compose and send messages) will also be offered.
Currently WSOSC can parse the following information:
  • packet validity: data length and content
  • packet type: message/bundle
  • address patterns
  • type tag string
  • arguments: int32, float32, OSC-string

Version: 0.1

This is a work in progress, and currently WSOSC needs a number of improvements. Next version will (hopefully) support:
  • OSC client features
  • Zeroconf support
  • TCP support (in addition to UDP)

Class information

WSOSC has three major classes: WSOSCPacket, WSOSCBundle, and WSOSCMessage. Methods of these classes are described below.

WSOSCMessage

  • - (id)initWithDataFrom:(NSString *)data;
    Initiates and returns an instance of WSOSCMessage with the data parsed from data (mostly handed over fromthe instance of WSOSCPacket or WSOSCBundle).
  • + (id)messageParsedFrom:(NSString *)data;
    Similar to - (id)initWithDataFrom:(NSString *)data;. This returns an autoreleased instance.
  • - (void)parseFrom:(NSString *)data;
    Parses the data and stores information.
  • - (NSString *)addressString;
    Returns address patterns as one NSString.
  • - (NSArray *)addressPattern;
    Returns address patterns as an NSArray, which contains each address pattern as elements.
  • - (int)numberOfAddressPatterns;
    Returns the number of address patterns.
  • - (NSString *)addressPatternAtIndex:(int)index;
    Returns the address pattern at index.
  • - (BOOL)hasTypeTag;
    Checks if the message has a type tag; this is necessary to deal with some old implementations of OSC.
  • - (NSString *)typeTagString;
    Returns type tags as one NSString.
  • - (char)typeTagAtIndex:(int)index;
    Returns the type tag character at index.
  • - (int)numberOfArguments;
    Returns the number of arguments in message.
  • - (NSMutableArray *)arguments;
    Returns arguments as an NSMutableArray, which contains each argument as elements.
  • - (id)argumentAtIndex:(int)index;
    Returns the argument at index.

WSOSCBundle

  • - (id)initWithDataFrom:(NSString *)data;
    Initiates and returns an instance of WSOSCBundle with the data parsed from data (mostly handed over from the instance of WSOSCPacket).
  • + (id)bundleParsedFrom:(NSString*)data;
    Similar to - (id)initWithDataFrom:(NSString *)data;. This returns an autoreleased instance.
  • - (void)parseFrom:(NSString *)data;
    Parses the data and stores information.
  • - (int)numberOfBundles;
    Returns the number of bundles in message.
  • - (NSNumber *)bundleTimeTag;
    Returns bundle time tag (not implemented yet).
  • - (NSMutableArray *)bundles;
    Returns bundless as an NSMutableArray, which contains each bundle as elements.
  • - (WSOSCMessage *)bundleAtIndex:(int)index;
    Returns the bundle at index. Here, each bundle is equivalent to a message.

WSOSCPacket

  • - (id)initWithDataFrom:(NSString *)data;
    Initiates and returns an instance of WSOSCPacket with the data parsed from data, which is the input from UDP socket.
  • + (id)packetParsedFrom:(NSString *)data;
    Similar to - (id)initWithDataFrom:(NSString *)data;. This returns an autoreleased instance.
  • - (void)parseFrom:(NSString *)data;
    Parses the data and stores information.
  • - (int)type;
    Type of the parsed packet. This can return four values: -1: Invalid packet (neither a message nor a bundle). 0: Invalid packet (size is not a multiple of 4). 1: Packet is a valid message. 2: Packet is a valid bundle.
  • - (id)content;
    Returns the content of parsed packet. Depending on the type of the packet , an instance of WSOSCMessage or WSOSCBundle will be returned.

Applications that incorporate WSOSC

  • SonART
  • WSDumpOSC (under construction)

Downloads

  • WSOSC.zip (project directory, zipped: 16[KB])