Monthly Archive for July, 2008

BBOSC/Cocoa on the iPhone

Just had a nice chat with Pawel of NUIGroup fame. and we did a bit of work and made a few minor changes to the BBOSC codebase so that it now compiles nicely on the iPhone.

Basically, since there are no calls to the AppKit, all that was required was to change all the #import Cocoa stuff to #import Foundation instead.

I also took out one NSAlert that gets called if the BBOSCListener thread dies for some reason, and temporarily replaced it with a simple NSLog. I will go back in later and make it more platform aware, but for now, all you get is a log entry.

as before the code can be found here:
http://code.google.com/p/bbosc/

Happy Coding!

OSC now with more Cocoa

Hello all,

So, I am in the midst of adding TUIO event generation to the BBTouch code base. For anyone who doesnt know, TUIO is a subset of OSC (open sound control) commands, and is sent using the OSC standard.

Sooo... to this effect, i started researching all the various OSC libs out there, and there are a few, and they are all pretty good. However, in the spirit of this project (ie an all-cocoa multi-touch thing), and in an effort to learn more about the OSC protocol, i decided to start over from scratch.

That was a few days ago, and here is a new OSC implementation in not-so-pure cocoa/objc. There is a bunch of POSIX and C stuff in there to deal with the sockets and the bit-level manipulation of the data. but that is all abstracted away into some nice objects.

here is some sample code for making an OSC listener: (aka a server)

BBOSCListener* anOSCListener = [BBOSCListener defaultListenerOnPort:4556];

that's it. the listener will use the default dispatch delegate to handle the messages coming in, and there you go. (note: be sure to retain your listener if you use the 'easy' method above)

and to send messages? like so:


BBOSCSender* anOSCSender =
[BBOSCSender senderWithDestinationHostName:@"localhost" portNumber:4556];

if (![anOSCSender sendOSCPacket:newMessage]) {
NSLog(@"Oh Noes!!");
}

that's it.

generating messages and bundles is also simple:


BBOSCMessage * newMessage =
[BBOSCMessage messageWithBBOSCAddress:
[BBOSCAddress addressWithString:@"/test/1/groovy"]];

[newMessage attachArgument:
[BBOSCArgument argumentWithString:@"Testing!!"]];
[newMessage attachArgument:
[BBOSCArgument argumentWithInt:12]];

and bundles are similar.

Anyhooo.. the code is available here:
http://code.google.com/p/bbosc/

It is all commented nicely so you should be able to re-use it pretty easily.

A few notes: First, it should probably be a framework, but for now it is just a collection of files. Also, I havent gotten around to building a nice message dispatch system. so for now, if you want to use the code to build a server, you will have to implement your own dispatch. I built it originally to be the client code for BBTouch TUIO events, but it seemed silly not to build the listener stuff as well, so i built that in. (sans dispatch). I am going to add the sending stuff to bbtouch, then i will come back and add a nice dispatch module into BBOSC.

busy busy busy!

I just wanted to jump on real quick and apologize for there being no real code updates for a month now. I have been snowed under with 'real' work and unfortunately the paying clients take precedence, even if the BBtouch code would be so much more fun!

Anyway, the good news is that, although i havent finished anything, i have made some progress on a TUIO/OSC event delegate. It is stubbed out and i think i have found a good set of code for the OSC client stuff. it will probably take a half dozen hours or so to get it all into the project and working, and as soon as i can scrape that time together it will be done and i will let you all know :-)

thanks to commenter: Sandor for keeping on me. I will have a look at your IB stuff when i can get a chance!

thanks all!
-b