NetAudio

Kok Chen, W7AY
[ w7ay (at) arrl.net ]


Introduction


NetAudio is a Cocoa framework which simplifies the implementation of MacOS X Core Audio's AUNetSend and AUNetReceive into a Cocoa program. AUNetSend and AUNetReceive are Audio Units that can be used to transfer audio data between applications and computers, including over a local network. The classes in NetAudio are compatible and interoperable with applications that directly use AUNetSend and AUNetReceive.

NetAudio links against the AudioUnit framework (in /System/Library/Frameworks).

The Xcode project for NetAudio, together with sample code can be downloaded together with the framework. See "Download" below.


NetAudio Classes


NetAudio consists of the NetSend and NetReceive classes, together with some opaque classes for NetReceive to use Bonjour for discovering NetSend services.

NetAudio defaults to a linear PCM (32 bit floating point) sound stream of 44100 samples/second with two channels per sample. Callback for new data are done through delegate methods. The NetSend and NetReceive classes can be easily subclassed to accept other parameters.

NetAudio uses an NSTimer process to pull data from the output renderer of the AUNetSend and AUNetReceive components. Both of the classes in NetAudio can be subclasses so that the data is pulled by the input renderer of a different Audio Unit (e.g., by the default Output Audio Unit).

NetSend
NetReceive


Download


The NetAudio framework, sources and Xcode project for NetAudio, and sample code can be obtained here. Included in the project is also some Bonjour classes that also might be useful for non-NetAudio applications.

The framework file (NetAudio.framework) should be copied into /Library/Frameworks or ~/Library/Frameworks, whichever is more appropriate.


Sample Code


The sample code for sending a sinusoidal waveform uses the NetSend object in NetAudio. It uses the Bonjour service name "NetSend Test."

The sample code for receiving and displaying an AUNetSend stream uses the NetReceive object in NetAudio. This application can be used with the NetSend Test sample code, and should produce the following waveform:

netreceivewin