rt audio sound stream resets system samplerate on OSX

Whenever I run an OF app using ofSoundStream on my Macbook Pro 13 (OSX 10.6) the system audio settings samplerate for the input and/or output are reset to 96000 kHz. This is easy to test by running Audio MIDI Setup and watching the samplerate.

This is annoying as it means when I request 44100 it uses 96000 and my audio is twice the speed. Anyone else notice this? Perhaps this is due to something I’ve done on my system. It happens in both OF 0062 and 007.

yes is an rtAudio issue, i want to change rtAudio with portaudio but haven’t had time. The problem i think is that the default samplerate for your soundcard is actually 96000, anything else is doing uprate or downrate, so indeed it’s not a bad idea to use the default

is there any way we can control a reset of this rate, even when it specifies 44100 it switches and I see this happen in Audio MIDI setup. I tried using Maximillian, but that also needs ofSoundStream so the same problem occurs.

I can think of one way - use libsamplerate to resample at 44100 from 9600.

(I need the sound to be at 44.1khz for a beat tracker I am porting over - other option is go through that code and make it run variable sample rate)


You can try compiling portaudio for osx and changing ofConstants.h so OF uses portaudio instead of rtaudio. From my experience portaudio doesn’t have that problem.

What version of rtaudio is packaged with OF? I am using the latest version of rtaudio without problems on os x 10.6+10.7 (but not with openframeworks) there were some bugfixes for os x

i think the latest in january : ) but could be older. try changing the binary for the new version and see if that solves the problem

the latest rtaudio-version (4.0.10) is from 30 August 11, so an upgrade will probably fix the problems on os x.


I’m adding a few notes here - looks like it’s working!

  1. get portaudio and compile it using
    “configure && make”

this gives you: portaudio.h file to go in new folder you create
and make
libs->portaudio->lib and put “libportaudio.a” in there

  1. openframeworks finds these using it’s CoreOF.config
    add these two lines:
    HEADER_PORTAUDIO = “$(OF_PATH)/libs/portaudio/include”
    LIB_PORTAUDIO = “$(OF_PATH)/libs/portaudio/lib/osx/libportaudio.a”
    and at the bottom

so we’re keeping RTAUDIO as a possible but adding in the ability to switch to PORTAUDIO

3.To change which one it uses, go into ofConstants.h - this is in libs->openframeworks->utils

“// check if any soundstream api is defined from the compiler
#elif defined(TARGET_WIN32) || defined(TARGET_OSX)
“// check if any soundstream api is defined from the compiler
#elif defined(TARGET_WIN32) || defined(TARGET_OSX)
#define OF_SOUNDSTREAM_PORTAUDIO//anr changed here from rt to port audio”

so now portaudio is defined

  1. Add in the AudioUnit frameworks - this is needed by portaudio
    under Action, click on ->add…then ->add existing frameworks
    it should come up

  2. need to add ofPAsoundStream.h and .cpp into the openframeworksCompiled project in the openFrameworks->sound folder - various audio header files there, so drag them in and then recompile

  3. build openframeworksCompiled project

that should then mean that we are using portaudio in the example projects

I may have a few things wrong here. One project, audioInput is working fine, but a different project not working yet. If anyone can add more on what’s going on here, that could be really helpful…


so that did work

just to explain: we are changing the flag in CoreOF.config to make ofSoundStream use portaudio as default
when TARGET OSX is defined, it sets
instead of RTAUDIO

then it’s important for it to find the extra couple of libraries:
in openFrameworksCompiled - the ofPAsoundStream files
and for portaudio to work, the AudioUnit frameworks that contains various files used (I guess these weren’t used by RtAudio)

It’s good now not to have the weird error where the soundcard skips to 96Khz. Also, it looks like portaudio may allow you to set your sample rate.

Thanks Arturo and sth for the tips.