updated embedded frameworks to link to 10.4 SDK
This commit is contained in:
parent
44af1938db
commit
d6b6b48f7e
|
@ -1,69 +0,0 @@
|
||||||
**************************************************************************
|
|
||||||
This program is free software; you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation; either version 2 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program; if not, write to the Free Software
|
|
||||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
||||||
|
|
||||||
**************************************************************************
|
|
||||||
|
|
||||||
|
|
||||||
Introduction
|
|
||||||
============
|
|
||||||
|
|
||||||
sc3ctrl is a command line utility which uses OpenSoundControl to control
|
|
||||||
SuperCollider3.app in OSX.
|
|
||||||
|
|
||||||
Consists of a small CoreFoundation bundle written in Objective-C and a
|
|
||||||
single SuperCollider class.
|
|
||||||
|
|
||||||
Binary: http://www.trapdoor1.net/sc3/sc3ctrl.tar.gz
|
|
||||||
(as yet untested on anything other than 10.5)
|
|
||||||
|
|
||||||
Source code: http://github.com/rfwatson/sc3ctrl
|
|
||||||
|
|
||||||
|
|
||||||
Installation
|
|
||||||
============
|
|
||||||
|
|
||||||
1) Drag the bundle into a suitable location on your machine
|
|
||||||
(e.g. /Application/Utilities/)
|
|
||||||
|
|
||||||
2) cd /Application/Utilities/sc3ctrl/
|
|
||||||
|
|
||||||
3) sudo install.rb
|
|
||||||
|
|
||||||
4) Start SuperCollider.app
|
|
||||||
|
|
||||||
|
|
||||||
Usage
|
|
||||||
=====
|
|
||||||
|
|
||||||
sc3ctrl -x Execute the SC code in environment variable SC_INTERPRET_TEXT
|
|
||||||
|
|
||||||
sc3ctrl -x VARIABLE_NAME Execute the SC code in environment variable VARIABLE_NAME
|
|
||||||
|
|
||||||
sc3ctrl -d classname Open help file for classname
|
|
||||||
|
|
||||||
sc3ctrl -j classname Open class definition for classname
|
|
||||||
|
|
||||||
sc3ctrl -y methodname Examine implementations of methodname
|
|
||||||
|
|
||||||
sc3ctrl -Y methodname Examine references to methodname
|
|
||||||
|
|
||||||
sc3ctrl -s Stop server (CMD-PERIOD)
|
|
||||||
|
|
||||||
sc3ctrl -c Clear post window
|
|
||||||
|
|
||||||
sc3ctrl -p Post window to front
|
|
||||||
|
|
||||||
sc3ctrl -k Recompile class library (requires recent build)
|
|
||||||
|
|
|
@ -0,0 +1,140 @@
|
||||||
|
// http://github.com/rfwatson/sc3ctrl
|
||||||
|
|
||||||
|
SC3Controller {
|
||||||
|
classvar nodes;
|
||||||
|
|
||||||
|
*initClass {
|
||||||
|
nodes = List[];
|
||||||
|
|
||||||
|
Platform.case(\osx) {
|
||||||
|
StartUp.add {
|
||||||
|
this.addListeners;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
*addListeners {
|
||||||
|
var node, postToFront;
|
||||||
|
|
||||||
|
postToFront = {
|
||||||
|
Document.listener.front;
|
||||||
|
};
|
||||||
|
|
||||||
|
if(nodes.isEmpty) {
|
||||||
|
node = OSCresponderNode(nil, '/sc3ctrl/cmd') { |t, r, msg|
|
||||||
|
msg[1].asString.interpretPrint;
|
||||||
|
{ postToFront.() }.defer;
|
||||||
|
}.add;
|
||||||
|
nodes.add(node);
|
||||||
|
|
||||||
|
node = OSCresponderNode(nil, '/sc3ctrl/help') { |t, r, msg|
|
||||||
|
{ msg[1].asString.openHelpFile }.defer
|
||||||
|
}.add;
|
||||||
|
nodes.add(node);
|
||||||
|
|
||||||
|
node = OSCresponderNode(nil, '/sc3ctrl/class') { |t, r, msg|
|
||||||
|
{ msg[1].asString.interpret.openCodeFile }.defer
|
||||||
|
}.add;
|
||||||
|
nodes.add(node);
|
||||||
|
|
||||||
|
node = OSCresponderNode(nil, '/sc3ctrl/implementations') { |t, r, msg|
|
||||||
|
{ SC3Controller.methodTemplates(msg[1]) }.defer
|
||||||
|
}.add;
|
||||||
|
nodes.add(node);
|
||||||
|
|
||||||
|
node = OSCresponderNode(nil, '/sc3ctrl/references') { |t, r, msg|
|
||||||
|
{ SC3Controller.methodReferences(msg[1]) }.defer
|
||||||
|
}.add;
|
||||||
|
nodes.add(node);
|
||||||
|
|
||||||
|
node = OSCresponderNode(nil, '/sc3ctrl/stop') { |t, r, msg|
|
||||||
|
thisProcess.stop;
|
||||||
|
}.add;
|
||||||
|
nodes.add(node);
|
||||||
|
|
||||||
|
node = OSCresponderNode(nil, '/sc3ctrl/clear') { |t, r, msg|
|
||||||
|
{
|
||||||
|
Document.listener.string = ""; "";
|
||||||
|
postToFront.();
|
||||||
|
}.defer;
|
||||||
|
}.add;
|
||||||
|
nodes.add(node);
|
||||||
|
|
||||||
|
node = OSCresponderNode(nil, '/sc3ctrl/postfront') { |t, r, msg|
|
||||||
|
{ postToFront.() }.defer;
|
||||||
|
}.add;
|
||||||
|
nodes.add(node);
|
||||||
|
|
||||||
|
node = OSCresponderNode(nil, '/sc3ctrl/recompile') { |t, r, msg|
|
||||||
|
{
|
||||||
|
thisProcess.recompile;
|
||||||
|
postToFront.();
|
||||||
|
}.defer;
|
||||||
|
}.add;
|
||||||
|
nodes.add(node);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
*removeAllListeners {
|
||||||
|
nodes.do(_.remove);
|
||||||
|
}
|
||||||
|
|
||||||
|
// adapated from Kernel.sc
|
||||||
|
*methodTemplates { |name|
|
||||||
|
var out, found = 0, namestring;
|
||||||
|
out = CollStream.new;
|
||||||
|
out << "Implementations of '" << name << "' :\n";
|
||||||
|
Class.allClasses.do({ arg class;
|
||||||
|
class.methods.do({ arg method;
|
||||||
|
if (method.name == name, {
|
||||||
|
found = found + 1;
|
||||||
|
namestring = class.name ++ ":" ++ name;
|
||||||
|
out << " " << namestring << " : ";
|
||||||
|
if (method.argNames.isNil or: { method.argNames.size == 1 }, {
|
||||||
|
out << "this." << name;
|
||||||
|
if (name.isSetter, { out << "(val)"; });
|
||||||
|
},{
|
||||||
|
out << method.argNames.at(0);
|
||||||
|
if (name.asString.at(0).isAlpha, {
|
||||||
|
out << "." << name << "(";
|
||||||
|
method.argNames.do({ arg argName, i;
|
||||||
|
if (i > 0, {
|
||||||
|
if (i != 1, { out << ", " });
|
||||||
|
out << argName;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
out << ")";
|
||||||
|
},{
|
||||||
|
out << " " << name << " ";
|
||||||
|
out << method.argNames.at(1);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
out.nl;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
if(found == 0)
|
||||||
|
{
|
||||||
|
Post << "\nNo implementations of '" << name << "'.\n";
|
||||||
|
}
|
||||||
|
{
|
||||||
|
out.collection.newTextWindow(name.asString);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
// adapted from Kernel.sc
|
||||||
|
*methodReferences { |name|
|
||||||
|
var out, references;
|
||||||
|
name = name.asSymbol;
|
||||||
|
out = CollStream.new;
|
||||||
|
references = Class.findAllReferences(name);
|
||||||
|
|
||||||
|
if (references.notNil, {
|
||||||
|
out << "References to '" << name << "' :\n";
|
||||||
|
references.do({ arg ref; out << " " << ref.asString << "\n"; });
|
||||||
|
out.collection.newTextWindow(name.asString);
|
||||||
|
},{
|
||||||
|
Post << "\nNo references to '" << name << "'.\n";
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
|
@ -1 +0,0 @@
|
||||||
Versions/Current/Headers
|
|
|
@ -0,0 +1,28 @@
|
||||||
|
//
|
||||||
|
// AddressValPair.h
|
||||||
|
// VVOSC
|
||||||
|
//
|
||||||
|
// Created by bagheera on 12/11/08.
|
||||||
|
// Copyright 2008 __MyCompanyName__. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
#if IPHONE
|
||||||
|
#import <UIKit/UIKit.h>
|
||||||
|
#else
|
||||||
|
#import <Cocoa/Cocoa.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@interface AddressValPair : NSObject {
|
||||||
|
NSString *address;
|
||||||
|
id val;
|
||||||
|
}
|
||||||
|
|
||||||
|
+ (id) createWithAddress:(NSString *)a val:(id)v;
|
||||||
|
- (id) initWithAddress:(NSString *)a val:(id)v;
|
||||||
|
|
||||||
|
- (NSString *) address;
|
||||||
|
- (id) val;
|
||||||
|
|
||||||
|
@end
|
|
@ -0,0 +1,34 @@
|
||||||
|
//
|
||||||
|
// OSCBundle.h
|
||||||
|
// OSC
|
||||||
|
//
|
||||||
|
// Created by bagheera on 9/20/08.
|
||||||
|
// Copyright 2008 __MyCompanyName__. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
#if IPHONE
|
||||||
|
#import <UIKit/UIKit.h>
|
||||||
|
#else
|
||||||
|
#import <Cocoa/Cocoa.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#import "OSCMessage.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@interface OSCBundle : NSObject {
|
||||||
|
NSMutableArray *elementArray; // array of messages or bundles
|
||||||
|
}
|
||||||
|
|
||||||
|
+ (void) parseRawBuffer:(unsigned char *)b ofMaxLength:(int)l toInPort:(id)p;
|
||||||
|
|
||||||
|
+ (id) create;
|
||||||
|
|
||||||
|
- (void) addElement:(id)n;
|
||||||
|
- (void) addElementArray:(NSArray *)a;
|
||||||
|
|
||||||
|
- (int) bufferLength;
|
||||||
|
- (void) writeToBuffer:(unsigned char *)b;
|
||||||
|
|
||||||
|
@end
|
|
@ -0,0 +1,93 @@
|
||||||
|
//
|
||||||
|
// OSCInPort.h
|
||||||
|
// OSC
|
||||||
|
//
|
||||||
|
// Created by bagheera on 9/20/08.
|
||||||
|
// Copyright 2008 __MyCompanyName__. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
#if IPHONE
|
||||||
|
#import <UIKit/UIKit.h>
|
||||||
|
#else
|
||||||
|
#import <Cocoa/Cocoa.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
//#import <sys/types.h>
|
||||||
|
//#import <sys/socket.h>
|
||||||
|
#import <netinet/in.h>
|
||||||
|
|
||||||
|
#import <pthread.h>
|
||||||
|
#import "AddressValPair.h"
|
||||||
|
#import "OSCPacket.h"
|
||||||
|
#import "OSCBundle.h"
|
||||||
|
#import "OSCMessage.h"
|
||||||
|
|
||||||
|
|
||||||
|
@protocol OSCInPortDelegateProtocol
|
||||||
|
- (void) oscMessageReceived:(NSDictionary *)d;
|
||||||
|
- (void) receivedOSCVal:(id)v forAddress:(NSString *)a;
|
||||||
|
@end
|
||||||
|
|
||||||
|
@protocol OSCDelegateProtocol
|
||||||
|
- (void) oscMessageReceived:(NSDictionary *)d;
|
||||||
|
- (void) receivedOSCVal:(id)v forAddress:(NSString *)a;
|
||||||
|
@end
|
||||||
|
|
||||||
|
|
||||||
|
@interface OSCInPort : NSObject {
|
||||||
|
BOOL deleted; // whether or not i'm deleted- ensures that socket gets closed
|
||||||
|
BOOL bound; // whether or not the socket is bound
|
||||||
|
int sock; // socket file descriptor. remember, everything in unix is files!
|
||||||
|
struct sockaddr_in addr; // struct that describes *my* address (this is an in port)
|
||||||
|
unsigned short port; // the port number i'm receiving from
|
||||||
|
BOOL running; // whether or not i should keep running
|
||||||
|
BOOL busy;
|
||||||
|
unsigned char buf[8192]; // the socket gets data and dumps it here immediately
|
||||||
|
|
||||||
|
pthread_mutex_t lock;
|
||||||
|
NSTimer *threadTimer;
|
||||||
|
int threadTimerCount;
|
||||||
|
NSAutoreleasePool *threadPool;
|
||||||
|
|
||||||
|
NSString *portLabel; // the "name" of the port (added to distinguish multiple osc input ports for bonjour)
|
||||||
|
NSNetService *zeroConfDest; // bonjour service for publishing this input's address...only active if there's a portLabel!
|
||||||
|
|
||||||
|
NSMutableDictionary *scratchDict; // key of dict is address port; object at key is a mut. array. coalesced messaging.
|
||||||
|
NSMutableArray *scratchArray; // array of AddressValPair objects. used for serial messaging.
|
||||||
|
id delegate; // my delegate gets notified of incoming messages
|
||||||
|
}
|
||||||
|
|
||||||
|
+ (id) createWithPort:(unsigned short)p;
|
||||||
|
+ (id) createWithPort:(unsigned short)p labelled:(NSString *)n;
|
||||||
|
- (id) initWithPort:(unsigned short)p;
|
||||||
|
- (id) initWithPort:(unsigned short)p labelled:(NSString *)n;
|
||||||
|
|
||||||
|
- (void) prepareToBeDeleted;
|
||||||
|
|
||||||
|
- (NSDictionary *) createSnapshot;
|
||||||
|
|
||||||
|
- (BOOL) createSocket;
|
||||||
|
- (void) start;
|
||||||
|
- (void) stop;
|
||||||
|
- (void) launchOSCLoop:(id)o;
|
||||||
|
- (void) OSCThreadProc:(NSTimer *)t;
|
||||||
|
- (void) parseRawBuffer:(unsigned char *)b ofMaxLength:(int)l;
|
||||||
|
|
||||||
|
// if the delegate im
|
||||||
|
- (void) handleParsedScratchDict:(NSDictionary *)d;
|
||||||
|
- (void) handleScratchArray:(NSArray *)a;
|
||||||
|
|
||||||
|
- (void) addValue:(id)val toAddressPath:(NSString *)p;
|
||||||
|
|
||||||
|
- (unsigned short) port;
|
||||||
|
- (void) setPort:(unsigned short)n;
|
||||||
|
- (NSString *) portLabel;
|
||||||
|
- (void) setPortLabel:(NSString *)n;
|
||||||
|
- (NSNetService *) zeroConfDest;
|
||||||
|
- (BOOL) bound;
|
||||||
|
|
||||||
|
- (id) delegate;
|
||||||
|
- (void) setDelegate:(id)n;
|
||||||
|
|
||||||
|
@end
|
|
@ -0,0 +1,144 @@
|
||||||
|
//
|
||||||
|
// OSCManager.h
|
||||||
|
// OSC
|
||||||
|
//
|
||||||
|
// Created by bagheera on 9/20/08.
|
||||||
|
// Copyright 2008 __MyCompanyName__. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
#if IPHONE
|
||||||
|
#import <UIKit/UIKit.h>
|
||||||
|
#else
|
||||||
|
#import <Cocoa/Cocoa.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#import "OSCZeroConfManager.h"
|
||||||
|
#import "OSCInPort.h"
|
||||||
|
#import "OSCOutPort.h"
|
||||||
|
#import <pthread.h>
|
||||||
|
|
||||||
|
/*
|
||||||
|
TOP-LEVEL OVERVIEW
|
||||||
|
|
||||||
|
this osc manager class is all you need to add to your app. it has methods for
|
||||||
|
adding and removing ports. you can have as many osc managers as you like, but
|
||||||
|
you should really only need one instance.
|
||||||
|
|
||||||
|
input ports have a delegate- delegate methods are called as the port receives data.
|
||||||
|
it's important to note that the delegate methods must be thread-safe: each input
|
||||||
|
port is running on its own (non-main) thread.
|
||||||
|
|
||||||
|
data is sent via the output ports (convenience methods for doing this are built
|
||||||
|
into the osc manager).
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
GENERAL OSC STRUCTURE AND OVERVIEW
|
||||||
|
|
||||||
|
this framework was written from the OSC spec found here:
|
||||||
|
http://opensoundcontrol.org/spec-1_0
|
||||||
|
|
||||||
|
- an OSC packet is the basic unit of transmitting OSC data.
|
||||||
|
- an OSC packet consists of:
|
||||||
|
- contents- contiguous block of binary data (either a bundle or a message), and then the
|
||||||
|
- size- number of 8-bit bytes that comprise 'contents'- ALWAYS multiple of 4!
|
||||||
|
- an OSC message consists of:
|
||||||
|
- an OSC address pattern (starting with '/'), followed by
|
||||||
|
- an OSC type tag string, followed by
|
||||||
|
- zero or more 'OSC arguments'
|
||||||
|
- an OSC bundle consists of:
|
||||||
|
- the OSC-string "#bundle", followed by
|
||||||
|
- an OSC time tag, followed by
|
||||||
|
- zero or more 'OSC bundle elements'
|
||||||
|
- an OSC bundle element consists of:
|
||||||
|
- 'size' (int32)- number of 8-bit bytes in the contents- ALWAYS multiple of 4!
|
||||||
|
- 'contents'- either another OSC bundle, or an OSC message
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
PORTS- SENDING AND RECEIVING UDP/TCP DATA
|
||||||
|
|
||||||
|
some basic information, gleaned from:
|
||||||
|
http://beej.us/guide/bgnet/output/html/multipage/index.html
|
||||||
|
|
||||||
|
struct sockaddr {
|
||||||
|
unsigned short sa_family; // address family, AF_xxx
|
||||||
|
char sa_data[14]; // 14 bytes of protocol address
|
||||||
|
}
|
||||||
|
struct sockaddr_in {
|
||||||
|
short int sin_family; // address family
|
||||||
|
unsigned short int sin_port; // port number
|
||||||
|
struct in_addr sin_addr; // internet address
|
||||||
|
unsigned char sin_zero[8]; // exists so sockaddr_in has same length as sockaddr
|
||||||
|
}
|
||||||
|
|
||||||
|
recv(int sockfd, void *buf, int len, unsigned int flags);
|
||||||
|
- sockfd is the socket descriptor to read from
|
||||||
|
- buf is the buffer to read the information into
|
||||||
|
- len is the max length of the buffer
|
||||||
|
- flags can be set to 0
|
||||||
|
recvfrom(int sockfd, void *buf, int len, unsigned int flags, struct sockaddr *from, int *fromlen);
|
||||||
|
- from is a pointer to a local struct sockaddr that will be filled with the IP & port of the originating machine
|
||||||
|
- fromlen is a pointer to a local int that should be initialized to a sizeof(struct sockaddr)- contains length of address actually stored in from on return
|
||||||
|
...as well as the 4 params listed above in recv()
|
||||||
|
|
||||||
|
int select(int numfds, fd_set *readrds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout);
|
||||||
|
*/
|
||||||
|
|
||||||
|
@interface OSCManager : NSObject {
|
||||||
|
NSMutableArray *inPortArray;
|
||||||
|
NSMutableArray *outPortArray;
|
||||||
|
|
||||||
|
pthread_rwlock_t inPortLock;
|
||||||
|
pthread_rwlock_t outPortLock;
|
||||||
|
|
||||||
|
id delegate;
|
||||||
|
|
||||||
|
OSCZeroConfManager *zeroConfManager; // bonjour/zero-configuration manager
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) deleteAllInputs;
|
||||||
|
- (void) deleteAllOutputs;
|
||||||
|
// methods for creating input ports
|
||||||
|
- (OSCInPort *) createNewInputFromSnapshot:(NSDictionary *)s;
|
||||||
|
- (OSCInPort *) createNewInputForPort:(int)p withLabel:(NSString *)l;
|
||||||
|
- (OSCInPort *) createNewInputForPort:(int)p;
|
||||||
|
- (OSCInPort *) createNewInput;
|
||||||
|
// methods for creating output ports
|
||||||
|
- (OSCOutPort *) createNewOutputFromSnapshot:(NSDictionary *)s;
|
||||||
|
- (OSCOutPort *) createNewOutputToAddress:(NSString *)a atPort:(int)p withLabel:(NSString *)l;
|
||||||
|
- (OSCOutPort *) createNewOutputToAddress:(NSString *)a atPort:(int)p;
|
||||||
|
- (OSCOutPort *) createNewOutput;
|
||||||
|
|
||||||
|
// typically, the manager is the input port's delegate- input ports tell delegates when they receive data
|
||||||
|
// this method is called and contains coalesced messages (grouped by address path)
|
||||||
|
- (void) oscMessageReceived:(NSDictionary *)d;
|
||||||
|
// this method is called every time any osc val is processed
|
||||||
|
- (void) receivedOSCVal:(id)v forAddress:(NSString *)a;
|
||||||
|
|
||||||
|
// methods for working with ports
|
||||||
|
- (NSString *) getUniqueInputLabel;
|
||||||
|
- (NSString *) getUniqueOutputLabel;
|
||||||
|
- (OSCInPort *) findInputWithLabel:(NSString *)n;
|
||||||
|
- (OSCOutPort *) findOutputWithLabel:(NSString *)n;
|
||||||
|
- (OSCOutPort *) findOutputWithAddress:(NSString *)a andPort:(int)p;
|
||||||
|
- (OSCOutPort *) findOutputForIndex:(int)i;
|
||||||
|
- (OSCInPort *) findInputWithZeroConfName:(NSString *)n;
|
||||||
|
- (void) removeInput:(id)p;
|
||||||
|
- (void) removeOutput:(id)p;
|
||||||
|
- (NSArray *) outPortLabelArray;
|
||||||
|
|
||||||
|
// subclassable methods for customizing
|
||||||
|
- (id) inPortClass;
|
||||||
|
- (NSString *) inPortLabelBase;
|
||||||
|
- (id) outPortClass;
|
||||||
|
|
||||||
|
// misc
|
||||||
|
- (id) delegate;
|
||||||
|
- (void) setDelegate:(id)n;
|
||||||
|
- (NSMutableArray *) inPortArray;
|
||||||
|
- (NSMutableArray *) outPortArray;
|
||||||
|
|
||||||
|
@end
|
|
@ -0,0 +1,43 @@
|
||||||
|
//
|
||||||
|
// OSCMessage.h
|
||||||
|
// OSC
|
||||||
|
//
|
||||||
|
// Created by bagheera on 9/20/08.
|
||||||
|
// Copyright 2008 __MyCompanyName__. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
#if IPHONE
|
||||||
|
#import <UIKit/UIKit.h>
|
||||||
|
#else
|
||||||
|
#import <Cocoa/Cocoa.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#import <pthread.h>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@interface OSCMessage : NSObject {
|
||||||
|
NSString *address;
|
||||||
|
NSMutableArray *typeArray;
|
||||||
|
NSMutableArray *argArray;
|
||||||
|
pthread_rwlock_t lock;
|
||||||
|
}
|
||||||
|
|
||||||
|
+ (void) parseRawBuffer:(unsigned char *)b ofMaxLength:(int)l toInPort:(id)p;
|
||||||
|
+ (id) createMessageToAddress:(NSString *)a;
|
||||||
|
- (id) initWithAddress:(NSString *)a;
|
||||||
|
|
||||||
|
- (void) addInt:(int)n;
|
||||||
|
- (void) addFloat:(float)n;
|
||||||
|
#if IPHONE
|
||||||
|
- (void) addColor:(UIColor *)c;
|
||||||
|
#else
|
||||||
|
- (void) addColor:(NSColor *)c;
|
||||||
|
#endif
|
||||||
|
- (void) addBOOL:(BOOL)n;
|
||||||
|
- (void) addString:(NSString *)n;
|
||||||
|
|
||||||
|
- (int) bufferLength;
|
||||||
|
- (void) writeToBuffer:(unsigned char *)b;
|
||||||
|
|
||||||
|
@end
|
|
@ -0,0 +1,58 @@
|
||||||
|
//
|
||||||
|
// OSCOutPort.h
|
||||||
|
// OSC
|
||||||
|
//
|
||||||
|
// Created by bagheera on 9/20/08.
|
||||||
|
// Copyright 2008 __MyCompanyName__. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
#if IPHONE
|
||||||
|
#import <UIKit/UIKit.h>
|
||||||
|
#else
|
||||||
|
#import <Cocoa/Cocoa.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#include <arpa/inet.h>
|
||||||
|
|
||||||
|
#import "OSCPacket.h"
|
||||||
|
#import "OSCBundle.h"
|
||||||
|
#import "OSCMessage.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@interface OSCOutPort : NSObject {
|
||||||
|
BOOL deleted;
|
||||||
|
int sock;
|
||||||
|
struct sockaddr_in addr;
|
||||||
|
unsigned short port;
|
||||||
|
NSString *addressString;
|
||||||
|
NSString *portLabel; // used it to distinguish between multiple osc outputs
|
||||||
|
}
|
||||||
|
|
||||||
|
+ (id) createWithAddress:(NSString *)a andPort:(unsigned short)p;
|
||||||
|
+ (id) createWithAddress:(NSString *)a andPort:(unsigned short)p labelled:(NSString *)l;
|
||||||
|
- (id) initWithAddress:(NSString *)a andPort:(unsigned short)p;
|
||||||
|
- (id) initWithAddress:(NSString *)a andPort:(unsigned short)p labelled:(NSString *)l;
|
||||||
|
- (void) prepareToBeDeleted;
|
||||||
|
|
||||||
|
- (NSDictionary *) createSnapshot;
|
||||||
|
|
||||||
|
- (BOOL) createSocket;
|
||||||
|
|
||||||
|
- (void) sendThisBundle:(OSCBundle *)b;
|
||||||
|
- (void) sendThisMessage:(OSCMessage *)m;
|
||||||
|
- (void) sendThisPacket:(OSCPacket *)p;
|
||||||
|
|
||||||
|
- (void) setAddressString:(NSString *)n;
|
||||||
|
- (void) setPort:(unsigned short)p;
|
||||||
|
- (void) setAddressString:(NSString *)n andPort:(unsigned short)p;
|
||||||
|
|
||||||
|
- (NSString *) portLabel;
|
||||||
|
- (void) setPortLabel:(NSString *)n;
|
||||||
|
|
||||||
|
- (unsigned short) port;
|
||||||
|
- (NSString *) addressString;
|
||||||
|
|
||||||
|
@end
|
|
@ -0,0 +1,37 @@
|
||||||
|
//
|
||||||
|
// OSCPacket.h
|
||||||
|
// OSC
|
||||||
|
//
|
||||||
|
// Created by bagheera on 9/20/08.
|
||||||
|
// Copyright 2008 __MyCompanyName__. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
#if IPHONE
|
||||||
|
#import <UIKit/UIKit.h>
|
||||||
|
#else
|
||||||
|
#import <Cocoa/Cocoa.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#import "OSCBundle.h"
|
||||||
|
#import "OSCMessage.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
this class requires a bundle or message on create/init. the buffer/msg
|
||||||
|
is NOT retained by this class in any way- it's used to immediately create
|
||||||
|
the buffer which will be sent.
|
||||||
|
*/
|
||||||
|
|
||||||
|
@interface OSCPacket : NSObject {
|
||||||
|
int bufferLength;
|
||||||
|
unsigned char *payload;
|
||||||
|
}
|
||||||
|
|
||||||
|
+ (void) parseRawBuffer:(unsigned char *)b ofMaxLength:(int)l toInPort:(id)p;
|
||||||
|
+ (id) createWithContent:(id)c;
|
||||||
|
- (id) initWithContent:(id)c;
|
||||||
|
|
||||||
|
- (int) bufferLength;
|
||||||
|
- (unsigned char *) payload;
|
||||||
|
|
||||||
|
@end
|
|
@ -0,0 +1,44 @@
|
||||||
|
//
|
||||||
|
// OSCZeroConfDomain.h
|
||||||
|
// VVOSC
|
||||||
|
//
|
||||||
|
// Created by bagheera on 12/9/08.
|
||||||
|
// Copyright 2008 __MyCompanyName__. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
#if IPHONE
|
||||||
|
#import <UIKit/UIKit.h>
|
||||||
|
#else
|
||||||
|
#import <Cocoa/Cocoa.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#import <pthread.h>
|
||||||
|
#import <sys/socket.h>
|
||||||
|
#include <arpa/inet.h>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@interface OSCZeroConfDomain : NSObject {
|
||||||
|
NSString *domainString;
|
||||||
|
NSNetServiceBrowser *serviceBrowser;
|
||||||
|
|
||||||
|
NSMutableArray *servicesArray;
|
||||||
|
pthread_rwlock_t servicesLock;
|
||||||
|
|
||||||
|
id domainManager;
|
||||||
|
}
|
||||||
|
|
||||||
|
+ (id) createWithDomain:(NSString *)d andDomainManager:(id)m;
|
||||||
|
- (id) initWithDomain:(NSString *)d andDomainManager:(id)m;
|
||||||
|
|
||||||
|
// NSNetServiceBrowser delegate methods
|
||||||
|
- (void)netServiceBrowser:(NSNetServiceBrowser *)n didFindService:(NSNetService *)x moreComing:(BOOL)m;
|
||||||
|
- (void)netServiceBrowser:(NSNetServiceBrowser *)n didNotSearch:(NSDictionary *)err;
|
||||||
|
- (void)netServiceBrowser:(NSNetServiceBrowser *)n didRemoveService:(NSNetService *)s moreComing:(BOOL)m;
|
||||||
|
|
||||||
|
// NSNetService delegate methods
|
||||||
|
- (void)netService:(NSNetService *)n didNotResolve:(NSDictionary *)err;
|
||||||
|
- (void)netServiceDidResolveAddress:(NSNetService *)n;
|
||||||
|
|
||||||
|
@end
|
|
@ -0,0 +1,39 @@
|
||||||
|
//
|
||||||
|
// OSCZeroConfManager.h
|
||||||
|
// VVOSC
|
||||||
|
//
|
||||||
|
// Created by bagheera on 12/9/08.
|
||||||
|
// Copyright 2008 __MyCompanyName__. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
#if IPHONE
|
||||||
|
#import <UIKit/UIKit.h>
|
||||||
|
#else
|
||||||
|
#import <Cocoa/Cocoa.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#import "OSCZeroConfDomain.h"
|
||||||
|
#import <pthread.h>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@interface OSCZeroConfManager : NSObject {
|
||||||
|
NSNetServiceBrowser *domainBrowser;
|
||||||
|
|
||||||
|
NSMutableDictionary *domainDict;
|
||||||
|
pthread_rwlock_t domainLock;
|
||||||
|
|
||||||
|
id oscManager;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (id) initWithOSCManager:(id)m;
|
||||||
|
|
||||||
|
- (void) serviceRemoved:(NSNetService *)s;
|
||||||
|
- (void) serviceResolved:(NSNetService *)s;
|
||||||
|
|
||||||
|
// NSNetServiceBrowser delegate methods
|
||||||
|
- (void)netServiceBrowser:(NSNetServiceBrowser *)n didFindDomain:(NSString *)d moreComing:(BOOL)m;
|
||||||
|
- (void)netServiceBrowser:(NSNetServiceBrowser *)n didNotSearch:(NSDictionary *)err;
|
||||||
|
|
||||||
|
@end
|
|
@ -0,0 +1,9 @@
|
||||||
|
|
||||||
|
|
||||||
|
#import "AddressValPair.h"
|
||||||
|
#import "OSCManager.h"
|
||||||
|
#import "OSCZeroConfManager.h"
|
||||||
|
#import "OSCPacket.h"
|
||||||
|
#import "OSCBundle.h"
|
||||||
|
#import "OSCMessage.h"
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
Versions/Current/Resources
|
|
Binary file not shown.
|
@ -0,0 +1,24 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
|
<plist version="1.0">
|
||||||
|
<dict>
|
||||||
|
<key>CFBundleDevelopmentRegion</key>
|
||||||
|
<string>English</string>
|
||||||
|
<key>CFBundleExecutable</key>
|
||||||
|
<string>VVOSC</string>
|
||||||
|
<key>CFBundleGetInfoString</key>
|
||||||
|
<string>0.1.2</string>
|
||||||
|
<key>CFBundleIdentifier</key>
|
||||||
|
<string>com.vidvox.VVOSC</string>
|
||||||
|
<key>CFBundleInfoDictionaryVersion</key>
|
||||||
|
<string>6.0</string>
|
||||||
|
<key>CFBundleName</key>
|
||||||
|
<string>VVOSC</string>
|
||||||
|
<key>CFBundlePackageType</key>
|
||||||
|
<string>FMWK</string>
|
||||||
|
<key>CFBundleSignature</key>
|
||||||
|
<string>????</string>
|
||||||
|
<key>CFBundleVersion</key>
|
||||||
|
<string>0.1.2</string>
|
||||||
|
</dict>
|
||||||
|
</plist>
|
|
@ -1 +0,0 @@
|
||||||
Versions/Current/VVOSC
|
|
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,28 @@
|
||||||
|
//
|
||||||
|
// AddressValPair.h
|
||||||
|
// VVOSC
|
||||||
|
//
|
||||||
|
// Created by bagheera on 12/11/08.
|
||||||
|
// Copyright 2008 __MyCompanyName__. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
#if IPHONE
|
||||||
|
#import <UIKit/UIKit.h>
|
||||||
|
#else
|
||||||
|
#import <Cocoa/Cocoa.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@interface AddressValPair : NSObject {
|
||||||
|
NSString *address;
|
||||||
|
id val;
|
||||||
|
}
|
||||||
|
|
||||||
|
+ (id) createWithAddress:(NSString *)a val:(id)v;
|
||||||
|
- (id) initWithAddress:(NSString *)a val:(id)v;
|
||||||
|
|
||||||
|
- (NSString *) address;
|
||||||
|
- (id) val;
|
||||||
|
|
||||||
|
@end
|
|
@ -0,0 +1,34 @@
|
||||||
|
//
|
||||||
|
// OSCBundle.h
|
||||||
|
// OSC
|
||||||
|
//
|
||||||
|
// Created by bagheera on 9/20/08.
|
||||||
|
// Copyright 2008 __MyCompanyName__. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
#if IPHONE
|
||||||
|
#import <UIKit/UIKit.h>
|
||||||
|
#else
|
||||||
|
#import <Cocoa/Cocoa.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#import "OSCMessage.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@interface OSCBundle : NSObject {
|
||||||
|
NSMutableArray *elementArray; // array of messages or bundles
|
||||||
|
}
|
||||||
|
|
||||||
|
+ (void) parseRawBuffer:(unsigned char *)b ofMaxLength:(int)l toInPort:(id)p;
|
||||||
|
|
||||||
|
+ (id) create;
|
||||||
|
|
||||||
|
- (void) addElement:(id)n;
|
||||||
|
- (void) addElementArray:(NSArray *)a;
|
||||||
|
|
||||||
|
- (int) bufferLength;
|
||||||
|
- (void) writeToBuffer:(unsigned char *)b;
|
||||||
|
|
||||||
|
@end
|
|
@ -0,0 +1,93 @@
|
||||||
|
//
|
||||||
|
// OSCInPort.h
|
||||||
|
// OSC
|
||||||
|
//
|
||||||
|
// Created by bagheera on 9/20/08.
|
||||||
|
// Copyright 2008 __MyCompanyName__. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
#if IPHONE
|
||||||
|
#import <UIKit/UIKit.h>
|
||||||
|
#else
|
||||||
|
#import <Cocoa/Cocoa.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
//#import <sys/types.h>
|
||||||
|
//#import <sys/socket.h>
|
||||||
|
#import <netinet/in.h>
|
||||||
|
|
||||||
|
#import <pthread.h>
|
||||||
|
#import "AddressValPair.h"
|
||||||
|
#import "OSCPacket.h"
|
||||||
|
#import "OSCBundle.h"
|
||||||
|
#import "OSCMessage.h"
|
||||||
|
|
||||||
|
|
||||||
|
@protocol OSCInPortDelegateProtocol
|
||||||
|
- (void) oscMessageReceived:(NSDictionary *)d;
|
||||||
|
- (void) receivedOSCVal:(id)v forAddress:(NSString *)a;
|
||||||
|
@end
|
||||||
|
|
||||||
|
@protocol OSCDelegateProtocol
|
||||||
|
- (void) oscMessageReceived:(NSDictionary *)d;
|
||||||
|
- (void) receivedOSCVal:(id)v forAddress:(NSString *)a;
|
||||||
|
@end
|
||||||
|
|
||||||
|
|
||||||
|
@interface OSCInPort : NSObject {
|
||||||
|
BOOL deleted; // whether or not i'm deleted- ensures that socket gets closed
|
||||||
|
BOOL bound; // whether or not the socket is bound
|
||||||
|
int sock; // socket file descriptor. remember, everything in unix is files!
|
||||||
|
struct sockaddr_in addr; // struct that describes *my* address (this is an in port)
|
||||||
|
unsigned short port; // the port number i'm receiving from
|
||||||
|
BOOL running; // whether or not i should keep running
|
||||||
|
BOOL busy;
|
||||||
|
unsigned char buf[8192]; // the socket gets data and dumps it here immediately
|
||||||
|
|
||||||
|
pthread_mutex_t lock;
|
||||||
|
NSTimer *threadTimer;
|
||||||
|
int threadTimerCount;
|
||||||
|
NSAutoreleasePool *threadPool;
|
||||||
|
|
||||||
|
NSString *portLabel; // the "name" of the port (added to distinguish multiple osc input ports for bonjour)
|
||||||
|
NSNetService *zeroConfDest; // bonjour service for publishing this input's address...only active if there's a portLabel!
|
||||||
|
|
||||||
|
NSMutableDictionary *scratchDict; // key of dict is address port; object at key is a mut. array. coalesced messaging.
|
||||||
|
NSMutableArray *scratchArray; // array of AddressValPair objects. used for serial messaging.
|
||||||
|
id delegate; // my delegate gets notified of incoming messages
|
||||||
|
}
|
||||||
|
|
||||||
|
+ (id) createWithPort:(unsigned short)p;
|
||||||
|
+ (id) createWithPort:(unsigned short)p labelled:(NSString *)n;
|
||||||
|
- (id) initWithPort:(unsigned short)p;
|
||||||
|
- (id) initWithPort:(unsigned short)p labelled:(NSString *)n;
|
||||||
|
|
||||||
|
- (void) prepareToBeDeleted;
|
||||||
|
|
||||||
|
- (NSDictionary *) createSnapshot;
|
||||||
|
|
||||||
|
- (BOOL) createSocket;
|
||||||
|
- (void) start;
|
||||||
|
- (void) stop;
|
||||||
|
- (void) launchOSCLoop:(id)o;
|
||||||
|
- (void) OSCThreadProc:(NSTimer *)t;
|
||||||
|
- (void) parseRawBuffer:(unsigned char *)b ofMaxLength:(int)l;
|
||||||
|
|
||||||
|
// if the delegate im
|
||||||
|
- (void) handleParsedScratchDict:(NSDictionary *)d;
|
||||||
|
- (void) handleScratchArray:(NSArray *)a;
|
||||||
|
|
||||||
|
- (void) addValue:(id)val toAddressPath:(NSString *)p;
|
||||||
|
|
||||||
|
- (unsigned short) port;
|
||||||
|
- (void) setPort:(unsigned short)n;
|
||||||
|
- (NSString *) portLabel;
|
||||||
|
- (void) setPortLabel:(NSString *)n;
|
||||||
|
- (NSNetService *) zeroConfDest;
|
||||||
|
- (BOOL) bound;
|
||||||
|
|
||||||
|
- (id) delegate;
|
||||||
|
- (void) setDelegate:(id)n;
|
||||||
|
|
||||||
|
@end
|
|
@ -0,0 +1,144 @@
|
||||||
|
//
|
||||||
|
// OSCManager.h
|
||||||
|
// OSC
|
||||||
|
//
|
||||||
|
// Created by bagheera on 9/20/08.
|
||||||
|
// Copyright 2008 __MyCompanyName__. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
#if IPHONE
|
||||||
|
#import <UIKit/UIKit.h>
|
||||||
|
#else
|
||||||
|
#import <Cocoa/Cocoa.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#import "OSCZeroConfManager.h"
|
||||||
|
#import "OSCInPort.h"
|
||||||
|
#import "OSCOutPort.h"
|
||||||
|
#import <pthread.h>
|
||||||
|
|
||||||
|
/*
|
||||||
|
TOP-LEVEL OVERVIEW
|
||||||
|
|
||||||
|
this osc manager class is all you need to add to your app. it has methods for
|
||||||
|
adding and removing ports. you can have as many osc managers as you like, but
|
||||||
|
you should really only need one instance.
|
||||||
|
|
||||||
|
input ports have a delegate- delegate methods are called as the port receives data.
|
||||||
|
it's important to note that the delegate methods must be thread-safe: each input
|
||||||
|
port is running on its own (non-main) thread.
|
||||||
|
|
||||||
|
data is sent via the output ports (convenience methods for doing this are built
|
||||||
|
into the osc manager).
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
GENERAL OSC STRUCTURE AND OVERVIEW
|
||||||
|
|
||||||
|
this framework was written from the OSC spec found here:
|
||||||
|
http://opensoundcontrol.org/spec-1_0
|
||||||
|
|
||||||
|
- an OSC packet is the basic unit of transmitting OSC data.
|
||||||
|
- an OSC packet consists of:
|
||||||
|
- contents- contiguous block of binary data (either a bundle or a message), and then the
|
||||||
|
- size- number of 8-bit bytes that comprise 'contents'- ALWAYS multiple of 4!
|
||||||
|
- an OSC message consists of:
|
||||||
|
- an OSC address pattern (starting with '/'), followed by
|
||||||
|
- an OSC type tag string, followed by
|
||||||
|
- zero or more 'OSC arguments'
|
||||||
|
- an OSC bundle consists of:
|
||||||
|
- the OSC-string "#bundle", followed by
|
||||||
|
- an OSC time tag, followed by
|
||||||
|
- zero or more 'OSC bundle elements'
|
||||||
|
- an OSC bundle element consists of:
|
||||||
|
- 'size' (int32)- number of 8-bit bytes in the contents- ALWAYS multiple of 4!
|
||||||
|
- 'contents'- either another OSC bundle, or an OSC message
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
PORTS- SENDING AND RECEIVING UDP/TCP DATA
|
||||||
|
|
||||||
|
some basic information, gleaned from:
|
||||||
|
http://beej.us/guide/bgnet/output/html/multipage/index.html
|
||||||
|
|
||||||
|
struct sockaddr {
|
||||||
|
unsigned short sa_family; // address family, AF_xxx
|
||||||
|
char sa_data[14]; // 14 bytes of protocol address
|
||||||
|
}
|
||||||
|
struct sockaddr_in {
|
||||||
|
short int sin_family; // address family
|
||||||
|
unsigned short int sin_port; // port number
|
||||||
|
struct in_addr sin_addr; // internet address
|
||||||
|
unsigned char sin_zero[8]; // exists so sockaddr_in has same length as sockaddr
|
||||||
|
}
|
||||||
|
|
||||||
|
recv(int sockfd, void *buf, int len, unsigned int flags);
|
||||||
|
- sockfd is the socket descriptor to read from
|
||||||
|
- buf is the buffer to read the information into
|
||||||
|
- len is the max length of the buffer
|
||||||
|
- flags can be set to 0
|
||||||
|
recvfrom(int sockfd, void *buf, int len, unsigned int flags, struct sockaddr *from, int *fromlen);
|
||||||
|
- from is a pointer to a local struct sockaddr that will be filled with the IP & port of the originating machine
|
||||||
|
- fromlen is a pointer to a local int that should be initialized to a sizeof(struct sockaddr)- contains length of address actually stored in from on return
|
||||||
|
...as well as the 4 params listed above in recv()
|
||||||
|
|
||||||
|
int select(int numfds, fd_set *readrds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout);
|
||||||
|
*/
|
||||||
|
|
||||||
|
@interface OSCManager : NSObject {
|
||||||
|
NSMutableArray *inPortArray;
|
||||||
|
NSMutableArray *outPortArray;
|
||||||
|
|
||||||
|
pthread_rwlock_t inPortLock;
|
||||||
|
pthread_rwlock_t outPortLock;
|
||||||
|
|
||||||
|
id delegate;
|
||||||
|
|
||||||
|
OSCZeroConfManager *zeroConfManager; // bonjour/zero-configuration manager
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) deleteAllInputs;
|
||||||
|
- (void) deleteAllOutputs;
|
||||||
|
// methods for creating input ports
|
||||||
|
- (OSCInPort *) createNewInputFromSnapshot:(NSDictionary *)s;
|
||||||
|
- (OSCInPort *) createNewInputForPort:(int)p withLabel:(NSString *)l;
|
||||||
|
- (OSCInPort *) createNewInputForPort:(int)p;
|
||||||
|
- (OSCInPort *) createNewInput;
|
||||||
|
// methods for creating output ports
|
||||||
|
- (OSCOutPort *) createNewOutputFromSnapshot:(NSDictionary *)s;
|
||||||
|
- (OSCOutPort *) createNewOutputToAddress:(NSString *)a atPort:(int)p withLabel:(NSString *)l;
|
||||||
|
- (OSCOutPort *) createNewOutputToAddress:(NSString *)a atPort:(int)p;
|
||||||
|
- (OSCOutPort *) createNewOutput;
|
||||||
|
|
||||||
|
// typically, the manager is the input port's delegate- input ports tell delegates when they receive data
|
||||||
|
// this method is called and contains coalesced messages (grouped by address path)
|
||||||
|
- (void) oscMessageReceived:(NSDictionary *)d;
|
||||||
|
// this method is called every time any osc val is processed
|
||||||
|
- (void) receivedOSCVal:(id)v forAddress:(NSString *)a;
|
||||||
|
|
||||||
|
// methods for working with ports
|
||||||
|
- (NSString *) getUniqueInputLabel;
|
||||||
|
- (NSString *) getUniqueOutputLabel;
|
||||||
|
- (OSCInPort *) findInputWithLabel:(NSString *)n;
|
||||||
|
- (OSCOutPort *) findOutputWithLabel:(NSString *)n;
|
||||||
|
- (OSCOutPort *) findOutputWithAddress:(NSString *)a andPort:(int)p;
|
||||||
|
- (OSCOutPort *) findOutputForIndex:(int)i;
|
||||||
|
- (OSCInPort *) findInputWithZeroConfName:(NSString *)n;
|
||||||
|
- (void) removeInput:(id)p;
|
||||||
|
- (void) removeOutput:(id)p;
|
||||||
|
- (NSArray *) outPortLabelArray;
|
||||||
|
|
||||||
|
// subclassable methods for customizing
|
||||||
|
- (id) inPortClass;
|
||||||
|
- (NSString *) inPortLabelBase;
|
||||||
|
- (id) outPortClass;
|
||||||
|
|
||||||
|
// misc
|
||||||
|
- (id) delegate;
|
||||||
|
- (void) setDelegate:(id)n;
|
||||||
|
- (NSMutableArray *) inPortArray;
|
||||||
|
- (NSMutableArray *) outPortArray;
|
||||||
|
|
||||||
|
@end
|
|
@ -0,0 +1,43 @@
|
||||||
|
//
|
||||||
|
// OSCMessage.h
|
||||||
|
// OSC
|
||||||
|
//
|
||||||
|
// Created by bagheera on 9/20/08.
|
||||||
|
// Copyright 2008 __MyCompanyName__. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
#if IPHONE
|
||||||
|
#import <UIKit/UIKit.h>
|
||||||
|
#else
|
||||||
|
#import <Cocoa/Cocoa.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#import <pthread.h>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@interface OSCMessage : NSObject {
|
||||||
|
NSString *address;
|
||||||
|
NSMutableArray *typeArray;
|
||||||
|
NSMutableArray *argArray;
|
||||||
|
pthread_rwlock_t lock;
|
||||||
|
}
|
||||||
|
|
||||||
|
+ (void) parseRawBuffer:(unsigned char *)b ofMaxLength:(int)l toInPort:(id)p;
|
||||||
|
+ (id) createMessageToAddress:(NSString *)a;
|
||||||
|
- (id) initWithAddress:(NSString *)a;
|
||||||
|
|
||||||
|
- (void) addInt:(int)n;
|
||||||
|
- (void) addFloat:(float)n;
|
||||||
|
#if IPHONE
|
||||||
|
- (void) addColor:(UIColor *)c;
|
||||||
|
#else
|
||||||
|
- (void) addColor:(NSColor *)c;
|
||||||
|
#endif
|
||||||
|
- (void) addBOOL:(BOOL)n;
|
||||||
|
- (void) addString:(NSString *)n;
|
||||||
|
|
||||||
|
- (int) bufferLength;
|
||||||
|
- (void) writeToBuffer:(unsigned char *)b;
|
||||||
|
|
||||||
|
@end
|
|
@ -0,0 +1,58 @@
|
||||||
|
//
|
||||||
|
// OSCOutPort.h
|
||||||
|
// OSC
|
||||||
|
//
|
||||||
|
// Created by bagheera on 9/20/08.
|
||||||
|
// Copyright 2008 __MyCompanyName__. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
#if IPHONE
|
||||||
|
#import <UIKit/UIKit.h>
|
||||||
|
#else
|
||||||
|
#import <Cocoa/Cocoa.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#include <arpa/inet.h>
|
||||||
|
|
||||||
|
#import "OSCPacket.h"
|
||||||
|
#import "OSCBundle.h"
|
||||||
|
#import "OSCMessage.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@interface OSCOutPort : NSObject {
|
||||||
|
BOOL deleted;
|
||||||
|
int sock;
|
||||||
|
struct sockaddr_in addr;
|
||||||
|
unsigned short port;
|
||||||
|
NSString *addressString;
|
||||||
|
NSString *portLabel; // used it to distinguish between multiple osc outputs
|
||||||
|
}
|
||||||
|
|
||||||
|
+ (id) createWithAddress:(NSString *)a andPort:(unsigned short)p;
|
||||||
|
+ (id) createWithAddress:(NSString *)a andPort:(unsigned short)p labelled:(NSString *)l;
|
||||||
|
- (id) initWithAddress:(NSString *)a andPort:(unsigned short)p;
|
||||||
|
- (id) initWithAddress:(NSString *)a andPort:(unsigned short)p labelled:(NSString *)l;
|
||||||
|
- (void) prepareToBeDeleted;
|
||||||
|
|
||||||
|
- (NSDictionary *) createSnapshot;
|
||||||
|
|
||||||
|
- (BOOL) createSocket;
|
||||||
|
|
||||||
|
- (void) sendThisBundle:(OSCBundle *)b;
|
||||||
|
- (void) sendThisMessage:(OSCMessage *)m;
|
||||||
|
- (void) sendThisPacket:(OSCPacket *)p;
|
||||||
|
|
||||||
|
- (void) setAddressString:(NSString *)n;
|
||||||
|
- (void) setPort:(unsigned short)p;
|
||||||
|
- (void) setAddressString:(NSString *)n andPort:(unsigned short)p;
|
||||||
|
|
||||||
|
- (NSString *) portLabel;
|
||||||
|
- (void) setPortLabel:(NSString *)n;
|
||||||
|
|
||||||
|
- (unsigned short) port;
|
||||||
|
- (NSString *) addressString;
|
||||||
|
|
||||||
|
@end
|
|
@ -0,0 +1,37 @@
|
||||||
|
//
|
||||||
|
// OSCPacket.h
|
||||||
|
// OSC
|
||||||
|
//
|
||||||
|
// Created by bagheera on 9/20/08.
|
||||||
|
// Copyright 2008 __MyCompanyName__. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
#if IPHONE
|
||||||
|
#import <UIKit/UIKit.h>
|
||||||
|
#else
|
||||||
|
#import <Cocoa/Cocoa.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#import "OSCBundle.h"
|
||||||
|
#import "OSCMessage.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
this class requires a bundle or message on create/init. the buffer/msg
|
||||||
|
is NOT retained by this class in any way- it's used to immediately create
|
||||||
|
the buffer which will be sent.
|
||||||
|
*/
|
||||||
|
|
||||||
|
@interface OSCPacket : NSObject {
|
||||||
|
int bufferLength;
|
||||||
|
unsigned char *payload;
|
||||||
|
}
|
||||||
|
|
||||||
|
+ (void) parseRawBuffer:(unsigned char *)b ofMaxLength:(int)l toInPort:(id)p;
|
||||||
|
+ (id) createWithContent:(id)c;
|
||||||
|
- (id) initWithContent:(id)c;
|
||||||
|
|
||||||
|
- (int) bufferLength;
|
||||||
|
- (unsigned char *) payload;
|
||||||
|
|
||||||
|
@end
|
|
@ -0,0 +1,44 @@
|
||||||
|
//
|
||||||
|
// OSCZeroConfDomain.h
|
||||||
|
// VVOSC
|
||||||
|
//
|
||||||
|
// Created by bagheera on 12/9/08.
|
||||||
|
// Copyright 2008 __MyCompanyName__. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
#if IPHONE
|
||||||
|
#import <UIKit/UIKit.h>
|
||||||
|
#else
|
||||||
|
#import <Cocoa/Cocoa.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#import <pthread.h>
|
||||||
|
#import <sys/socket.h>
|
||||||
|
#include <arpa/inet.h>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@interface OSCZeroConfDomain : NSObject {
|
||||||
|
NSString *domainString;
|
||||||
|
NSNetServiceBrowser *serviceBrowser;
|
||||||
|
|
||||||
|
NSMutableArray *servicesArray;
|
||||||
|
pthread_rwlock_t servicesLock;
|
||||||
|
|
||||||
|
id domainManager;
|
||||||
|
}
|
||||||
|
|
||||||
|
+ (id) createWithDomain:(NSString *)d andDomainManager:(id)m;
|
||||||
|
- (id) initWithDomain:(NSString *)d andDomainManager:(id)m;
|
||||||
|
|
||||||
|
// NSNetServiceBrowser delegate methods
|
||||||
|
- (void)netServiceBrowser:(NSNetServiceBrowser *)n didFindService:(NSNetService *)x moreComing:(BOOL)m;
|
||||||
|
- (void)netServiceBrowser:(NSNetServiceBrowser *)n didNotSearch:(NSDictionary *)err;
|
||||||
|
- (void)netServiceBrowser:(NSNetServiceBrowser *)n didRemoveService:(NSNetService *)s moreComing:(BOOL)m;
|
||||||
|
|
||||||
|
// NSNetService delegate methods
|
||||||
|
- (void)netService:(NSNetService *)n didNotResolve:(NSDictionary *)err;
|
||||||
|
- (void)netServiceDidResolveAddress:(NSNetService *)n;
|
||||||
|
|
||||||
|
@end
|
|
@ -0,0 +1,39 @@
|
||||||
|
//
|
||||||
|
// OSCZeroConfManager.h
|
||||||
|
// VVOSC
|
||||||
|
//
|
||||||
|
// Created by bagheera on 12/9/08.
|
||||||
|
// Copyright 2008 __MyCompanyName__. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
#if IPHONE
|
||||||
|
#import <UIKit/UIKit.h>
|
||||||
|
#else
|
||||||
|
#import <Cocoa/Cocoa.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#import "OSCZeroConfDomain.h"
|
||||||
|
#import <pthread.h>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@interface OSCZeroConfManager : NSObject {
|
||||||
|
NSNetServiceBrowser *domainBrowser;
|
||||||
|
|
||||||
|
NSMutableDictionary *domainDict;
|
||||||
|
pthread_rwlock_t domainLock;
|
||||||
|
|
||||||
|
id oscManager;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (id) initWithOSCManager:(id)m;
|
||||||
|
|
||||||
|
- (void) serviceRemoved:(NSNetService *)s;
|
||||||
|
- (void) serviceResolved:(NSNetService *)s;
|
||||||
|
|
||||||
|
// NSNetServiceBrowser delegate methods
|
||||||
|
- (void)netServiceBrowser:(NSNetServiceBrowser *)n didFindDomain:(NSString *)d moreComing:(BOOL)m;
|
||||||
|
- (void)netServiceBrowser:(NSNetServiceBrowser *)n didNotSearch:(NSDictionary *)err;
|
||||||
|
|
||||||
|
@end
|
|
@ -0,0 +1,9 @@
|
||||||
|
|
||||||
|
|
||||||
|
#import "AddressValPair.h"
|
||||||
|
#import "OSCManager.h"
|
||||||
|
#import "OSCZeroConfManager.h"
|
||||||
|
#import "OSCPacket.h"
|
||||||
|
#import "OSCBundle.h"
|
||||||
|
#import "OSCMessage.h"
|
||||||
|
|
Binary file not shown.
|
@ -0,0 +1,24 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
|
<plist version="1.0">
|
||||||
|
<dict>
|
||||||
|
<key>CFBundleDevelopmentRegion</key>
|
||||||
|
<string>English</string>
|
||||||
|
<key>CFBundleExecutable</key>
|
||||||
|
<string>VVOSC</string>
|
||||||
|
<key>CFBundleGetInfoString</key>
|
||||||
|
<string>0.1.2</string>
|
||||||
|
<key>CFBundleIdentifier</key>
|
||||||
|
<string>com.vidvox.VVOSC</string>
|
||||||
|
<key>CFBundleInfoDictionaryVersion</key>
|
||||||
|
<string>6.0</string>
|
||||||
|
<key>CFBundleName</key>
|
||||||
|
<string>VVOSC</string>
|
||||||
|
<key>CFBundlePackageType</key>
|
||||||
|
<string>FMWK</string>
|
||||||
|
<key>CFBundleSignature</key>
|
||||||
|
<string>????</string>
|
||||||
|
<key>CFBundleVersion</key>
|
||||||
|
<string>0.1.2</string>
|
||||||
|
</dict>
|
||||||
|
</plist>
|
Binary file not shown.
Loading…
Reference in New Issue