Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make the API for loading audio files at run-time uniform across formats #8055

Open
4 tasks
CsloudX opened this issue Oct 10, 2023 · 5 comments
Open
4 tasks

Comments

@CsloudX
Copy link

CsloudX commented Oct 10, 2023

Describe the project you are working on

Music Player

Describe the problem or limitation you are having in your project

In 4.x, it has ability to load audio on runtime, but it not uniformed.

MP3

var file = FileAccess.open(path, FileAccess.READ)
var sound = AudioStreamMP3.new()
sound.data = file.get_buffer(file.get_length())

OGG

var sound = load_from_file(path)

WAV

No api, but I think it was simple to implement.

Describe the feature / enhancement and how it helps to overcome the problem or limitation

uniform all api to static method load_from_file(path).

  • add static method load_from_file for AudioStreamMP3
  • add static method load_from_file for AudioStreamWAV

If possible, I wish all have load_from_buffer.(sometime I will get data from network)

  • add static method load_from_buffer for AudioStreamMP3
  • add static method load_from_buffer for AudioStreamWAV

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

/

If this enhancement will not be used often, can it be worked around with a few lines of script?

/

Is there a reason why this should be core and not an add-on in the asset library?

It is should be core.

@Calinou Calinou changed the title uniform load api for audio file Make the API for loading audio files at run-time uniform across formats Oct 10, 2023
@fire
Copy link
Member

fire commented Oct 10, 2023

Are you interested in making pr for this? I think making a new matching set of apis would help unify and allow the backwards compatibility change by marking as deprecated and then removing many versions later

@marcinn1
Copy link

Should loading audio files work via ResourceLoader::load()? I see there is nothing like ResourceFormatLoaderAudio.

ResourceLoader::load can be a high level interface for loading any resources. Instead of detecting format of the file inside the app (MusicPlayer in this example), Godot can do this internally.

PS. I need audio files loading at runtime in my project. I can help with testing or making a patch.

@fire
Copy link
Member

fire commented Oct 12, 2023

The load function in Godot Engine utilizes its internal format. Importers convert the original file into this internal format. An .imported/godot/file.res replaces the original file with the converted internal format, and then the "pointer" is saved in the .import file.

@marcinn1
Copy link

Ok, so I'm confused again and I think I must be lucky with loading DDS by using ResourceLoader:
#5748 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants