Multichannel audio in Windows with ASIO and PortAudio

Hi all

Not sure if this will be of any use to anyone, but I thought I’d record it here in case. Been working with a Digigram LX1616ES soundcard, F/W upgraded to 32 input and 32 output channels. I’m using OF 0.07.

The card needed ASIO support and for whatever reason, recompiling RtAudio with ASIO support had RtAudio report back the data buffer format as -1. Instead, I set about the nasty job of getting PortAudio compiled in Windows with ASIO support and getting OF to use it.

Firstly - compiling PortAudio for Windows with ASIO.

  1. Make sure you have MinGW and MSys installed. I used the MinGW installed with CodeBlocks and MSys 1.0.11 from Set your MinGW directory in the post-install process for MSys in the style c:/progra~1/codebl~1/mingw. Yup, Windows is still that much fun.

  2. Download Portaudio. I used dated Tuesday, 26-Jul-2011. Extract somewhere useful - I used C:\portaudioASIO\portaudio

  3. Open the portaudio The following lines have changes:

CXX = @CXX@ becomes CXX = g++
CFLAGS has -$I(top_srcdir)/src/os/unix changed to -$I(top_srcdir)/src/os/win
CXXFLAGS has -$I(top_srcdir)/src/os/win added to it
LIBS has -lstdc++ added to it
DLL_LIBS has -lstdc++ added to it

  1. Download the ASIO sdk from Extract somewhere useful - I used C:\portaudioASIO\ASIOSDK2

  2. Run MSys and ensure the following directories exist - I think something bad I previously did removed them so you probably won’t have to create them. I created them with mkdir in the following way:

mkdir /c/portaudioasio/asiosdk2/common/.libs
mkdir /c/portaudioasio/asiosdk2/host/.libs
mkdir /c/portaudioasio/asiosdk2/host/pc/.libs

  1. CD to the dir with PortAudio. For me this was cd /c/portaudioasio/portaudio.

  2. Execute ./configure --with-winapi=asio --with-asiodir=“c:/portaudioasio/asiosdk2”

The output should read something like (after a lot of indecipherable stuff):

Configuration summary:

Target … i686-pc-mingw32
C++ bindings … no
Debug output … no

WMME … no
DSound … no
ASIO … yes (c:/portaudioasio/asiosdk2)
WDMKS … no

  1. Execute make. Pray. If you don’t see anything talking about errors, you’re probably OK at this point.

  2. What we want from this is in the portaudio\lib.libs folder and is called libportaudio.a. I can make mine available if needed so you can skip these steps.

Secondly - rebuild openFrameworks with Portaudio ASIO support

I’m assuming you’re using code::blocks for this bit.

  1. open the openframeworkslib project from libs\openframworks\compiled in your OF directory

  2. remove sound\RtAudio.cpp, sound\ofRtAudioSoundStream.cpp, sound\ofRtAudioSoundStream.h from the project, or just mark the .cpp files to be neither compiled or linked in their properties.

  3. add portaudio.h, ofPASoundStream.cpp and ofPASoundStream.h to the project from \libs\portaudio\include and \libs\openFrameworks\sound respectively

  4. whilst we’re at it, copy the libportaudio.a file into \libs\portaudio\lib

  5. in the project build options remove all references to rtaudio from the compiler search directories and add …\portaudio\include

  6. also in build options, add a compiler #define of OF_SOUNDSTREAM_PORTAUDIO

  7. open sound\ofPASoundStream.cpp and where it says #ifdef TARGET_LINUX… add our own ifdef:

#include “pa_asio.h”

  1. Clean and rebuild the library. All should be OK.

Thirdly - getting your OF project to correctly link portaudio

  1. Open the project - for this example I’m using the audioOutputExample

  2. In the project build options, remove librtaudio.a from the link libraries in the linker tab and replace it with the libportaudio.a we created in the first step and stored in \libs\portaudio\lib in the second step. It’s important this is in roughly the same place in the linker list - way before the GCC/MinGW links later on and certainly before ole32. For simplicity, keep it in the same position RtAudio was.

  3. Clean and rebuild the project.

And you’re done!

Don’t know if this will be of any use to anyone, but if OF is going towards portaudio instead of RtAudio, this will be an easy way to integrate it for Windows.


I use ASIO, too but with RTAudio, doing multichannel duplex stuff, never had real problems.
is port PortAudio better then RTAudio?
or are there good reason to change?

Hi Yonas

I couldn’t get RTAudio to work with ASIO last time I tried, although I’ve learned a bit since then. I think PortAudio is generally considered a bit more robust by people I’ve spoken to, but knowing how to do it for RTAudio would be really great too. Would you mind posting a walkthrough so people know how to do it?



I still work with OF 0062, got Asio with rtAudio running there, i tried to do the same thing in 007 today(recompiling rtAudio with the asio files from the asio sdk, and got some problems.
it compiles without problems and the listDevices() funtion prints only asio devices now, but when i try to setup one of them rtAudio prints an error message, something like samplerate(44100) is not supported on this device, but actualy it is… i’m not shure whats going on,but the whole soundstream thing seems to be changed in 007, there was no setDeviceID, so I did it manualy.
But portAudio is a regular part of OF now, so perhaps its easier to get ASIO running with PortAudio, now, then with rtAudio.


So I’ve had a go at doing an
ofxPortaudioSoundstream addon. This works for me. Has multiple version of a portaudio soundstream, useful if you want say input from line-in on laptop and also for that line-in to go to the headphones out.

it’s at:

Have included some info from here in the README. If anyone can check that out, that would be great. It may need a bit of tweaking!