Skip to content

Conversation

@rh101
Copy link
Contributor

@rh101 rh101 commented Sep 14, 2025

Describe your changes

This is initial support for playing a sound at a specific position in 3D space. It will be relative to the listener. The position of the listener can also be set, allowing the listener position to be modified, such as when a player object is moving around.

Issue ticket number and link

Checklist before requesting a review

For each PR

  • Add Copyright if it missed:
    - "Copyright (c) 2019-present Axmol Engine contributors (see AUTHORS.md)."

  • I have performed a self-review of my code.

    Optional:

    • I have checked readme and add important infos to this PR.
    • I have added/adapted some tests too.

For core/new feature PR

  • I have checked readme and add important infos to this PR.
  • I have added thorough tests.

Axmol 3.x ------------------------------------------------------------

For each 3.x PR

  • Check the '#include "axmol.h"' and replace it with the needed headers.

Add support for setting listener position
@rh101 rh101 marked this pull request as draft September 14, 2025 14:49
@halx99
Copy link
Collaborator

halx99 commented Sep 14, 2025

What about let play2d invoke play3d with positon: Vec3::ZERO ?

@rh101
Copy link
Contributor Author

rh101 commented Sep 14, 2025

What about let play2d invoke play3d with positon: Vec3::ZERO ?

I did do that originally, but then realized that there would be other things to add to the 3d audio, such as the velocity, Doppler effects etc., so it would need its own method to handle all those things, since they cannot be applied to the 2D audio.

It may still be possible to reduce the code duplication significantly with refactoring, but for the time being, perhaps we just get an initial implementation working, and then improve it later?

@halx99
Copy link
Collaborator

halx99 commented Sep 14, 2025

perhaps we just get an initial implementation working, and then improve it later?

It's ok

@rh101 rh101 marked this pull request as ready for review September 14, 2025 16:37
@rh101
Copy link
Contributor Author

rh101 commented Sep 14, 2025

The cpp-tests Scene3D test seemed to be a good place to add a test for this, so if you move the character around, you can tell that the position of the audio changes correctly.

This implementation seems to be working well enough, and I'm sure in the future we can add more functionality to it. If there is nothing else, then this PR should be ready.

@halx99 halx99 added this to the 2.9.0 milestone Sep 14, 2025
@halx99 halx99 added the enhancement New feature or request label Sep 14, 2025
halx99
halx99 previously approved these changes Sep 14, 2025
@halx99 halx99 merged commit 4ce12e6 into axmolengine:release/2.x Sep 15, 2025
15 checks passed
@rh101 rh101 deleted the audio-play3d branch September 15, 2025 03:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants