[SOLVED]Using the Jack audio server with openFrameworks on Linux

I want to use the ofxPd addon which opens Pure Data inside openFrameworks, but I want to use it with the Jack audio server, as this is the server I’m using for audio on my computer.
I’ve tried some stuff with earlier versions of OF, like compile rtAudio which I found on GitHub and replace the libRtAudio.a file and the RtAudio.h in ROOT/libs/rtAudio/lib and include/ directories (which didn’t work), but now I’m on OF-0.9.1 (I had some compiling issues with 0.8.4 which I don’t have with 0.9.1, so I prefer to use this version) and there’s no rtAudio directory. What I can find is ROOT/libs/openFrameworks/sound and there are some .cpp and .h files there, but I don’t know how I can achieve what I want…

I am not an OF user, but I work with a colleague who uses OF and I use Pd, hence I’m trying to make this work.

Anyone has any idea?

You can specify the audio API within the ofSooundStreamSettings: https://github.com/openframeworks/openFrameworks/blob/ac79b88f0c290c7842a3da81b683085f3527eefc/libs/openFrameworks/sound/ofBaseSoundStream.h#L19

the ofBaseSoundStream.h file from 0.9.1 is quite different. What I did find is the rtAudio.sh script in the scripts/apothecary/formulas/ directory which downloads and installs the rtAudio library, if I get it right.
I am now cloning openFrameworks from git and will try to compile that. How do I specify the audio API during compilation? I guess it’s done via some script, but I don’t know the exact steps.


this is something new in the next release but you can use it with the nightly builds for example.

also in linux we use the rtaudio library directly from the system, not compiled with apothecary and the library in the system already supports jack so no need to recompile it.

1 Like

@arturo so if I use the nightly builds from OF website download page and compile using the instructions here http://openframeworks.cc/setup/linux-install/ will any audio example use Jack by default, or do I have to specify it somehow?

in the default audioOutputExample you have to change the way of getting the default sound deivce to something like:

auto devices = soundStream.getDeviceList(ofSoundDevice::Api::JACK);

which should work if there’s any jack devices present

1 Like

You’re right, I saw these files with the colleague I mentioned and it seems that that’s the place to fix this. Still it doesn’t work.
I tried and I get errors of this type:
/home/alex/Applications/openFrameworks/libs/openFrameworks/sound/ofSoundStream.h:224:47: error: ‘ofSoundDevice::Api ofSoundStreamSettings::api’ is private ofSoundDevice::Api api = ofSoundDevice::Api::JACK; ^ /home/alex/Applications/openFrameworks/examples/sound/audioOutputExample/src/ofApp.cpp:35:11: error: within this context settings.api = ofSoundDevice::Api::JACK;

I tried to changed some .h and .cpp files, like ofSoundStream.h, lines 96 and 224, and ofBaseSoundStream.h, line 25, replacing “UNSPECIFIED” with “JACK”, but still I get these errors about “ofSoundDevice::Api ofSoundStreamSettings::api” being private and “settings.api = ofSoundDevice::Api::JACK;” in the project .cpp file throwing an error “withing this context”.

The audioOutputExample compiles fine if I keep all the lines concerning the audio API commented out. I must admit that I’m a bit lost here (I do use Jack with Pd and Audacity, so I know it’s working…).

Any ideas?

It worked!. I commented out lines 44-52 in audioOutputExample.cpp:
#ifdef TARGET_LINUX // Latest linux versions default to the HDMI output // this usually fixes that. Also check the list of available // devices if sound doesn't work auto devices = soundStream.getMatchingDevices("default"); if(!devices.empty()){ settings.setOutDevice(devices[1]); } #endif
and the project compiled (having kept the changes in my post above).
The strange thing is that the program runs fine the first time, but in order to run it again, I need to first stop JACK and restart it, otherwise I get a “Segmentation fault”, and sometimes even that won’t do, and the program won’t run and I have to re-compile it.

Anyway, I consider this issue to be solved. Thanks for the help!

This wasn’t necessary eventually. I changed the code back to the original and tried an app with the ofxPd addon and it worked perfectly, which also doesn’t give this strange behavior of needing to stop JACK before I re-launch the app.
So, this issue is indeed solved.

Thanks again!