PortAudio  2.0
PortAudio Tutorials

These tutorials takes you through a hands-on example of using PortAudio to make sound. If you'd prefer to start with a top-down overview of the PortAudio API, check out the PortAudio API Overview.

Downloading

First thing you need to do is download the PortAudio source code either as a tarball from the website, or from the Subversion Repository.

Compiling

Once you've downloaded PortAudio you'll need to compile it, which of course, depends on your environment:

Many platforms with GCC/make can use the simple ./configure && make combination and simply use the resulting libraries in their code.

Programming with PortAudio

Below are the steps to writing a PortAudio application using the callback technique:

In addition to this "Callback" architecture, V19 also supports a "Blocking I/O" model which uses read and write calls which may be more familiar to non-audio programmers. Note that at this time, not all APIs support this functionality.

In this tutorial, we'll show how to use the callback architecture to play a sawtooth wave. Much of the tutorial is taken from the file paex_saw.c, which is part of the PortAudio distribution. When you're done with this tutorial, you'll be armed with the basic knowledge you need to write an audio program. If you need more sample code, look in the "examples" and "test" directory of the PortAudio distribution. Another great source of info is the portaudio.h Doxygen page, which documents the entire V19 API. Also see the page for tips on programming PortAudio on the PortAudio wiki.

Programming Tutorial Contents

If you are upgrading from V18, you may want to look at the Proposed Enhancements to PortAudio, which describes the differences between V18 and V19.

Once you have a basic understanding of how to use PortAudio, you might be interested in Exploring PortAudio.

Next: Writing a Callback Function