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

Migrate to Symphonia to support more audio formats #707

Open
mrDIMAS opened this issue Dec 6, 2024 · 8 comments
Open

Migrate to Symphonia to support more audio formats #707

mrDIMAS opened this issue Dec 6, 2024 · 8 comments
Assignees
Labels
enhancement New feature or request good first issue Good for newcomers sound anything sound-related

Comments

@mrDIMAS
Copy link
Member

mrDIMAS commented Dec 6, 2024

A very common format and it should be supported by the sound system.

Edit. Symphonia looks to be a better replacement for current decoder implementation.

@mrDIMAS mrDIMAS added enhancement New feature or request good first issue Good for newcomers sound anything sound-related labels Dec 6, 2024
@pedroafabri
Copy link

@mrDIMAS which library would you sugest to decode the mp3 file?

I'm new to Rust but excited by it's universe and I found this library: https://github.com/germangb/minimp3-rs

Do you think it'll do the job?

@mrDIMAS
Copy link
Member Author

mrDIMAS commented Dec 25, 2024

@pedroafabri I think it is worth integrating symphonia and remove all other decoder dependencies. It seems that this lib supports a ton of formats and this change could solve all the future format requests as well.

@mrDIMAS
Copy link
Member Author

mrDIMAS commented Dec 25, 2024

But for now you could add minimp3-rs if that's easier.

@pedroafabri
Copy link

@mrDIMAS maybe we could use symphonia for the .mp3 and open new issues to change .wav and .ogg to that lib too if it turns out well.

What do you think?

@mrDIMAS
Copy link
Member Author

mrDIMAS commented Dec 25, 2024

Symphonia looks to be quite easy to use and it could be a drop-in replacement for Decoder. All that is needed is to basically use next_packet to read next bunch of samples and then use these samples in Iterator impl.

I understand your concern, this change is quite significant and could potentially be a source of problems, but fyrox-sound has a bunch of examples that can be used to test if everything works as it should.

I can also rename this issue to Use symphonia crate instead of separate audio decoders so it better matches the actual task.

@pedroafabri
Copy link

Oh, I see now that you were proposing to use Symphonia alongside the other formats all in the same issue.

If you think it’s not too much for a single PR, you could update the title to reflect that this issue will switch everything to Symphonia and implement MP3 support.

Also, I’m relatively new to open-source collaboration, so feel free to correct me if needed!

@mrDIMAS
Copy link
Member Author

mrDIMAS commented Dec 25, 2024

Yeah, Symphonia is basically a full replacement for every decoder in fyrox-sound + it adds support for lots of new formats. It looks to be a relatively small PR - 3 changed files + 2 deleted (old decoders). So the idea of fyrox-sound decoder interface is simple - it must implement Iterator trait that emits samples one by one in interleaved format (LRLRLR...). Symphonia reads data by packets so you basically need to read a packet, then consume it in the iterator, when it depletes - read next packet and so on. Should be simple to implement. There are also a few additional methods like time_seek, rewind, etc. and there should also be no problems with it since Symphonia provides such methods too.

@mrDIMAS mrDIMAS changed the title Add mp3 audio format support. Migrate to Symphonia to support more audio formats Dec 25, 2024
@pedroafabri
Copy link

pedroafabri commented Dec 25, 2024

Perfect! I will probably only be able to take a look at the first week of January, because of the holidays.

If you're ok with that you can assign this one to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers sound anything sound-related
Projects
None yet
Development

No branches or pull requests

2 participants