AGS Development > Engine Development

3D/Positional Audio using OpenAL

(1/3) > >>

vga256:
Context: I recently discovered that OpenAL (and via extensions?) supports Positional/3D audio. Although I spent some time browsing the ags github repo, I am not clear as to the progress made with the transition to SDL2 and OpenAL with 3.6.0. It *appears* from a glance that 3.6.0 is now using mojoAL for interfacing with OpenAL.

Question: Is it possible to write a plug-in for AGS that would enable some basic positional/3D audio functions that would allow run-time changes to audio during gameplay? I am working on a first-person adventure that would greatly benefit from this feature, and I'm willing to put in the wrench time to make it happen, if it is possible at all.

Crimson Wizard:

--- Quote from: vga256 on 21 Apr 2022, 23:47 --- Although I spent some time browsing the ags github repo, I am not clear as to the progress made with the transition to SDL2 and OpenAL with 3.6.0. It *appears* from a glance that 3.6.0 is now using mojoAL for interfacing with OpenAL.

--- End quote ---

3.6.0 has fully transition to SDL2 and is using mojoAL for audio playback, which is an OpenAL interface and SDL2-based implementation.
The parts of Allegro library are embedded into the engine code now; these are parts related to bitmap manipulation (pixel drawing) and utf-8 handling.


--- Quote from: vga256 on 21 Apr 2022, 23:47 ---
Question: Is it possible to write a plug-in for AGS that would enable some basic positional/3D audio functions that would allow run-time changes to audio during gameplay? I am working on a first-person adventure that would greatly benefit from this feature, and I'm willing to put in the wrench time to make it happen, if it is possible at all.

--- End quote ---

I don't think that's possible without changes in both engine and plugin API. Playback settings afaik are not exposed to plugin API in any way. Internally, in the engine playback does not have 3D settings. So even though the backend allows it, engine does not have this logic implemented anywhere.

AFAIK AGS supports sound stereo panning between left & right (see AudioChannel.Panning).

vga256:

--- Quote from: Crimson Wizard on 22 Apr 2022, 00:15 ---
3.6.0 has fully transition to SDL2 and is using mojoAL for audio playback, which is an OpenAL interface and SDL2-based implementation.
The parts of Allegro library are embedded into the engine code now; these are parts related to bitmap manipulation (pixel drawing) and utf-8 handling.

I don't think that's possible without changes in both engine and plugin API. Playback settings afaik are not exposed to plugin API in any way. Internally, in the engine playback does not have 3D settings. So even though the backend allows it, engine does not have this logic implemented anywhere.

AFAIK AGS supports sound stereo panning between left & right (see AudioChannel.Panning).

--- End quote ---

Gotcha! It sounds like this would be a very long term project if there was interest in it. In the interim I will do my best with the .Panning property - thanks.

eri0o:
Can you elaborate what are you trying to achieve with 3D positional audio?

Like, as an example, Alan's Draconian Ags4 fork has sound from views attached to characters corresponding to either the character position on screen, or character position relative to player character. Is it this a similar case or more playing a sound at a specific position?

AGS has AudioChannel.SetRoomLocation, so if it's more on the single API implementation, perhaps a similar API could be made, which would be more flexible but more disconnected from internal AGS game logic.

vga256:

--- Quote from: eri0o on 22 Apr 2022, 02:58 ---Can you elaborate what are you trying to achieve with 3D positional audio?

Like, as an example, Alan's Draconian Ags4 fork has sound from views attached to characters corresponding to either the character position on screen, or character position relative to player character. Is it this a similar case or more playing a sound at a specific position?

AGS has AudioChannel.SetRoomLocation, so if it's more on the single API implementation, perhaps a similar API could be made, which would be more flexible but more disconnected from internal AGS game logic.

--- End quote ---

So to clarify - the OpenAL 3D sound implementation is not simple Right-Left panning. It employs a complex set of algorithms to emulate positional sound in a 3D space using a Head-related Transfer Function. This is effectively "surround sound" produced algorithmically in stereo, instead of via many channels (5.1/7.1). You can watch/listen to an HRTF demo here. It is a much more powerful effect than a standard stereo pan.

After doing some reading, it is not clear to me if mojoAL supports HRTF, or if that functionality is enabled through an extension like ALC_SOFT_HRTF.

Navigation

[0] Message Index

[#] Next page

Go to full version