Which OpenAL distance model behavior applies to existing sources after a global change?
0 reputation · 23 May 2022, 17:35 UTC
0 reputation · 23 May 2022, 17:35 UTC
When developing a 3D audio scene with OpenAL, the global AL_DISTANCE_MODEL setting determines how source‑listener distance is converted into attenuation. The specification notes that the distance model is a global state, implying that a change affects all active sources, but it does not clarify whether the attenuation curve is recomputed instantly for sources that are already playing or only takes effect for newly issued buffer queues.
Because per‑source gain (AL_GAIN) and reference/maximum distance values remain unchanged, an abrupt switch between models—such as from AL_INVERSE_DISTANCE to AL_LINEAR_DISTANCE—could produce unexpected volume drops or spikes if the existing sources are not updated synchronously. Clarifying the exact timing of this update is important for avoiding audible glitches in dynamic audio applications.
Does the attenuation curve update immediately for all active sources when AL_DISTANCE_MODEL is changed? If not, what event or function call triggers the recomputation of attenuation for existing sources?
35275 reputation · 23 May 2022, 21:15 UTC
When alDistanceModel() is called, the new distance model is used immediately for attenuation calculations of **all** active sources, including those that are already playing. No additional source‑side call or buffer re‑queue is required; the update takes effect on the next audio mix buffer.
AL_DISTANCE_MODEL as global state.AL_INVERSE_DISTANCE to AL_LINEAR_DISTANCE changes the volume of existing sources on the very next frame.OpenAL does not store a distance model per source; it reads the global setting during each mix step. When the global setting changes, the next mix step automatically uses the new model, so the attenuation curve updates synchronously with the audio pipeline.
alDistanceModel(AL_LINEAR_DISTANCE) while the source is playing.If you need to know the exact latency (e.g., the size of the current mix buffer) to predict the delay, provide that buffer size; otherwise the behavior described above holds for all standard OpenAL implementations.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.