JG Electronics

Cocoa Audio Code Snippets

On my old website back in 2011 I published several Cocoa Audio Code XCode 4.0.1 Projects for OSX10.6.

The Cocoa Code Snippets from these projects still might be of interest to people who start to write audio programs.


If you like to study the examples start to study Audio Tool first.


You’re welcome to download and use the code, subject to the License Agreement mentioned in the classes.

For support please go to the Apple mailing lists.

Remarks and bug reports are welcome.


Click on the picture at the project page to download the application and the source code.


All the compiled programs still run on OSX 10.11

The first Apple Example I studied was ‘Default Output Unit’ a simple example to play a sine wave through the default audio output.

I converted it from C to Cocoa and added controls for frequency and amplitude control.

MIDI Tool is intended as a Cocoa example and a starting point for some basic MIDI functions.

It’s based on Apple’s example code Play Soft MIDI and MIDI Echo which I used as a starting point.

I copied the code into Xcode4.0 and I replaced some deprecated functions / methods.

Record Audio To File is intended as a Cocoa example and a starting point for Core Audio. It’s based on Apple’s example code Record Audio To File which I used as a starting point.

Serial Communication RS232 and RS485


Sometimes you need an old fashion serial interface to receive data from or send data to a device with only a serial port.

Play Audio From File is intended as a Cocoa example and a starting point for Core Audio.

Audio Queue Services Programming Guide.

Apple’s document that describes how to use Audio Queue Services.

Audio Queue Services Programming Guide.

Apple’s document that describes how to use Audio Queue Services.

Expand the example Play Audio Queue From File with a nice appearance, extra functions and a help window.

Not completed !!


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

Play Audio From File enhanced with an appearance that follows the Apple Human Interface Guidelines, a volume control, stop function and time display.

Chen Kok has written a Cocoa interface a free and open source Audio Library for Core Audio.

With this library it should be rather easy to write audio apps that uses sound input and / or output.

A Programming Guide comes with the Audio Library as well so it is excellent documented.

Both the library and programming guide you can download from Chen’s

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.

The Apple example project AUPinkNoise will build an audio unit generator that creates a pink noise output.

Cocoa Audio Code Snippets Not Completed

C Serial Communication Code

© JG Electronics

Ham Radio PA0JCG

Morse Code Generator for macOS


Morse Decoder for Arduino


Under  construction.


Last update: April  9, 2022