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;
}
}
LocalFree(szArgList);
}
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