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’m adding a few notes here - looks like it’s working!
get portaudio and compile it using
“configure && make”
this gives you: portaudio.h file to go in new folder you create
libs->portaudio->include
and make
libs->portaudio->lib and put “libportaudio.a” in there
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
“… $(LIB_RTAUDIO) $(LIB_PORTAUDIO)”
“OF_CORE_HEADERS = $(HEADER_OF) … $(HEADER_RTAUDIO) $(HEADER_PORTAUDIO)”
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
change:
“// check if any soundstream api is defined from the compiler #if !defined(OF_SOUNDSTREAM_PORTAUDIO) && !defined(OF_SOUNDSTREAM_RTAUDIO) && !defined(OF_SOUNDSTREAM_ANDROID) #ifdef TARGET_LINUX #define OF_SOUNDSTREAM_PORTAUDIO #elif defined(TARGET_WIN32) || defined(TARGET_OSX) #define OF_SOUNDSTREAM_RTAUDIO”
to
“// check if any soundstream api is defined from the compiler #if !defined(OF_SOUNDSTREAM_PORTAUDIO) && !defined(OF_SOUNDSTREAM_RTAUDIO) && !defined(OF_SOUNDSTREAM_ANDROID) #ifdef TARGET_LINUX #define OF_SOUNDSTREAM_PORTAUDIO #elif defined(TARGET_WIN32) || defined(TARGET_OSX) #define OF_SOUNDSTREAM_PORTAUDIO//anr changed here from rt to port audio”
so now portaudio is defined
Add in the AudioUnit frameworks - this is needed by portaudio
under Action, click on ->add…then ->add existing frameworks
it should come up
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
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…
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 #define OF_SOUNDSTREAM_PORTAUDIO
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.