PortAudio Tutorial

home | contents | previousnext

Compiling for Macintosh OS X

To compile a Macintosh OS X CoreAudio application with the PortAudio library you will use the following source files:
pa_mac_core/pa_mac_core.c
pa_common/pa_lib.c
pa_common/portaudio.h
pa_common/pa_host.h
pa_common/pa_convert.c
pa_common/pa_trace.c
pa_common/pa_trace.h
pablio/ringbuffer.c
pablio/ringbuffer.h

Using Apple Project Builder

Create a new ProjectBuilder project. You can use a "Tool" project to run the PortAudio examples.

Add the source files from above to your Project.

Add both the Apple CoreAudio.framework and the AudioToolbox.framework to your project by selecting "Add FrameWorks..." from the Project menu.

Compile and run the "pa_tests:patest_saw.c" file first because it is the simplest.

Or Using Metrowerks CodeWarrior 8

by James Van Lommel
Create a new CodeWarrior project using Mac OS C++ Stationery.
Then choose Mac OS X Mach-O > Standard Console > C++ Console Mach-O.

In the project window, Clear the HelloWorld.cpp file and add the source files from above to your Project.

Add a test file of your choosing, like
   patests    /patest_sine8.c

Add the frameworks to the Frameworks tab using Project > Add Files...
   CoreAudio
   AudioToolbox

(The System framework should already be a part of the project.)

Open the current target's settings, and in Language Settings > C/C++ Language, uncheck (disable) the "ANSI Strict" setting. (Do this for both Debug and Release projects, if necessary.) You may also choose to disable RTTI and exceptions; the most important settings are 'Force C++ compilation' (enabled) and 'ANSI Strict' (disabled)."

Edit pa_mac_core.c:
   On line 1546, cast the PaHost_AllocateFastMemory() result to a (char *) or you will get a compile error.

Compile and run. (may need to run from a terminal window)

I've successfully built patest_sine8.c this way using the CVS .tar version of portaudio (date: 2003-04-27). I get 17 warnings during compilation, all of which deal with unused variables or arguments.

home | contents | previousnext