cocoa osc app
i just wrote a cocoa frontend for my ruby osc sequencer using vvosc.
this is a simple tutorial to show how i got my vvosc app running. i'm neither a xcode nor objective-c expert - so be gentle if there are some mistakes, or there is a simpler more xcody way to do it :-)
get vvosc from http://github.com/mrRay/vvosc/tree/master (use download as zip if you have no git installed)
open xcode and build the project.
go to the "File" menu in XCode, click on "New" and choose "Cocoa Application" name it whatever you like
drag the VVOSC.framework from the vvosc-project "Products"-Folder to the "Frameworks/Linked Framworks folder" of your new project
then go to the "Targets" folder control-click your application name and select "Add > New Build Phase > New Copy Files Build Phase"
control-click the build phase you just added and change the "Destination" select box to "Frameworks". now drag the VVOSC.framework to the new build phase.
control-click the "Classes"-Folder and select "Add > New File ...". choose "Objective-C class" and name it "Controller"
change your controller.h to look like this
#import <Cocoa/Cocoa.h>
#import <VVOSC/VVOSC.h>
@interface Controller : NSObject {
OSCManager *manager;
OSCOutPort *outport;
IBOutlet id play1;
IBOutlet id play2;
IBOutlet id play3;
IBOutlet id pause1;
IBOutlet id pause2;
IBOutlet id pause3;
IBOutlet id stop1;
IBOutlet id stop2;
IBOutlet id stop3;
}
-(IBAction) click:(id)sender;
@end
now go to the "Resources"-Folder and double click the "MainMenu.xib"
in the interface builder select the app window and drag 9 buttons from the palette to it (and some labels if you like).
now select an object from the library and drag it to the MainMenu.xib window. open the inspector (apple-shift-I) and change the class to "controller".
control-click the new blue cube and drag the small circle on the right side to the buttons you added to the main window
then drag the small circle right of the click method to every button.
go back to xcode and change your controller.m to look like this
#import "Controller.h"
@implementation Controller
-(id)init {
if (self = [super init]) {
manager = [[OSCManager alloc] init];
}
return self;
}
- (void) awakeFromNib {
outport = [manager createNewOutputToAddress:@"127.0.0.1" atPort:3333 withLabel:@"test app"];
}
-(IBAction) click:(id)sender {
NSLog(@"click");
OSCMessage *msg = nil;
OSCPacket *packet = nil;
if ( sender == play1 ) {
msg = [OSCMessage createWithAddress:@"/seq/bass"];
[msg addString:@"play"];
} else if ( sender == play2 ) {
msg = [OSCMessage createWithAddress:@"/seq/mel"];
[msg addString:@"play"];
} else if ( sender == play3 ){
msg = [OSCMessage createWithAddress:@"/seq/drum"];
[msg addString:@"play"];
} else if ( sender == pause1 ) {
msg = [OSCMessage createWithAddress:@"/seq/bass"];
[msg addString:@"pause"];
} else if ( sender == pause2 ) {
msg = [OSCMessage createWithAddress:@"/seq/mel"];
[msg addString:@"pause"];
} else if ( sender == pause3 ){
msg = [OSCMessage createWithAddress:@"/seq/drum"];
[msg addString:@"pause"];
} else if ( sender == stop1 ) {
msg = [OSCMessage createWithAddress:@"/seq/bass"];
[msg addString:@"stop"];
} else if ( sender == stop2 ) {
msg = [OSCMessage createWithAddress:@"/seq/mel"];
[msg addString:@"stop"];
} else if ( sender == stop3 ){
msg = [OSCMessage createWithAddress:@"/seq/drum"];
[msg addString:@"stop"];
}
packet = [OSCPacket createWithContent:msg];
[outport sendThisPacket: packet];
}
@end
hit the "Build and Go" button and you should have a running OSC app, that sends an osc event to port 3333 every time you click a button
See also:
Android Monome-Clone in Processing
Mapping linux input events to OSC
ruby osc seqencer version2
osc linkdump