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

Add master volume to Audioio #9623

Open
Extner32 opened this issue Sep 14, 2024 · 4 comments
Open

Add master volume to Audioio #9623

Extner32 opened this issue Sep 14, 2024 · 4 comments

Comments

@Extner32
Copy link

I know you can change the volume(gain) using the circuitpython mixer object. However, there are a few reasons that I think it should also be added to the audioio object:

  • Better preformance. I've tried to make a mp3 player on the Adafruit Pygamer but adding a mixer slows it down too much so the audio sounds poppy and choppy. Changing volume is really just multiplying all the samples by the volume. So one float multiplication built into the audioio module will probably be faster than having to create another object to do that for you.

  • Master volume control, so you don't have to set the volume for each voice.

@tannewt tannewt added the audio label Sep 16, 2024
@tannewt tannewt added this to the Long term milestone Sep 16, 2024
@tannewt
Copy link
Member

tannewt commented Sep 16, 2024

I don't really think we want this. To do it, we'd need most of what mixer is doing (the extra buffer and multiply). I don't think the object creation is what slowing things down. I suspect it's the multiplying of all of the samples. We could probably make mixer work better in single voice mode that you could use after a multi-voice mixer.

@Extner32
Copy link
Author

Why do you need an extra buffer to multiply all the samples?

@tannewt
Copy link
Member

tannewt commented Sep 23, 2024

You don't. That's my mistake. I still think this is better done as an optimization on Mixer though.

@gamblor21
Copy link
Member

I have been spending a lot of time deep-diving into the audio code lately and I'm not sure if moving it from Mixer to anywhere else will see much of a speedup. As is the Mixer code basically only does what you describe, multiple each sample by a value. I'm not even sure there is room for much optimization in there.

The other issue is the audioio code is port specific so would have to be done for each port.

I do not have a PyGamer so cannot easily try it out unfortunately.

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

No branches or pull requests

3 participants