Quick tip: supporting wasapi and asio

As far as i understand OF0.10 will have unified sound support, where all APIs (Asio, WASAPI, Direct Sound) are enumerated through a single soundStream.getDeviceList() call or the Api can be specified. (see https://github.com/openframeworks/openFrameworks/blob/master/libs/openFrameworks/sound/ofRtAudioSoundStream.cpp#L71)

If you are like me and you already need a choice between different APIs, here is a non-intrusive way to patch OF. The end result will be a exe file that starts with Wasapi, and a Shortcut to the same exe that starts in Asio mode. There will be no changes to your code, so things won’t break if you pass the code to a person that doesn’t have the patch, or if you update to a newer version OF.

1. Edit libs/openFrameworks/sound/ofRtAudioSoundStream.cpp

Here we will read the command line arguments to the application and see if “asio” was passed as parameter.

Add this just underneath the existing header includes:

#include <wchar.h>
bool checkForAsioArgs() {
    LPWSTR *szArgList; 
    int argCount; 
    szArgList = CommandLineToArgvW(GetCommandLine(), &argCount);
    if (szArgList != NULL) {
        for (int i = 0; i < argCount; i++) {
            if (wcscmp(szArgList[i], L"asio")==0) {
                return true; 
    return false; 
bool of_rtaudiostream_use_asio = checkForAsioArgs(); 
#define OF_RTAUDIO_API (of_rtaudiostream_use_asio?RtAudio::Api::WINDOWS_ASIO:RtAudio::Api::WINDOWS_WASAPI) 

Now search for the two occurences of new RtAudio() in that same file.
Replace them with new RtAudio(OF_RTAUDIO_API)

2. Build the solution.

You now have an exe that connects to the WASAPI sound system.

3. Create a shortcut

In windows explorer right click on myApp/bin/myApp.exe and create a new shortcut. Rename it to myApp.exe - Asio so it’s easy to find.

Right click on the shortcut and edit the properties. At the end of shortcut target add an ‘asio’ argument. For me the target is now:

C:\Users\be\Desktop\of_v0.9.3_vs_release\apps\myApps\sketchyscope\bin\sketchyscope.exe asio

Don’t worry about the absolute path. Windows should know how to fix things when the folder gets moved around or is copied to another computer.

And… that’s all.

Here is a pastebin link with those same instructions which you can add as a comment in your readme or main.cpp: http://pastebin.com/ZZLZ3jUm

1 Like

The feature shoudl already exist in of0.9.3, see here:

And its implmentation:

Still an interesting way of allowing someone to switch Api’s via command line =)


it’s not in 0.9.3.
i saw that it was on master, but look here:

and here

that’s why i made this intermediate solution to have a quick patch, without breaking things once 0.9.4 is out.

best, hansi.


It seems that this feature is still missing in version 0.9.8 for Visual Studio. Will it be available in the next version of the Visual Studio download?


Sorry for the slow response. I’ll look into it.

Had a long hiatus due to grad school but now I have the time to tinker around with OF again.