Openal - Bad Audio


Rockthesmurf

Advanced Member
Joined
Jul 18, 2003
Messages
1,115
Age
40
Location
Manchester, UK
Website
Visit site
Hi there,

I have built OpenAL for Pandora, but when I play multiple sounds at once it kills the frame rate, and the sounds are juttery and sound really bad. I have built OpenAL with ALSA support, but when I enumerate available devices at runtime I only see:

- OSS Default
- Null Output

What are other peoples experiences? I am sure I should be able to have multiple sounds playing at once, and sounding nice - I am cross compiling everything if that makes any difference!

Oh, I do have a music track playing at the same time, which is being played through OpenAL, so I guess I can sort of play two sounds at once, but adding a third makes thing go pretty wrong!

I look forward to your expert help,

Steve
 
I should probably also add, I build the same project (with identical code for sound/music) on IPhone and PC and everything sounds fine, so I do not think the problem lies with any of that code. My gut feeling is I probably am not using the right device, or something along those lines. But I most certainly do not know for sure.

Steve
 
Okay, I have progressed a bit further, for starters I was making a silly mistake, whilst I was linking against my newly compiled version of OpenAL that has ALSA support, I had not copied the updated shared library onto my Pandora, so it using the old version with out ALSA support. With that fixed, I now get the option of the following devices:

  • ALSA Default
  • omap3pandora [] (hw:0,0) via ALSA
  • omap3pandora [] (hw:0,1) via ALSA
  • OSS Default
  • NULL Output

The ALSA Default device seems to be pretty bad, sometimes stuttering with just a single sound, or couple of sounds playing. The 'omap3pandora [] (hw:0,0) via ALSA' option seems to be similar to the initial device I was using, in that it can play a couple of sounds okay, but adding a third causes problems. The 'omap3pandora [] (hw:0,1) via ALSA' device doesn't appear to make any sound, but I can see by the frame rate it performs about the same as the other hw device.

I tried clocking my Pandora up to 800 MHz, this improves things quite a lot, still got some sound issues, but far less, which makes me think it is just very costly to play multiple sounds at once on Pandora, even when requesting a device with 'hw' in the name (which I assumed would be a hardware device).

Is it possible the Pandora just has pretty poor audio drivers? Other platforms (IPhone - right back to the original model, or my Android phone the Nexus One) do not have any problems playing multiple sounds.

Has anyone developed any software that plays a few sounds at once?

Steve
 
Are you compiling with the optimized compiler flags? For me in some applications this made a huge difference.
 
Pandora doesn't have any kind of hardware mixing, so it's most likely done in software by OpenAL itself. There should be enough power to mix 3 sounds though, unless it uses some kind of filtering that gcc produces really bad ARM code for. Best to check OpenAL compile flags, like Hitnrun says.
 
I just tried an optimised build of my game code, which made no difference, but that is to be expected, as the game code doesn't do any heavy lifting, it just issues commands to OpenAL. I'll have a look at what compile flags OpenAL is using next. I am just using the CMake stuff that OpenAL provides, I assumed it'd be using sensible flags, but maybe that's a bad assumption!

I didn't know that the Pandora didn't have any hardware mixing capabilities, but that would certainly explain why when I clocked my CPU higher it improves things. Any idea how many sounds I can expect to be able to mix? I typically have a background music track, and up to perhaps 5 sound effects playing, I might have been lucky in that other platforms I have targeted have either been clocked higher or had hardware mixing, but it would feel like a bit of a short coming of the Pandora if it can't handle a decent amount of simultaneous sound effects, as I would have thought that would be quite common in a game.

Steve
 
Due to my lack of knowledge about CMake, I've just used procmon to see what the compiler gets called with (minus include paths):

Code:
arm-none-linux-gnueabi-gcc.exe
-DAL_BUILD_LIBRARY
-DHAVE_GCC_VISIBILITY 
-D_GNU_SOURCE=1 
-D_DEBUG
-g 
-O2 
-funroll-loops  
-fPIC 
-Wall 
-Wextra 
-fvisibility=hidden 
-pthread 
-DAL_ALEXT_PROTOTYPES 
-c C:/Projects/OpenAL/OpenAL-Soft/OpenAL32/alAuxEffectSlot.c 
-o CMakeFiles/openal.dir/OpenAL32/alAuxEffectSlot.o

I would think O2 would be enough to be able to call that an optimized build - any flags it is missing that could make any substantial difference?

Steve
 
Rockthesmurf said:
Due to my lack of knowledge about CMake, I've just used procmon to see what the compiler gets called with (minus include paths):

Code:
arm-none-linux-gnueabi-gcc.exe
-DAL_BUILD_LIBRARY
-DHAVE_GCC_VISIBILITY 
-D_GNU_SOURCE=1 
-D_DEBUG
-g 
-O2 
-funroll-loops  
-fPIC 
-Wall 
-Wextra 
-fvisibility=hidden 
-pthread 
-DAL_ALEXT_PROTOTYPES 
-c C:/Projects/OpenAL/OpenAL-Soft/OpenAL32/alAuxEffectSlot.c 
-o CMakeFiles/openal.dir/OpenAL32/alAuxEffectSlot.o

I would think O2 would be enough to be able to call that an optimized build - any flags it is missing that could make any substantial difference?

Steve

Only the ones that matters :)

try with:

-O3 -mcpu=cortex-a8 -mfpu=neon -ftree-vectorize -mfloat-abi=softfp -ffast-math -fsingle-precision-constant
 
Last edited by a moderator:
Okay, I'm not sure how to make CMake do that, but I'll manually build with those flags and see if it makes any difference - shouldn't take too long...

Steve
 
Rockthesmurf said:
Okay, I'm not sure how to make CMake do that, but I'll manually build with those flags and see if it makes any difference - shouldn't take too long...

Steve

Using any CMake gui, set this values on the CFLAGS and CXXFLAGS fields.

On linux I use the terminal gui called "ccmake".
 
Last edited by a moderator:
That seems to improve things quite a lot, on the whole not getting many sound stutters, still a few though. I am guessing it is not liking the fact it is having to mix sounds from a bunch of different frequencies, e.g. some SFX are 32,000, others are 44,100 and others 22,050 while the music is typically 32,000, or in some cases 44,100 (at the moment). I know on IPhone at least they recommend you keep the frequencies the same. I'll have to go through and save out as everything as 32,000 and see if that makes any difference. At this point I am still seeing worse performance in terms of audio compared to the first generation IPhone, which doesn't feel right! Then again I'm not sure what hardware acceleration it had for AL...

Steve
 
Back
Top