Skip to content

Commit

Permalink
update to version 2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
danielbuechele committed Oct 10, 2012
1 parent 9b872ea commit 4253597
Show file tree
Hide file tree
Showing 204 changed files with 15,584 additions and 108 deletions.
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
atemOSC
=======
atemOSC v2.0
============

This is a Mac OS X application, providing an interface to control an ATEM video switcher via OSC.
The code is based on the *SwitcherPanel*-Democode (Version 3.1) provided by Blackmagic.
The code is based on the *SwitcherPanel*-Democode (Version 3.1) provided by Blackmagic. Additionally the control of a tally-light interface via Arduino is provided.

![atemOSC](https://github.com/danielbuechele/atemOSC/raw/master/atemOSC.jpg)

- [VVOSC](http://code.google.com/p/vvopensource/) is used as OSC-framework.
- [AMSerialPort](https://github.com/smokyonion/AMSerialPort) is used for Arduino-connection

VVOSC is used as OSC-framework.
The current version is built for Mac OS 10.8 SDK. A compiled and runnable version of the atemOSC is included. Caution: The software lacks of many usability features (like input validation).

----------

Expand Down
23 changes: 23 additions & 0 deletions arduino-tally/arduino-tally.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
int incomingByte = 0; // for incoming serial data

int cams[] = {6,9,10,11};

void setup() {
Serial.begin(9600); // opens serial port, sets data rate to 9600 bps
}

void loop() {

// send data only when you receive data:
if (Serial.available() > 0) {
// read the incoming byte:
incomingByte = Serial.read();

for (int i = 0;i<sizeof(cams);i++) {
analogWrite(cams[i],0);
}
analogWrite(cams[incomingByte-49],128);

}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?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>BuildMachineOSBuild</key>
<string>11E53</string>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleExecutable</key>
<string>VVBasics</string>
<key>CFBundleGetInfoString</key>
<string>156</string>
<key>CFBundleIdentifier</key>
<string>com.vidvox.VVBasics</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>156</string>
<key>DTCompiler</key>
<string>com.apple.compilers.llvm.clang.1_0</string>
<key>DTPlatformBuild</key>
<string>4E2002</string>
<key>DTPlatformVersion</key>
<string>GM</string>
<key>DTSDKBuild</key>
<string>10K549</string>
<key>DTSDKName</key>
<string>macosx10.6</string>
<key>DTXcode</key>
<string>0432</string>
<key>DTXcodeBuild</key>
<string>4E2002</string>
</dict>
</plist>
Binary file not shown.

This file was deleted.

Binary file not shown.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,185 @@

#if IPHONE
#import <UIKit/UIKit.h>
#else
#import <Cocoa/Cocoa.h>
#endif
#import <pthread.h>



/// Similar to NSMutableArray, but thread-safe. Internally, uses an NSMutableArray and a rwlock.
/*
This class exists because NSMutableArray is not thread-safe by default: if you call methods on it from two different threads at the same time, it will try to execute both, often crashing in the process. I found myself writing a lot of lock/array pairs, so simplified everything by combining them into a single class. MutLockArray has methods which allow you to work with a mutable array in a transparent and thread-safe manner- it will automatically establish the read-/write-locks necessary to perform the relevant task. By avoiding the "lock" methods, you can also work with the array without performing any locking- so you can get a read-/write-lock, perform a number of actions, and then unlock.
It is important to remember, when working with it, that MutLockArray is NOT a subclass of NSMutableArray; rather, it is a subclass of NSObject with an instance of an NSMutableArray and a rwlock for working with it safely. This means that you can't pass an instance of MutLockArray to anything which is expecting to be passed an NSMutableArray- internally, apple's frameworks will probably be doing some dark voodoo bullshit which will result in a spectacular failure. If you want to work with an actual NSMutableArray, check out the "array", "createArrayCopy", and "lockCreateArrayCopy" methods below.
...and remember- when looking for stuff in an NSMutableArray, the array will use the "isEqualTo:" comparator method, which is slower than comparing the address of two pointers. if you know the pointer address hasn't changed (if you're *not* working with NSStrings), use the "indexOfIdenticalPtr", "removeIdenticalPtr", etc. methods to work with the array.
*/

@interface MutLockArray : NSObject {
NSMutableArray *array;
pthread_rwlock_t arrayLock;
}

/// Creates and returns an auto-released MutLockArray with a given capacity. The capacity may be 0.
+ (id) arrayWithCapacity:(NSUInteger)c;
/// Inits and returns a MutLockArray with a given capacity; the capacity may be 0.
- (id) initWithCapacity:(NSUInteger)c;
- (id) init;

/// Establishes a read-lock for the array; multiple read locks may exist simultaneously (if it's not changing, anything can look at the contents of the array). This method does not return until it has been able to get the lock.
- (void) rdlock;
- (BOOL) tryRdLock; // returns YES if i got a read-lock successfully!
/// Establishes a write-lock for the array. Only one write-lock may exist at any given time, and all read-locks must be relinquished before the write-lock may be established (if you're going to change the array, nothing else can be changing or observing it).
- (void) wrlock;
/// Unlocks the array.
- (void) unlock;

/// Returns the NSMutableArray with everything in it. This returns the actual array, so be careful- it's possible to do something which ISN'T threadsafe with this...
- (NSMutableArray *) array;
/// Returns an NSMutableArray which was created by calling "mutableCopy" on my array. Again, it's possible to do something which ISN'T threadsafe by calling this...
- (NSMutableArray *) createArrayCopy;
/// Returns an NSMutableArray which was created while a read-lock was established; this is threadsafe.
- (NSMutableArray *) lockCreateArrayCopy;

/// Calls "addObject" on my array; not threadsafe.
- (void) addObject:(id)o;
/// Establishes a write-lock, then calls "addObject" on self; threadsafe.
- (void) lockAddObject:(id)o;
/// Calls "addObjectsFromArray" on my array; not threadsafe.
- (void) addObjectsFromArray:(id)a;
/// Establishes a write-lock, then calls "addObjectsFromArray" on self; threadsafe.
- (void) lockAddObjectsFromArray:(id)a;
/// Calls "addObjectsFromArray" on my array; not threadsafe.
- (void) replaceWithObjectsFromArray:(id)a;
/// Establishes a write-lock, then calls "replaceWithObjectsFromArray" on self; threadsafe.
- (void) lockReplaceWithObjectsFromArray:(id)a;
/// Calls "insertObject:atIndex:" on my array; not threadsafe.
- (void) insertObject:(id)o atIndex:(NSUInteger)i;
/// Establishes a write-lock, then calls "insertObject:atIndex:" on self; threadsafe.
- (void) lockInsertObject:(id)o atIndex:(NSUInteger)i;
/// Calls "removeAllObjects" on my array; not threadsafe.
- (void) removeAllObjects;
/// Establishes a write-lock, then calls "removeAllObjects" on self; threadsafe.
- (void) lockRemoveAllObjects;
/// Calls "objectAtIndex:0" on my array; not threadsafe.
- (id) firstObject;
/// Establishes a read-lock, then calls "firstObject" on self; threadsafe
- (id) lockFirstObject;
/// Calls "removeObjectAtIndex:0" on my array; not threadsafe
- (void) removeFirstObject;
/// Establishes a write-lock, then calls "removeFirstObject" on self; threadsafe.
- (void) lockRemoveFirstObject;
/// Calls "lastObject" on my array; not threadsafe.
- (id) lastObject;
/// Establishes a read-lock, then calls "lastObject" on self; threadsafe.
- (id) lockLastObject;
/// Calls "removeLastObject" on my array; not threadsafe.
- (void) removeLastObject;
/// Establishes a write-lock, then calls "removeLastObject" on self; threadsafe.
- (void) lockRemoveLastObject;
/// Calls "removeObject:" on my array; not threadsafe.
- (void) removeObject:(id)o;
/// Establishes a write-lock, then calls "removeObject:" on self; threadsafe.
- (void) lockRemoveObject:(id)o;
/// Calls "removeObjectAtIndex:" on my array; not threadsafe.
- (void) removeObjectAtIndex:(NSUInteger)i;
/// Establishes a write-lock, then calls "removeObjectAtIndex:" on self; threadsafe.
- (void) lockRemoveObjectAtIndex:(NSUInteger)i;
/// Calls "removeObjectsAtIndexes:" on my array; not threadsafe.
- (void) removeObjectsAtIndexes:(NSIndexSet *)i;
/// Establishes a write-lock, then calls "removeObjectsAtIndexes:" on self; threadsafe.
- (void) lockRemoveObjectsAtIndexes:(NSIndexSet *)i;
/// Calls "removeObjectsInArray:" on my array; not threadsafe.
- (void) removeObjectsInArray:(NSArray *)otherArray;
/// Establishes a write-lock, then calls "removeObjectsInArray:" on self; threadsafe.
- (void) lockRemoveObjectsInArray:(NSArray *)otherArray;
/// Calls "removeIdenticalPtrsInArray:" on my array; not threadsafe
- (void) removeIdenticalPtrsInArray:(NSArray *)a;
/// Establishes a write-lock, then calls "removeIdenticalPtrsInArray:" on self; threadsafe.
- (void) lockRemoveIdenticalPtrsInArray:(NSArray *)a;

/// Calls "replaceObjectsAtIndexes:withObjects" on my array; not threadsafe.
- (void) replaceObjectsAtIndexes:(NSIndexSet *)indexes withObjects:(NSArray *)objects;
// Establishes a write-lock, then calls "replaceObjectsAtIndexes:withObjects on self; threadsafe
- (void) lockReplaceObjectsAtIndexes:(NSIndexSet *)indexes withObjects:(NSArray *)objects;

/// Calls "valueForKey:" on my array; not threadsafe.
- (id) valueForKey:(NSString *)key;
/// Establishes a read-lock, then calls "valueForKey:" on self; threadsafe.
- (id) lockValueForKey:(NSString *)key;


/// Calls "containsObject:" on my array; not threadsafe.
- (BOOL) containsObject:(id)o;
/// Establishes a read-lock, then calls "containsObject:" on self; threadsafe.
- (BOOL) lockContainsObject:(id)o;
/// Calls "objectAtIndex:" on my array; not threadsafe.
- (id) objectAtIndex:(NSUInteger)i;
/// Establishes a read-lock, then calls "objectAtIndex:" on self; threadsafe.
- (id) lockObjectAtIndex:(NSUInteger)i;
/// Calls "objectsAtIndexes:" on my array; not threadsafe.
- (NSArray *) objectsAtIndexes:(NSIndexSet *)indexes;
/// Establishes a read-lock, then calls "objectsAtIndexes:" on self; threadsafe.
- (NSArray *) lockObjectsAtIndexes:(NSIndexSet *)indexes;
/// Calls "indexOfObject:" on my array; not threadsafe.
- (NSUInteger) indexOfObject:(id)o;
/// Establishes a read-lock, then calls "indexOfObject:" on self; threadsafe.
- (NSUInteger) lockIndexOfObject:(id)o;


/// Enumerates through my array- compares the address of each item in the array to the passed pointer. Unlike NSMutableArray, this method does NOT call isEqualTo:, it's just a simple == operator.
- (BOOL) containsIdenticalPtr:(id)o;
/// Establishes a read-lock, then calls "containsIdenticalPtr:" on self; threadsafe.
- (BOOL) lockContainsIdenticalPtr:(id)o;
/// Enumerates through my array- compares the address of each item in the array to the passed pointer. Unlike NSMutableArray, this method does NOT call isEqualTo:, it's just a simple == operator.
- (long) indexOfIdenticalPtr:(id)o;
/// Establishes a read-lock, then calls "indexOfIdenticalPtr:" on self; threadsafe.
- (long) lockIndexOfIdenticalPtr:(id)o;
/// Locates an item in my array by enumerating through it and comparing the address of each item in the array to the passed ptr, and then deletes the matching item from the array; not threadsafe.
- (void) removeIdenticalPtr:(id)o;
/// Establishes a write-lock, then calls "removeIdenticalPtr:" on self; threadsafe.
- (void) lockRemoveIdenticalPtr:(id)o;

// Calls "filteredArrayUsingPredicate:" on my array; not threadsafe
- (NSArray *)filteredArrayUsingPredicate:(NSPredicate *)predicate;
// Establishes a read-lock, then calls "filteredArrayUsingPredicate:" on self; threadsafe
- (NSArray *) lockFilteredArrayUsingPredicate:(NSPredicate *)predicate;

/// Calls "makeObjectsPerformSelector:" on my array; not threadsafe.
- (void) makeObjectsPerformSelector:(SEL)s;
/// Establishes a read-lock, then calls "makeObjectsPerformSelector:" on self; threadsafe.
- (void) lockMakeObjectsPerformSelector:(SEL)s;
/// Calls "makeObjectsPerformSelector:withObject:" on my array; not threadsafe.
- (void) makeObjectsPerformSelector:(SEL)s withObject:(id)o;
/// Establishes a read-lock, then calls "makeObjectsPerformSelector:withObject:" on self; threadsafe.
- (void) lockMakeObjectsPerformSelector:(SEL)s withObject:(id)o;



/*
- (void) makeCopyPerformSelector:(SEL)s;
- (void) lockMakeCopyPerformSelector:(SEL)s;
- (void) makeCopyPerformSelector:(SEL)s withObject:(id)o;
- (void) lockMakeCopyPerformSelector:(SEL)s withObject:(id)o;
*/



/// Calls "sortUsingSelector:" on my array; not threadsafe.
- (void) sortUsingSelector:(SEL)s;
/// Establishes a write-lock, then calls "sortUsingSelector:" on self; threadsafe.
- (void) lockSortUsingSelector:(SEL)s;

/// Calls "sortUsingDescriptors:" on my array; not threadsafe.
- (void) sortUsingDescriptors:(NSArray *)descriptors;
/// Establishes a write-lock, then calls "sortUsingDescriptors:" on self; threadsafe.
- (void) lockSortUsingDescriptors:(NSArray *)descriptors;

- (NSEnumerator *) objectEnumerator;
- (NSEnumerator *) reverseObjectEnumerator;
- (long) count;
- (long) lockCount;

@end
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@

#if IPHONE
#import <UIKit/UIKit.h>
#else
#import <Cocoa/Cocoa.h>
#endif
#import <pthread.h>



/// MutLockDict is a thread-safe version of NSMutableDictionary.
/*!
This class exists because NSMutableDictionary is not thread-safe by default: if you call methods on it from two different threads at the same time, it will try to execute both, often crashing in the process. This class has methods which allow you to work with a mutable dictionary in a transparent and thread-safe manner.
*/

@interface MutLockDict : NSObject {
NSMutableDictionary *dict;
pthread_rwlock_t dictLock;
}

+ (id) dictionaryWithCapacity:(NSUInteger)c;
+ (id) dictionaryWithDict:(NSDictionary *)d;
- (id) initWithCapacity:(NSUInteger)c;

- (void) rdlock;
- (void) wrlock;
- (void) unlock;

- (NSMutableDictionary *) dict;
- (NSMutableDictionary *) createDictCopy;
- (NSMutableDictionary *) lockCreateDictCopy;

- (void) setObject:(id)o forKey:(NSString *)s;
- (void) lockSetObject:(id)o forKey:(NSString *)s;
- (void) setValue:(id)v forKey:(NSString *)s;
- (void) lockSetValue:(id)v forKey:(NSString *)s;
- (void) removeAllObjects;
- (void) lockRemoveAllObjects;
- (id) objectForKey:(NSString *)k;
- (id) lockObjectForKey:(NSString *)k;
- (void) removeObjectForKey:(NSString *)k;
- (void) lockRemoveObjectForKey:(NSString *)k;
- (void) addEntriesFromDictionary:(NSDictionary *)otherDictionary;
- (void) lockAddEntriesFromDictionary:(NSDictionary *)otherDictionary;
- (NSArray *) allKeys;
- (NSArray *) lockAllKeys;
- (NSArray *) allValues;
- (NSArray *) lockAllValues;

- (void) lockMakeObjectsPerformSelector:(SEL)s;
- (void) makeObjectsPerformSelector:(SEL)s;

- (NSUInteger) count;
- (NSUInteger) lockCount;

@end
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@

#if IPHONE
#import <UIKit/UIKit.h>
#else
#import <Cocoa/Cocoa.h>
#endif

#import "MutLockArray.h"
#import "ObjectHolder.h"



/// Subclass of MutLockArray; this class does NOT retain the objects in its array!
/*
this class exists because i frequently find myself in situations where i want to add an instance of an object to an array/dict/[any class which retains the passed instance], but i don't actually want the item to be retained.
Instead of adding (and therefore retaining) objects to an array like my superclass, this class makes an ObjectHolder for objects which are added to it (so they don't get retained), and adds the ObjectHolder to me. when other classes ask me for the index of an object, or ask for the object at a particular index, i'll find the relevant ObjectHolder and then return the object it's storing.
*/

@interface MutNRLockArray : MutLockArray {

}

+ (id) arrayWithCapacity:(NSUInteger)c;

- (NSMutableArray *) createArrayCopy;
- (NSMutableArray *) lockCreateArrayCopyFromObjects;
- (NSMutableArray *) createArrayCopyFromObjects;
- (void) addObject:(id)o;
- (void) addObjectsFromArray:(id)a;
- (void) replaceWithObjectsFromArray:(id)a;
- (void) insertObject:(id)o atIndex:(NSUInteger)i;
- (id) lastObject;
- (void) removeObject:(id)o;
- (BOOL) containsObject:(id)o;
- (id) objectAtIndex:(NSUInteger)i;
- (NSArray *) objectsAtIndexes:(NSIndexSet *)indexes;
- (NSUInteger) indexOfObject:(id)o;
- (BOOL) containsIdenticalPtr:(id)o;
- (long) indexOfIdenticalPtr:(id)o;
- (void) removeIdenticalPtr:(id)o;

// these methods exist because the lookup cost for an ObjectHolder can be significant for high-performance applications- these methods get the object from the ObjectHolder and call the method directly on it!
- (void) bruteForceMakeObjectsPerformSelector:(SEL)s;
- (void) lockBruteForceMakeObjectsPerformSelector:(SEL)s;
- (void) bruteForceMakeObjectsPerformSelector:(SEL)s withObject:(id)o;
- (void) lockBruteForceMakeObjectsPerformSelector:(SEL)s withObject:(id)o;


@end
Loading

0 comments on commit 4253597

Please sign in to comment.