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

Allow changing pitch of sound being currently played #1241

Open
aleokdev opened this issue Aug 16, 2023 · 0 comments
Open

Allow changing pitch of sound being currently played #1241

aleokdev opened this issue Aug 16, 2023 · 0 comments

Comments

@aleokdev
Copy link
Contributor

aleokdev commented Aug 16, 2023

I'd like to change the pitch of a sound that is being played. To do this, it's as easy as changing the rodio audio sink's speed while it is playing. However, we do not currently have access to the underlying sink in a Source. While Source.set_pitch exists, it only changes the pitch of the subsequent sounds to be played. While this is also an useful feature to have (for e.g. pitching sounds like footsteps randomly), I think we should have the ability to change the pitch of currently playing sounds as well.

We have a couple options here, but I think the most sensible one is to actually have set_pitch affect the current sounds being played as set_volume does, but also accept parameters on all play functions to set the starting properties of the sound (e.g. speed, fadein, skip duration). Right now these properties are stored in the source instead. While this does work I think it'd make sense to go with the aforementioned approach as it is also consistent with how Drawables work. (There's a DrawParam that stores the sprite info which is passed to the draw function, instead of storing it in the canvas.)

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

1 participant