Since iOS 5 we have support for reverb effects in OpenAL but I couldn't find any good example for using this functionality. I found only some links to ObjectAL source code but it is too complicated to understand the usage of reverb effects. So, how to add reverb effect to iOS app using OpenAL?
1 Answers
The ObjectAL codebase has gotten pretty complicated, but on the OpenAL side it's actually just one big wrapper around the C API for the most part. The primary Objective-C API entry points for reverb are:
If you want to implement it yourself, you'll first need to bind the extension functions like I do in +[ALWrapper initialize]: https://github.com/kstenerud/ObjectAL-for-iPhone/blob/master/ObjectAL/ObjectAL/OpenAL/ALWrapper.m#L1363
At the core, all of the reverb functionality is done using calls to alcASASetListener() and alcASASetSource(). If you search for those functions in ALWrapper, you'll see that it's just wrapping the call in Objective-C (plus some error handling), and ALSource & ALListener are wrapping that. At the lowest level, it's just a bunch of these kinds of calls:
alcASASetSource(ALC_ASA_REVERB_SEND_LEVEL, sourceID, &value, sizeof(value));
So the code will always follow one of these two paths:
- ALSource -> ALWrapper -> Raw C call to alcASASetSource()
- ALListener -> ALWrapper -> Raw C call to alcASASetListener()
The global controls (controlled via the listener) are:
- Turn reverb on/off (globally)
- Global reverb level (How loud the reverb effects are)
- Room type (various presets are available such as ALC_ASA_REVERB_ROOM_TYPE_Cathedral)
- EQ gain, bandwidth, frequency (basic filtering, used the same way you'd use a physical equalizer - you probably won't use this much, if at all)
The local controls (controlled via the source) are:
- Reverb send level (how much reverb affects this source)
- Reverb occlusion (simulate a physical object between the listener and source that sound can partially traverse, like a door or a thin wall)
- Reverb obstruction (simulate a physical object between the listener and source that doesn't conduct sound, such that you only hear sound going around it, like a concrete pillar)
I've also written a small demo here: https://github.com/kstenerud/ObjectAL-for-iPhone/blob/master/ObjectALDemo/Demos/ReverbDemo.m
Apple hasn't put out much documentation as far as I'm aware, so your best bet would be to clone the repo, build the demo, and play around with the API until you get a feel for how it all works together. Then it would be a matter of translating the stuff you did using ObjectAL into the actual calls to alcASASetListener() and friends, but those should be pretty direct translations since it's just wrapper code in the end.

- 14,434
- 9
- 44
- 61
-
Thank you very much! Actually, I did all you wrote but nothing happened. And now you encouraged me to look closer. My mistake was in turning reverb on. I passed ALboolean value to that function instead of ALint: `alcASASetListener(ALC_ASA_REVERB_ON, &reverbIsOn, sizeof(reverbIsOn));` – Steel Apple Oct 09 '12 at 08:44
-
@Karl great contribution to the audio community. Your library will be useful in my app! – manderson Jan 19 '13 at 04:34
-
@Karl not to split hairs but technically speaking it looks like the OpenAL C calls are actually to `alcGetProcAddress()`. It looks like `alcASASet{Source, Listener}()` are then called internally by OpenAL. Just thought I'd point that since this threw me off initially, seeing as there is no mention of `alcASASet{Source, Listener}()` in [the OpenAL user specs](http://open-activewrl.sourceforge.net/data/OpenAL_PGuide.pdf). – acannon828 Feb 18 '15 at 16:46
-
Wait no I was wrong...`alcASASet{Source, Listener}()` are defined in the Apple Spatial Audio extensions (oalMacOSX_OALExtensions.h). – acannon828 Feb 18 '15 at 17:52