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

Getting access to a Frame from a Handle #15

Open
woelper opened this issue Oct 18, 2021 · 6 comments
Open

Getting access to a Frame from a Handle #15

woelper opened this issue Oct 18, 2021 · 6 comments

Comments

@woelper
Copy link

woelper commented Oct 18, 2021

Hi, and thanks for this great library!
I am experimenting with Kira and bevy, as well as building a super simple audio player for fun. I think it would be great to access a Frame at a time, for example to have a game entity react to the sound or add visualization to audio. I see that there is get_frame_at_position, but this is not implemented for the Handle. Would this be reasonable to add or am I missing a way to make this work with the current state maybe?

@tesselode
Copy link
Owner

SoundHandles don't have direct access to the Sound they represent. I'm changing Sounds to be a trait in kira v0.6, so you would be able to write a Sound implementor that stores its data in an Arc. v0.6 will also have a StaticSound struct which is essentially what the current Sound struct is, and I may end up storing the frames in an Arc, although I'm not sure if there would be any performance or usability drawbacks to doing so.

@woelper
Copy link
Author

woelper commented Oct 19, 2021

Thanks for your answer! This sounds great and I am very excited for 0.6 then!

@tesselode
Copy link
Owner

After re-reading this issue, I thin what you were requesting is a way to see the frame a sound is currently outputting, right, @woelper ?

@woelper
Copy link
Author

woelper commented Apr 19, 2022

Thanks, yes, you are correct.

Sorry for derailing this a bit, but would this work with StreamingSounds too?

@tesselode
Copy link
Owner

Yes. While you still can't get the currently playing frame from a handle, you can create an effect that sends the frames (or information about the frames, like the average amplitude) to an effect handle. I may do a write-up on how to implement this (or maybe even add it as a default effect).

@jakerr
Copy link
Contributor

jakerr commented Mar 22, 2023

you can create an effect that sends the frames (or information about the frames, like the average amplitude) to an effect handle.

I made a demo that does exactly this in my kira wrapper for Bevy.

See:
https://github.com/jakerr/bevy_mod_kira/blob/main/examples/effects/level_monitor/mod.rs
and it's usage
https://github.com/jakerr/bevy_mod_kira/blob/main/examples/level_monitor.rs

I realize it's been a year since the last comment here but thought for posterity's sake I'd share.

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

No branches or pull requests

3 participants