Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
slight update to the VVMIDI framework :: added a new target- MIDI via…
… OSC sends MIDI data over a network as OSC, and vice versa
- Loading branch information
raycutler
committed
Sep 24, 2009
1 parent
ffc22c8
commit 10a7515
Showing
17 changed files
with
5,525 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?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>${EXECUTABLE_NAME}</string> | ||
<key>CFBundleIdentifier</key> | ||
<string>com.vvopensource.${PRODUCT_NAME:identifier}</string> | ||
<key>CFBundleInfoDictionaryVersion</key> | ||
<string>6.0</string> | ||
<key>CFBundlePackageType</key> | ||
<string>APPL</string> | ||
<key>CFBundleSignature</key> | ||
<string>????</string> | ||
<key>CFBundleVersion</key> | ||
<string>0.1.0</string> | ||
<key>CFBundleGetInfoString</key> | ||
<string>0.1.0</string> | ||
<key>NSMainNibFile</key> | ||
<string>MainMenu</string> | ||
<key>NSPrincipalClass</key> | ||
<string>NSApplication</string> | ||
</dict> | ||
</plist> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#import <Cocoa/Cocoa.h> | ||
#import <VVMIDI/VVMIDI.h> | ||
|
||
|
||
|
||
|
||
@interface MVOMIDIManager : VVMIDIManager { | ||
MutLockArray *receivedOSCStringArray; | ||
IBOutlet NSTextField *receivedOSCField; | ||
|
||
IBOutlet NSTableView *sourcesTableView; | ||
IBOutlet NSTableColumn *sourcesNameColumn; | ||
IBOutlet NSTableColumn *sourcesEnableColumn; | ||
|
||
IBOutlet NSTableView *receiversTableView; | ||
IBOutlet NSTableColumn *receiversNameColumn; | ||
IBOutlet NSTableColumn *receiversEnableColumn; | ||
|
||
NSMutableDictionary *sourceEnableStateDict; | ||
NSMutableDictionary *destEnableStateDict; | ||
} | ||
|
||
- (void) appWillTerminateNotification:(NSNotification *)note; | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,247 @@ | ||
#import "MVOMIDIManager.h" | ||
#import <VVOSC/VVOSC.h> | ||
|
||
|
||
|
||
|
||
@implementation MVOMIDIManager | ||
|
||
|
||
- (void) generalInit { | ||
//NSLog(@"%s",__func__); | ||
receivedOSCStringArray = [[MutLockArray alloc] init]; | ||
NSUserDefaults *def = [NSUserDefaults standardUserDefaults]; | ||
NSDictionary *tmpDict = [def objectForKey:@"snap"]; | ||
//NSLog(@"\tsnap is %@",tmpDict); | ||
if (tmpDict != nil) { | ||
sourceEnableStateDict = [tmpDict objectForKey:@"src"]; | ||
destEnableStateDict = [tmpDict objectForKey:@"dst"]; | ||
} | ||
|
||
if (sourceEnableStateDict != nil) | ||
[sourceEnableStateDict retain]; | ||
else | ||
sourceEnableStateDict = [[NSMutableDictionary dictionaryWithCapacity:0] retain]; | ||
|
||
if (destEnableStateDict != nil) | ||
[destEnableStateDict retain]; | ||
else | ||
destEnableStateDict = [[NSMutableDictionary dictionaryWithCapacity:0] retain]; | ||
|
||
//NSLog(@"\tsourceEnableStateDict = %@",sourceEnableStateDict); | ||
//NSLog(@"\tdestEnableStateDict = %@",destEnableStateDict); | ||
|
||
[[NSNotificationCenter defaultCenter] | ||
addObserver:self | ||
selector:@selector(appWillTerminateNotification:) | ||
name:NSApplicationWillTerminateNotification | ||
object:nil]; | ||
|
||
receivedOSCStringArray = [[MutLockArray alloc] init]; | ||
|
||
[super generalInit]; | ||
} | ||
- (void) awakeFromNib { | ||
[sourcesTableView reloadData]; | ||
[receiversTableView reloadData]; | ||
} | ||
- (void) appWillTerminateNotification:(NSNotification *)note { | ||
//NSLog(@"%s",__func__); | ||
//NSLog(@"\tsourceEnableStateDict = %@",sourceEnableStateDict); | ||
//NSLog(@"\tdestEnableStateDict = %@",destEnableStateDict); | ||
NSUserDefaults *def = [NSUserDefaults standardUserDefaults]; | ||
//[def setObject:sourceEnableStateDict forKey:@"sourceEnableStateDict"]; | ||
//[def setObject:destEnableStateDict forKey:@"destEnableStateDict"]; | ||
NSMutableDictionary *tmpDict = [NSMutableDictionary dictionaryWithCapacity:0]; | ||
[tmpDict setObject:sourceEnableStateDict forKey:@"src"]; | ||
[tmpDict setObject:destEnableStateDict forKey:@"dst"]; | ||
[def setObject:tmpDict forKey:@"snap"]; | ||
[def synchronize]; | ||
} | ||
- (NSString *) receivingNodeName { | ||
return [NSString stringWithString:@"To 'MIDI via OSC'"]; | ||
} | ||
- (NSString *) sendingNodeName { | ||
return [NSString stringWithString:@"From 'MIDI via OSC'"]; | ||
} | ||
- (void) receivedOSCMessage:(OSCMessage *)m { | ||
//NSLog(@"%s",__func__); | ||
|
||
if (m == nil) | ||
return; | ||
OSCValue *val = [m value]; | ||
if (val == nil) | ||
return; | ||
if ([val type] != OSCValMIDI) | ||
return; | ||
VVMIDIMessage *msg = nil; | ||
msg = [VVMIDIMessage createFromVals:[val midiStatus]:[val midiPort]:[val midiData1]:[val midiData2]]; | ||
if (msg != nil) | ||
[self sendMsg:msg]; | ||
// if the received message wasn't a clock pulse... | ||
if ([msg type] != VVMIDIClockVal) { | ||
// put together the string for the UI... | ||
NSMutableString *tmpString = [NSMutableString stringWithCapacity:0]; | ||
[receivedOSCStringArray wrlock]; | ||
[receivedOSCStringArray addObject:[msg lengthyDescription]]; | ||
while ([receivedOSCStringArray count]>20) | ||
[receivedOSCStringArray removeObjectAtIndex:0]; | ||
NSEnumerator *it = [[receivedOSCStringArray array] reverseObjectEnumerator]; | ||
for (NSString *midiString in it) | ||
[tmpString appendString:[NSString stringWithFormat:@"%@\n",midiString]]; | ||
[receivedOSCStringArray unlock]; | ||
[receivedOSCField setStringValue:tmpString]; | ||
} | ||
} | ||
|
||
- (void) loadMIDIInputSources { | ||
//NSLog(@"%s",__func__); | ||
// before i load anything, run through and save the enable state of the midi nodes in my dict | ||
if ((sourceArray!=nil)&&([sourceArray count]>0)) { | ||
//pthread_mutex_lock(&arrayLock); | ||
[sourceArray rdlock]; | ||
for (VVMIDINode *nodePtr in [sourceArray array]) | ||
[sourceEnableStateDict setValue:[NSNumber numberWithBool:[nodePtr enabled]] forKey:[nodePtr name]]; | ||
//pthread_mutex_unlock(&arrayLock); | ||
[sourceArray unlock]; | ||
} | ||
// tell the super to load the midi input sources (this actually does the loading) | ||
[super loadMIDIInputSources]; | ||
// now that i'm done loading, run through and either disable or restore the enable state of the nodes | ||
if ((sourceArray!=nil) && ([sourceArray count]>0)) { | ||
//pthread_mutex_lock(&arrayLock); | ||
[sourceArray rdlock]; | ||
NSNumber *tmpNum = nil; | ||
for (VVMIDINode *nodePtr in [sourceArray array]) { | ||
tmpNum = [sourceEnableStateDict valueForKey:[nodePtr name]]; | ||
if (tmpNum != nil) | ||
[nodePtr setEnabled:[tmpNum boolValue]]; | ||
else | ||
[nodePtr setEnabled:NO]; | ||
} | ||
//pthread_mutex_unlock(&arrayLock); | ||
[sourceArray unlock]; | ||
} | ||
} | ||
- (void) loadMIDIOutputDestinations { | ||
// before i load anything, run through and save the enable state of the midi nodes in my dict | ||
if ((destArray!=nil)&&([destArray count]>0)) { | ||
//pthread_mutex_lock(&arrayLock); | ||
[destArray rdlock]; | ||
for (VVMIDINode *nodePtr in [destArray array]) | ||
[destEnableStateDict setValue:[NSNumber numberWithBool:[nodePtr enabled]] forKey:[nodePtr name]]; | ||
//pthread_mutex_unlock(&arrayLock); | ||
[destArray unlock]; | ||
} | ||
// tell the super to load the midi input destinations (this actually does the loading) | ||
[super loadMIDIOutputDestinations]; | ||
// now that i'm done loading, run through and either disable or restore the enable state of the nodes | ||
if ((destArray!=nil) && ([destArray count]>0)) { | ||
//pthread_mutex_lock(&arrayLock); | ||
[destArray rdlock]; | ||
NSNumber *tmpNum = nil; | ||
for (VVMIDINode *nodePtr in [destArray array]) { | ||
tmpNum = [destEnableStateDict valueForKey:[nodePtr name]]; | ||
if (tmpNum != nil) | ||
[nodePtr setEnabled:[tmpNum boolValue]]; | ||
else | ||
[nodePtr setEnabled:NO]; | ||
} | ||
//pthread_mutex_unlock(&arrayLock); | ||
[destArray unlock]; | ||
} | ||
} | ||
|
||
- (NSInteger) numberOfRowsInTableView:(NSTableView *)tv { | ||
if (tv == sourcesTableView) | ||
return [sourceArray count]; | ||
else if (tv == receiversTableView) | ||
return [destArray count]; | ||
|
||
return 0; | ||
} | ||
- (id) tableView:(NSTableView *)tv objectValueForTableColumn:(NSTableColumn *)tc row:(NSInteger)row { | ||
if (tv == sourcesTableView) { | ||
//NSLog(@"\t\tsources"); | ||
id midiSource = [sourceArray lockObjectAtIndex:row]; | ||
|
||
if (midiSource == nil) | ||
return nil; | ||
|
||
if (tc == sourcesNameColumn) { | ||
return [midiSource name]; | ||
} | ||
else if (tc == sourcesEnableColumn) { | ||
if ([midiSource enabled]) | ||
return [NSNumber numberWithInt:NSOnState]; | ||
else | ||
return [NSNumber numberWithInt:NSOffState]; | ||
} | ||
} | ||
else if (tv == receiversTableView) { | ||
//NSLog(@"\t\treceivers"); | ||
id midiSource = [destArray lockObjectAtIndex:row]; | ||
|
||
if (midiSource == nil) | ||
return nil; | ||
|
||
if (tc == receiversNameColumn) { | ||
return [midiSource name]; | ||
} | ||
else if (tc == receiversEnableColumn) { | ||
if ([midiSource enabled]) | ||
return [NSNumber numberWithInt:NSOnState]; | ||
else | ||
return [NSNumber numberWithInt:NSOffState]; | ||
} | ||
} | ||
|
||
return nil; | ||
} | ||
- (void) tableView:(NSTableView *)tv setObjectValue:(id)v forTableColumn:(NSTableColumn *)tc row:(NSInteger)row { | ||
if (tv == sourcesTableView) { | ||
//NSLog(@"\t\tsources"); | ||
id midiSource = [sourceArray lockObjectAtIndex:row]; | ||
|
||
if (midiSource == nil) | ||
return; | ||
|
||
if (tc == sourcesEnableColumn) { | ||
if ([v intValue] == NSOnState) | ||
[midiSource setEnabled:YES]; | ||
else | ||
[midiSource setEnabled:NO]; | ||
} | ||
|
||
if ((sourceArray!=nil)&&([sourceArray count]>0)) { | ||
[sourceArray rdlock]; | ||
for (VVMIDINode *nodePtr in [sourceArray array]) | ||
[sourceEnableStateDict setValue:[NSNumber numberWithBool:[nodePtr enabled]] forKey:[nodePtr name]]; | ||
[sourceArray unlock]; | ||
} | ||
} | ||
else if (tv == receiversTableView) { | ||
//NSLog(@"\t\treceivers"); | ||
id midiSource = [destArray lockObjectAtIndex:row]; | ||
|
||
if (midiSource == nil) | ||
return; | ||
|
||
if (tc == receiversEnableColumn) { | ||
if ([v intValue] == NSOnState) | ||
[midiSource setEnabled:YES]; | ||
else | ||
[midiSource setEnabled:NO]; | ||
} | ||
|
||
if ((destArray!=nil)&&([destArray count]>0)) { | ||
[destArray rdlock]; | ||
for (VVMIDINode *nodePtr in [destArray array]) | ||
[destEnableStateDict setValue:[NSNumber numberWithBool:[nodePtr enabled]] forKey:[nodePtr name]]; | ||
[destArray unlock]; | ||
} | ||
} | ||
} | ||
|
||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#import <Cocoa/Cocoa.h> | ||
#import <VVOSC/VVOSC.h> | ||
|
||
|
||
|
||
|
||
// key for notification which is fired whenever a new output is created | ||
#define VVOSCOutPortsChangedNotification @"VVOSCOutPortsChangedNotification" | ||
|
||
|
||
|
||
|
||
@interface MVOOSCManager : OSCManager { | ||
MutLockArray *receivedMIDIStringArray; | ||
IBOutlet NSTextField *receivedMIDIField; | ||
|
||
MutLockArray *outgoingBuffer; | ||
VVThreadLoop *oscSendingThread; | ||
|
||
OSCInPort *inPort; | ||
OSCOutPort *outPort; | ||
|
||
IBOutlet NSTextField *ipField; | ||
IBOutlet NSTextField *portField; | ||
IBOutlet NSPopUpButton *outputDestinationButton; | ||
IBOutlet NSTextField *networkAddressField; | ||
|
||
IBOutlet NSTableView *midiSourcesTable; | ||
IBOutlet NSTableView *midiDestTable; | ||
} | ||
|
||
- (void) sendOSC; | ||
- (void) oscOutputsChangedNotification:(NSNotification *)note; | ||
- (IBAction) setupFieldUsed:(id)sender; | ||
- (IBAction) outputDestinationButtonUsed:(id)sender; | ||
- (NSArray *) ipAddressArray; | ||
|
||
@end |
Oops, something went wrong.