Skip to content

Add support for playing 3d (stereo) sound effect. #745

@Tanay-ErrorCode

Description

@Tanay-ErrorCode

Description:

Currently, Ursina does not support playing stereo sound effects. All audio is heard equally in both speakers, which limits the immersive experience for 3D environments. This issue aims to introduce support for playing 3D sound effects, where audio volume and balance dynamically adjust based on the sound's position in 3D space, as well as the orientation of the listener.

The goal is to allow developers to input the following parameters:

  1. The position (x, y, z) and rotation of the entity (listener) that hears the sound.
  2. The position (x, y, z) of the entity (sound source) that plays the sound.

The system will use this information to:

  1. Calculate the distance between the sound source and the listener to adjust the overall volume (e.g., closer sounds are louder, farther sounds are quieter).
  2. Determine the direction of the sound relative to the listener's position and rotation to calculate the left and right audio channel volumes, creating a realistic stereo effect.

For example:

  • A sound coming from the left of the listener's current orientation will have higher volume in the left speaker and lower volume in the right speaker.
  • A sound coming from the right of the listener will do the opposite.
  • If the sound is directly in front of the listener, both speakers will play the sound equally.
  • The system will also account for cases where the listener rotates or moves, dynamically adjusting the audio to match the new orientation and distance.

This feature will help create more realistic and immersive soundscapes for 3D environments in Ursina by integrating position and rotation-based audio effects.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions