About

Selected Works
.: An Uncommon Affair
   At Tooting Bec Common
.: Quasar (J.M. Crettaz, et.al.)
.: DEFENDEX-ESPGX
.: BitSignalFabric
.: AL on the BPE

Composition Samples

Publications, Articles, Exhibitions & Performances

Hardware & Software Projects
.: Super Retro Faderbox
.: grainbuffer~
.: MD Arduino
   (for Max and Processing)
.: CUIOSC
.: Mutator28
.: MySQLJBDC
   (a Max MXJ Object)
.: eXtend SEF

Contact

CUIOSC

NOTE: CUIOSC is supported on PPC only. No Intel version is currently planned. The source code is available below.

Conceived as a stand alone USB to OSC interface for my Super Retro Faderbox (SRF), CUIOSC is a general purpose Apple OSX application that provides a simple configurable interface to the Create USB Interface, designed by Dan Overholt, upon which the SRF is based. CUIOSC dynamically provides an interface for each CUI device attached to your computer.

Image
CUIOSC GUI Example


After launching the application, the user is supplied with a window for each CUI that is attached to the computer (up to 128). Each window provides configurable access to that particular device. The window serves two purposes, feedback and control. The feedback fields provide the user with information on the device name, manufacturer, vendor ID, product ID, current OSC host and port, as well as analog and digital input values. The user has control over the OSC host and port numbers, the OSC name space, and the polling rate of the device values.

Values are sent from the device via OSC using a fixed format name space:
/<deviceName>/<controlname> <value>
The values of the name space are user editable. Users can change the device name, and analog and digital names respectively (analog and digital names are also assigned a number based on the order the particular control appears in the USB descriptor table. This feature is not user configurable).

The development of the CUIOSC application involved the use of Carbon and other Apple API’s. In the Apple API there are several ways to access a USB device such as the CUI. These include the IOHIDDeviceInterface, IOUSBDeviceInterface, and IOUSBInterfaceInterface. Without going into the advantages and disadvantages of using these different methods, it should suffice to say that the IOHIDDeviceInterface was the best choice for CUI since it falls under the class of Human Interface Devices (HID, specifically a generic game HID devices) as described at USB.org.

The process for reading from a USB device involves several steps:

1. Find devices
Devices are discovered and added to an iterator based on whether or not they match a matching dictionary. If no dictionary is provided the function will return all HID devices.

2. Show properties
In this step information, such as the device name from the descriptor, is gathered and stored for later use.

3. Create device interface
The device interface is grabbed in order to access the device.

4. Get cookies
Endpoint keys are used to get data from the endpoints of the elements on the CUI. Cookies are assigned these keys so that the cookies may later be used to poll the device.

5. Open the device
Once we have the endpoints from the device we can open it for use.

6. Poll interface
Polling should be done in a callback from an Apple Event Manager. Initially, this was application was polling the device using pthreads  (as it still is in the older version: main2.c of the source code). But after implementing the standard Apple GUI with an Event Manager I was having what I think was a race condition, or some other problem due to the fact that the Apple Event Manager wants to be the parent thread and I was forcing it to fork off of the main thread, or something. Short of the long, In order to implement the GUI it was necessary to drop pthreads in favor of the Apple even Manager.

7. Close the device
When your done you should clean-up after yourself. Unless the OS will clean-up for you… I guess sometimes your mother does live here.

In addition to the Apple API, CUIOSC was, profoundly, developed using the OSC library from CNMAT, UC Berkeley via Matt Wright. In order to implement OSC I simply took the example from their website called SendOSC, made an interface for it called SimpleOSC that looks like:
SimpleOSC(HostName, PortName, NameSpace, Message)
This was very easy to do and I thank Matt Wright for making such a clear and easy to use example. My implementation of SimpleOSC can be extracted from the provided source code.

As for Apple API, I found it to be a little cryptic at first, but once I got the organization down I was able to find what I needed without cussing too much.

Anyway, enjoy the source code and application: CUIOSC.zip (2.1MB)

 

© 2008 MarkDavid Hosale