Skip to content

Enhance AudioEngine to Support Playing Sound Effects Directly from Binary Streams or Byte Arrays #3024

@hlwz5735

Description

@hlwz5735

Is your feature request related to a problem? Please describe.
Currently, the play2d and play3d methods in AudioEngine only accept file names as parameters, which limits playback to sound files located in the local resource directory. This becomes a significant issue when audio resources are embedded within archived packages (e.g., .zip, custom asset bundles) or are downloaded from the network, as there is no way to play them directly without first extracting or saving them to disk.

Describe the solution you'd like
I would like the AudioEngine to be enhanced with overloaded versions of the play2d and play3d methods that can accept byte arrays (e.g., unsigned char*, std::vector<unsigned char>) or input streams (e.g., std::istream or a custom stream interface) as parameters. Alternatively, introducing a new class like AudioClip to wrap the audio data (similar to Unity's design) would also be an excellent solution. This would allow developers to play sounds directly from memory or network streams without the overhead of intermediate files.

Describe alternatives you've considered

  1. Extracting or downloading audio resources to a temporary file before passing the file path to the existing play2d/play3d methods. This is inefficient and adds unnecessary I/O overhead, especially for frequently played sounds or network-sourced audio.
  2. Modifying the resource manager to support virtual file systems that can mount archives. While this is a more comprehensive solution, it is significantly more complex and time-consuming to implement compared to adding direct byte array/stream support to the audio playback methods.

Additional context
This enhancement would greatly improve flexibility for games and applications that package assets or rely on dynamic content delivery. It aligns with modern game development practices where resources are often loaded from memory for performance and security reasons. Implementing this would make the engine more versatile for a wider range of use cases.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions