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

[Merged by Bors] - Expose symphonia features from rodio in bevy_audio and bevy #6388

Closed
wants to merge 5 commits into from

Conversation

Ian-Yy
Copy link
Contributor

@Ian-Yy Ian-Yy commented Oct 27, 2022

Objective

Fix #6301

Solution

Add new features in bevy_audio to use symphonia sound format from rodio
Also add in bevy

@alice-i-cecile alice-i-cecile added A-Audio Sounds playback and modification C-Usability A simple quality-of-life change that makes Bevy easier to use labels Oct 27, 2022
@alice-i-cecile
Copy link
Member

Ping @harudagondi.

Copy link
Member

@harudagondi harudagondi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we add the description of the features here?

Otherwise, this LGTM.

@alice-i-cecile
Copy link
Member

We should, yes.

symphonia-all = ["bevy_internal/symphonia-all"]
symphonia-flac = ["bevy_internal/symphonia-flac"]
symphonia-isomp4 = ["bevy_internal/symphonia-isomp4"]
symphonia-mp3 = ["bevy_internal/symphonia-mp3"]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why expose this when there's another mp3 feature already? Same with wav and vorbis.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Symphonia is an alternative backend to what rodio uses, which depends on the features used (flac = claxon, vorbis = lewton, wav = hound, mp3 = minimp3).

imo these features should be available because:

  1. For completeness sake.
  2. When you want to support formats, where is only supported by symphonia (for example aac and wav) you'll have to compile both hound and symphonia. I think it's better as a user to just enable symphonia's wav feature instead of using hound to reduce compile times.

@Ian-Yy
Copy link
Contributor Author

Ian-Yy commented Oct 29, 2022

Hi. Regarding the CI Dependencies / check-bans that is failing, the issue is on error[duplicate]: found 2 duplicate entries for crate 'nix'. I am not entirely sure how to fix this. Can please guide me on fixing this?

@harudagondi
Copy link
Member

It's probably because of the alsa issue (diwic/alsa-rs#90) and #6359. Your code is currently fine, however someone else needs to simply just update the ignore file for nix versions.

@alice-i-cecile alice-i-cecile added the S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it label Oct 29, 2022
@@ -39,6 +39,13 @@
|flac|FLAC audio format support. It's included in bevy_audio feature.|
|mp3|MP3 audio format support.|
|wav|WAV audio format support.|
|symphonia-aac|AAC audio format support by Symphonia.|
|symphonia-all|AAC, FLAC, MP4, MP3, Vorbis, WAV support by Symphonia.|
|symphonia-flac|FLAC audio format support by Symphonia.|
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice to have a short explanation of how this is different than the flac feature (same for mp3 and wav)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do I put the explanation in this cargo_features file as well? Besides, AFAIK they are just different libraries. Both can be used to process audio files. A benefit I could think of using Symphonia is easily change audio formats used by games since it can probe the media source and decode accordingly instead of changing bunch of code when you need to change audio file from wav = hound to mp3 = minimp3.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bevy completely abstracts over the file loaded, so changing from wav to Flac would just mean changing the feature and the file extension.

I would like to see in this file why someone would enable a feature, and I'm not sure "support by Symphonia" is enough of a difference with the flac feature to help users decide which they need.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Internally, rodio parses audio files using the following libraries:

Format Library
flac claxon
vorbis lewton
wav hound
mp3 minimp3

Symphonia support parsing all of the mentioned file formats and more, however it is much "heavier" due to having support of more file formats. Therefore symphonia is not enabled by default.

Symphonia is usually enabled if:

  1. You have audio files not supported by any of the four audio files mentioned. (I don't think there's even a library for parsing aac files that is widely used and tested)
  2. You support a multitude of audio file formats and would not like to compile five different crates that essentially do the same thing (well, more than five, since symphonia have its own subcrates)

In this scenario, symphonia is just an implementation detail. Perhaps we can indicate that when enabling symphonia, they should disable other features to avoid redundancies. (also when you enable both mp3 and symphonia-mp3 features, the mp3 will actually be disable and symphonia will take priority. see here)

As such, enabling all the aformentioned features plus symphonia-all will simply render the above four features useless, while still compiling the corresponding libraries (i think. haven't delved deep into how rust compile dependencies).

Maybe the best thing to do is to link symphonia to its docs.rs page, and mention this comment (or put it) on symphonia-all's description.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd be very happy to add a modified version of this comment to the feature list.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a few more info to chip in after researching a bit.

On the codec mp3, the rodio is most likely also switching to symphonia due to cross compilations, potentially unsafe code and perhaps ios rejection as discussed here.

And also over here, it seems symphonia has more momentums compared to lewton for vorbis and therefore, could reiterate more often and provide more features/fixes perhaps?

@alice-i-cecile alice-i-cecile removed the S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it label Oct 31, 2022
@alice-i-cecile
Copy link
Member

Waiting to merge until @mockersf's concerns above are addressed a bit more. @harudagondi, perhaps you can help out?

@harudagondi
Copy link
Member

Hey @Ian-Yy can you update this PR? Would love to see this merged for Bevy 0.10

@Ian-Yy
Copy link
Contributor Author

Ian-Yy commented Dec 24, 2022

Hi @harudagondi, sorry not sure if I get it. Do you mean pulling the latest and re-apply the changes?

@harudagondi
Copy link
Member

Hi @harudagondi, sorry not sure if I get it. Do you mean pulling the latest and re-apply the changes?

Yes, and add a comment in the Cargo.toml or the cargo_features.md regarding the difference between the default decoder and symphonia.

@Ian-Yy
Copy link
Contributor Author

Ian-Yy commented Jan 6, 2023

Hi, I have merged and add more details in the cargo_features.md. Please let me know if any correction is needed.

docs/cargo_features.md Outdated Show resolved Hide resolved
docs/cargo_features.md Outdated Show resolved Hide resolved
@alice-i-cecile alice-i-cecile added the S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it label Jan 9, 2023
@alice-i-cecile
Copy link
Member

bors r+

bors bot pushed a commit that referenced this pull request Jan 9, 2023
# Objective
Fix #6301 

## Solution
Add new features in `bevy_audio` to use `symphonia` sound format from `rodio` 
Also add in `bevy`
@bors bors bot changed the title Expose symphonia features from rodio in bevy_audio and bevy [Merged by Bors] - Expose symphonia features from rodio in bevy_audio and bevy Jan 9, 2023
@bors bors bot closed this Jan 9, 2023
james7132 pushed a commit to james7132/bevy that referenced this pull request Jan 21, 2023
…ne#6388)

# Objective
Fix bevyengine#6301 

## Solution
Add new features in `bevy_audio` to use `symphonia` sound format from `rodio` 
Also add in `bevy`
alradish pushed a commit to alradish/bevy that referenced this pull request Jan 22, 2023
…ne#6388)

# Objective
Fix bevyengine#6301 

## Solution
Add new features in `bevy_audio` to use `symphonia` sound format from `rodio` 
Also add in `bevy`
ItsDoot pushed a commit to ItsDoot/bevy that referenced this pull request Feb 1, 2023
…ne#6388)

# Objective
Fix bevyengine#6301 

## Solution
Add new features in `bevy_audio` to use `symphonia` sound format from `rodio` 
Also add in `bevy`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Audio Sounds playback and modification C-Usability A simple quality-of-life change that makes Bevy easier to use S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Expose symphonia feature of rodio for bevy_audio
5 participants