JG Electronics

Play Through Lion

To do digital signal processing (DSP) with an audio signal your application must have an input unit to connect to the audio source, a DSP unit and an output unit to connect to a loudspeaker so you can hear the audio and the effect of the DSP unit. You can compare Play Through with an amplifier if you like, an amplifier consist of a pre amplifier (input unit), tone control (DSP unit) and a power amplifier (output unit).

With my knowledge so far I thought to accomplish Play Through with one Audio Graph consisting of three Apple Audio Units (AU). In AudioUnit.framework / AUComponent.h you’ll find descriptions of all the Apple Audio Units. There are Audio Output Units but there are no Audio Input Units.

You can use the HALOutput AU ocoaLigature0 kAudioUnitSubType_HALOutput ocoaLigature1 for input as well as for output but you can put only one HALOutput AU in an Audio Graph. The solution is to have a HALOutput AU for input connected to an input device and the output of the HALOutput AU connected to a buffer.

The Audio Graph can read from the buffer to a Varispeed AU ocoaLigature0 kAudioUnitSubType_VarispeedocoaLigature1  to compensate for the differences in timing between the Input and Output Devices. The Varispeed AU connects to a DSP AU that connects to a HALOutput AU for output connected to an output device.

It’s complex but for a radio amateur who likes to do DSP to decode audio signals it has an advance as well. For DSP with no standard DSP AU’s there are two possibilities:

     1.     You can do DSP in an Audio Graph, you need then a DSP AU that you have to write yourself.

     2.     You can do DSP with the raw PCM audio data that flows through the buffer and then you don’t have to write an Audio Unit yourself.

The complete Play Through consists from input to output of the following objects:

Input Device i.e. build in audio with build in microphone and line in, sound card intern or extern.

HALOutput Audio Unit for input.

Buffer for temporary storage of the PCM audio signal.

In the Audio Graph:

DSP Audio Unit Varispeed AU supplied by Apple. In this example we use only the Varispeed AU.

DSP Audio Unit i.e. tone control, effect, limiter, delay supplied by Apple.

HALOutput Audio Unit for output.

Output Device i.e. build in audio with build in loudspeaker, line out, sound card intern or extern.

I started to look for an Apple example and found an example from 2004 called Complex Play Through.

Very old I thought and written in Object C.

I made a project in XCode4.1 under Lion OSX10.7 and compiled it for OSX10.6 32-bit.

I received more then 30 warnings but the application runs perfect with the warnings still in the code.

Because the final application code will be completely different from this first code, I decide to divide the project in several parts and publish every part (step) separately so it will be easy to follow.

The next step will be to change all the deprecated functions, then to convert the code to Cocoa and after that to enhance to application.

Play Through is written in Cocoa and Object C but will be full Cocoa when the project is finished.

The MVC design pattern will be followed in Play Through.

The build requirements for this project are Mac OSX10.7 and XCode4.1

The runtime requirements are Mac OSX10.6 or later.

The Cocoa Filter Example is from Chen Kok W7AY. See HAM Radio Projects for other projects from Chen.


If you have questions about programming topics please ask these questions on a developer mailing list from Apple. There you find people with far more knowledge then I.

For questions concerning Core Audio goto: coreaudio-api@lists.apple.com

For books about the foundation of Cocoa Programming visit: www.bignerdranch.com

Other useful books:

C++ From the Beginning, author Jan Skansholm.

Cocoa Programming Developer’s Handbook, author David Chisnall.

Core Audio, authors Kevin Avila and Chris Adamson.

If you have remarks or if you find bugs please send me an email: jgelectronics@icloud.com

Click on the picture to download the application and the source code.

Happy Coding!


© JG Electronics