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

Audio getting progressively worse. (By default) #13508

Closed
redstonerti opened this issue May 25, 2024 · 9 comments
Closed

Audio getting progressively worse. (By default) #13508

redstonerti opened this issue May 25, 2024 · 9 comments
Labels
A-Audio Sounds playback and modification C-Usability A targeted quality-of-life change that makes Bevy easier to use

Comments

@redstonerti
Copy link

Bevy version

0.13.2

[Optional] Relevant system information

Windows 11 x64, Ryzen 7 4700U with Radeon Graphics

What you did

I searched up how to play a sound in bevy, and used this code from a bevy example to play some mp3 files for my pong clone.
https://github.com/bevyengine/bevy/blob/main/examples/audio/audio.rs
commands.spawn(AudioBundle { source: asset_server.load("sounds/Windless Slopes.ogg"), ..default() });

What went wrong

Every time a sound plays, the audio quality gets worse. At 100 sounds played, it is unrecognisable. I have a video here to show it more clearly:

2024-05-25.20-50-58.mp4
@redstonerti redstonerti added C-Bug An unexpected or incorrect behavior S-Needs-Triage This issue needs to be labelled labels May 25, 2024
@hymm
Copy link
Contributor

hymm commented May 25, 2024

I believe the audio entities by default don't get despawned. You can change the behavior to PlaybackMode::Despawn on the audio bundle https://docs.rs/bevy/latest/bevy/audio/enum.PlaybackMode.html

@redstonerti
Copy link
Author

I have already tried that. Here is the full code:
https://github.com/redstonerti/pong/

@redstonerti
Copy link
Author

Nevermind, I hadn't set it in every instance that I spawned an AudioBundle. May I ask why it isn't Despawn by default?

@mweatherley
Copy link
Contributor

mweatherley commented May 26, 2024

Nevermind, I hadn't set it in every instance that I spawned an AudioBundle. May I ask why it isn't Despawn by default?

I think it's not the default because it creates very undesirable behavior when an AudioBundle is attached to a normal entity with other data (i.e. it causes the entire entity to be destroyed when audio stops playing). (However, the default right now is also just very bad.)

@redstonerti redstonerti reopened this May 27, 2024
@redstonerti redstonerti changed the title Audio getting progressively worse. Audio getting progressively worse. (By default) May 27, 2024
@redstonerti
Copy link
Author

redstonerti commented May 27, 2024

It's possible that spawning audio as a component is not a good idea. Wouldn't it be better if it was a resource that could be accessed from anywhere, like Commands or something?

Maybe something like this?

AudioManager.play(source_file, AudioSettings{volume, pitch, Mode::Spatial3D(x,y,z)});

Although now that I think about it, it is really convenient how it is right now, because you can spawn AudioBundles along with enities and they can access and play them whenever they want, without having to necessarily know what they are playing. I could be picking up a rock or a stick for example, and they could be playing different audio with the same code, just by being spawned differently

@hymm
Copy link
Contributor

hymm commented May 27, 2024

How would you do spatial audio with a resource?

@redstonerti
Copy link
Author

redstonerti commented May 27, 2024

How would you do spatial audio with a resource?

I have no idea and no experience. I was just typing what I was thinking. Forget the spatial audio, I just thought it could be simpler to use a resource to play sounds.

@rparrett
Copy link
Contributor

See also #12359

@alice-i-cecile alice-i-cecile added A-Audio Sounds playback and modification C-Usability A targeted quality-of-life change that makes Bevy easier to use and removed C-Bug An unexpected or incorrect behavior S-Needs-Triage This issue needs to be labelled labels Jun 1, 2024
@alice-i-cecile
Copy link
Member

#12359 is much clearer to track: I'm going to close this out in favor of that issue.

@alice-i-cecile alice-i-cecile closed this as not planned Won't fix, can't repro, duplicate, stale Jun 1, 2024
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 targeted quality-of-life change that makes Bevy easier to use
Projects
Status: Done
Development

No branches or pull requests

5 participants