adafruit / circuitpython

CircuitPython - a Python implementation for teaching coding with microcontrollers
https://circuitpython.org
Other
4.12k stars 1.22k forks source link

Add master volume to Audioio #9623

Open Extner32 opened 2 months ago

Extner32 commented 2 months ago

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:

tannewt commented 2 months ago

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 commented 1 month ago

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

tannewt commented 1 month ago

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

gamblor21 commented 1 month ago

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.